orm – Clean architecture and entity framework

There were some problems when generating a database schema from business objects with EF Core:

  • No support for structural properties
  • No support for interface properties
  • I need additional columns, which should only belong to the data level.

I do not want to change my layer of business (structures / interfaces to classes) just because of EF, because that violates the principles of clean architecture (framework should serve your application, not vice versa). Adding persistence-specific columns to the business layer is also out of the question.

I suppose the right thing is to add persistence objects to the persistence layer that would represent entities in the business layer.
In addition, some of the business layer's mappers would need to be used to abstract persistence objects that they map to the business entities.

Some questions about this approach:

  • Is that correct? Are there alternatives? For example, EF configuration functions that allow me to solve the problems listed above without replicating entities in the persistence layer?
  • This feels like a lot of boilerplate code and the replication of the same features. Seems like this code could be generated automatically by a tool. Is there something like that?
  • Is there a good example of what such an approach should look like?

Java – 2414 Entity and the Cubes


The entity won n dice and decided to build a pyramid with them. It should be built according to the following pattern: The top should contain 1 dice, the second level should contain 1 + 2 = 3 dice, the third level should contain 1 + 2 + 3 = 6 dice and so on. The i-th stage of the pyramid must therefore contain 1 + 2 + … + (i – 1) + i cubes.

The entity wants to know what maximum height it can build with n cubes.

Note: The entity can not create parts of a level. or she denies everything or she does not build.

Input format:

The single line of the entry contains an integer n that represents the number of cubes earned by the entity.

Output format:

Returns an integer representing the largest possible height of the pyramid.

8 – Why do I get the message "Type does not match any entity on this site" when I send a POST to a REST API behind an Apache reverse proxy?

I've configured the REST API to POST new users / entity / user, It works fine on my local computer. As soon as I access my remote host, it stops working.

The main difference is that my site runs on my local computer in a docking container bound to port 6050 so all remaining calls are sent to localhost: 6050,

On my remote host, I configured Docker behind an Apache 2.4 reverse proxy. The Docker container is thus still bound to all requests should go to https://example.tld/,

In summary, a new user is sent to http: // localhost: 6050 / entity / user? _format = hal_json, with the corresponding X-CSRF token and content type Header set, works. It returns 200,

Posting to https: // sub.example.tld/entity/user? _format = hal_json, with the corresponding X-CSRF token and content type Header set, not. It returns 422 Unprocessable unit,

{"message": "Enter https:  /  / sub.example.tld  / rest  / type  / user  / user does not match any entity on this site."}

I manually set the user's _links array:

"_Left": {
"Type": {
"href": "https: //example.tld/rest/type/user/user"

I know that authentication is not the problem. My code successfully accesses views that require authentication.

Since I think it might have something to do with these settings, I have the following set:

  • $ Settings['trusted_host_patterns'] = ["$sub.example.tld$"]
  • $ Settings['reverse_proxy'] = TRUE;
  • $ Settings['reverse_proxy_addresses'] = ["internal network ip","",""];

I use Drupal 8.7.3.

My Docker image is based on PHP: 7.1 Apache.

Any ideas, what am I doing wrong?

Non-matching entity and / or field definitions for the comment field

I received this message

Mismatched entity and / or field definitions
The following changes have been detected in the entity type and field definitions.
The Entity Type field needs to be updated.
The Name field of the comment field needs to be updated.

I've tried a lot of things, including running entup (apparently deprecated) and adding a few lines to the entity update in index.php. Nothing worked, I do not use any comments on my site, but I still want to dissolve any ideas about that?

8 – When integrating custom entity views, the missing operator is empty

I have a custom entity called Measurement, There is a baseField definition Field called completed, When I create a view for this custom entity, I want to add a filter to the view so that only Measurementhave that completed The completed field is displayed.

I do not see the option in my filter for Is empty, Is that due to the way I've defined my field in mine? baseField definition?

$ Fields['completed'] = BaseFieldDefinition :: create (& # 39; datetime & # 39;)
-> setLabel (t (# date completed & # 39;))
-> setRevisionable (TRUE)
-> setDefaultValue (& # 39; & # 39;)
-> setDisplayOptions (& # 39; view & # 39 ;, [
    'label' => 'above',
    'type' => 'string',
    'weight' => -3,
-> setDisplayOptions (& # 39; form & # 39 ;, [
    'type' => 'datetime_default',
    'weight' => -3,
-> setDisplayConfigurable (& # 39; form & # 39 ;, TRUE)
-> setDisplayConfigurable (& # 39; view & # 39 ;, TRUE);

Entities – How do I get a plain text tagged list from a polyvalent entity reference field in Drupal 8?

I have a module that creates custom RSS feeds for me.

In a content type, my tags are stored in the field_tags entity reference field.

My goal is to get the names of all the tags and put them in an array so they can get into a tokenless RSS field.

When I pull the data, I get it like this:

foreach ($ this-> dbh-> selectVideos (self :: RPP) as $ nid) {
$ node = $ this-> entityMgr-> getStorage (& # 39; node & # 39;) -> load ($ nid);

if (! empty ($ node)) {
$ data-> node[] = [
      'title'    => $this->filterTxt($node->title->value),
      'body'     => $this->filterTxt($node->get('field_paragraph')->value),
      'body2'     => $this->filterTxt($node->get('field_paragraph')->value),
      'created'  => date('D, d M Y H:i:s', $node->created->value) . ' GMT',
      'guid'     => $node->id(),
      'img'      => $this->getImgUrl($node, self::IMG_FIELD),
      'keywords' => $this->filterTxt($node->get('field_tags')->value),
      'video'    => $node->get('field_vid_url')->getString(),
return $ this-> render ($ data, & # 39; nameoffeed & # 39;);


The problem is that & # 39; field_tags & # 39; is an entity reference field and therefore remains empty.

I had some success with it:

                if ($ node-> hasField (& # 39; field_tags & # 39;)) {
$ entity_ref = $ node-> get (& # 39; field_tags & # 39;);
if ($ entity_ref-> count ()> 0) {
$ tagoutput = entity_view ($ entity_ref-> entity, & # 39; default & # 39;);

Then set & # 39; keywords & # 39; on $ tagoutput. This takes up the first day, which is not great because I need them all, and then comes a complete HTML layout package that does not work for an RSS feed.

I'm confused, which is the right way to get a proper list of tag names. In D6 I had this list as plain text, which was not great because you could not click on one in the page view and be led to a list of all pages with that tag, but at least the tags that were being worked on are easily taken ,

Any thoughts?

tools – Entity web of entity interaction within the site

I'm looking for a tool that lets you create a network of entities of people and organizations (with images) that are connected to each other.
Most of all, I would like every connection to be explained as well, for example: you see that John has a connection to Peter, and when you click on the connection, it is explained that they went to school together with an old photo of them ,

Is there a tool for that matter that can be embedded in a website if users of that site can interact with that web of entities?
An open source / free tool would be nice, but if that's not available, a paid service is enough.

Thank you in advance!

8 – Change the entity label method of the user

By default, the label () method returns the user name for the user entity. Everywhere on the website where user references are used, the username is displayed.

I need to change this method so that the username appears wherever it uses my custom function. For example, instead of "custom_user_name", "Firstname Lastname" is displayed.

Any idea how this can be achieved? Many Thanks.

entity – Change table_name to Content Entity

In Drupal 8, I have a permission that I want to save in another database, d. H. Not the standard. I found this post on Drupal Answers, which seems to provide a solution. I am not sure how to implement it. I'm using the sample module with the content_entity_example. In Contact.php I see:

    * @ContentEntityType (
* id = "content_entity_example_contact",
* label = @Translation ("contact person"),
* handler = {
* "view_builder" = "Drupal  Core  Entity  EntityViewBuilder",
* "list_builder" = "Drupal  content_entity_example  Entity  Controller  ContactListBuilder",
* "form" = {
* "default" = "Drupal  content_entity_example  Form  ContactForm",
* "delete" = "Drupal  content_entity_example  Form  ContactDeleteForm",
* "access" = "Drupal  content_entity_example  ContactAccessControlHandler",
* list_cache_contexts = {"user"},
* base_table = "drupal.contact",
* admin_permission = "Manage contact person",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid"

I want to change the base ~ _table. The above post indicates that I should change the base_table shortly before this class definition:

Class Contact extends ContentEntityBase implements ContactInterface {

use EntityChangedTrait;

What is the correct syntax? Reference here