The basic idea is that those annotation classes come with better defaults (e.g. default to use the config storage controller) and that annotation keys which are specific to either of those can be moved down.

See also the discussion in #2116551: Fix the UX of Entity Reference fields about using groups to identify them.

CommentFileSizeAuthor
#48 2119905-48.patch1.83 KBdamiankloip
#41 interdiff-2119905-41.txt741 bytesdamiankloip
#41 2119905-41.patch38.96 KBdamiankloip
#39 interdiff-2119905-39.txt615 bytesdamiankloip
#39 2119905-39.patch38.86 KBdamiankloip
#37 interdiff-2119905-37.txt1.83 KBdamiankloip
#37 2119905-37.patch38.26 KBdamiankloip
#35 interdiff-2119905-35.txt644 bytesdamiankloip
#35 2119905-35.patch38.54 KBdamiankloip
#33 2119905-33.patch41.61 KBdamiankloip
#31 interdiff-2119905-31.txt12.15 KBdamiankloip
#31 2119905-31.patch43.74 KBdamiankloip
#28 2119905-28.patch37.82 KBdamiankloip
#20 interdiff-2119905-20.txt643 bytesdamiankloip
#20 2119905-20.patch36.43 KBdamiankloip
#18 interdiff-2119905-18.txt924 bytesdamiankloip
#18 2119905-18.patch36.42 KBdamiankloip
#17 interdiff.txt500 bytestim.plunkett
#17 entity-2119905-17.patch36.52 KBtim.plunkett
#15 entity-2119905-15.patch36.52 KBtim.plunkett
#15 interdiff.txt13.3 KBtim.plunkett
#13 interdiff.txt580 bytestim.plunkett
#13 config-entity-2119905-13.patch23.63 KBtim.plunkett
#11 config-entity-2119905-11.patch23.62 KBtim.plunkett
#9 config-entity-2119905-9a-do-not-test.patch22.64 KBtim.plunkett
#9 config-entity-2119905-9b-do-not-test.patch23.62 KBtim.plunkett
#9 config-entity-2119905-9c-do-not-test.patch22.73 KBtim.plunkett
#9 interdiff-a-b.txt1.32 KBtim.plunkett
#9 interdiff-a-c.txt20.03 KBtim.plunkett
#5 config-entity-type-annotation-2119905-5.patch28.86 KBberdir
#4 config-entity-type-annotation-2119905-4.patch29.3 KBberdir
#1 config-entity-type-annotation-2119905-1.patch2.37 KBberdir

Comments

berdir’s picture

Just experimenting a bit.

As nice as having a group label would be, it's a) ugly to do something based on it and b) I have no idea how to have a translatable default group label there...

berdir’s picture

Status: Active » Needs review
dawehner’s picture

We should consider to keep maybe the storage controllers on some of the examples in order to show people how to override it.

On the other hand it is really great to simplify the initial work.

berdir’s picture

Issue summary: View changes
StatusFileSize
new29.3 KB

Changed all config entities.

Deleted two storage controllers, one was empty and the other only contained methods that we don't call, because those pre/post thingies were moved to entity classes a long time ago.

berdir’s picture

Re-roll.

msonnabaum’s picture

This is definitely an improvement, but I dont get why getAnnotationReader is being made public in this patch.

berdir’s picture

That's just a left-over from experimenting, shouldn't have made it into the patch. I initially thought it would be necessary but as long as all the annotation classes are in the same directory, it just works.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Related issues: +#2005716: Promote EntityType to a domain object

This will need a reroll soon.

tim.plunkett’s picture

StatusFileSize
new20.03 KB
new1.32 KB
new22.73 KB
new23.62 KB
new22.64 KB

Just to ensure I wasn't breaking the ability to do this with #2005716: Promote EntityType to a domain object, I've rerolled this now.

9A is the closest equivalent to a reroll.
9B shows some more options we have with how to deal with the different methods.
9C skips the annotation completely to use the new entity_type_class property directly.

All of these are suffixed with -do-not-test since they won't apply until the other issue goes in.

yched’s picture

The c) option with the 'entity_type_class' looks weird - the @ annotation used points at a class, but the actual content of the annotation in fact points to a different (sub)class ?
Why would we go with that rather than a) / b) ?

tim.plunkett’s picture

StatusFileSize
new23.62 KB

A and B both contain a \Drupal\Core\Entity\Annotation\EntityType class that have public $entity_type_class = 'Drupal\Core\Config\Entity\ConfigEntityType';

C just skips the middleman.

This is a reroll of B now that the blocker went in.

Status: Needs review » Needs work

The last submitted patch, 11: config-entity-2119905-11.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new23.63 KB
new580 bytes

Silly mistake.

dawehner’s picture

What happened with the ContentEntityType announced in the title?

+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
@@ -0,0 +1,61 @@
+    );
...
+  public function getControllers() {
+    return parent::getControllers() + array(
+      'storage' => 'Drupal\Core\Config\Entity\ConfigStorageController',
...
+  }

Out of scope: Did we ever considered to automatically add the config entity list controller here?

tim.plunkett’s picture

StatusFileSize
new13.3 KB
new36.52 KB

Hah, forgot about that part.

There are 3 entity types that are neither config nor content (extend Entity directly):
FieldUITestNoBundle
EntityCacheTest
MenuLink

Status: Needs review » Needs work

The last submitted patch, 15: entity-2119905-15.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new36.52 KB
new500 bytes

Fixing SearchPage.

damiankloip’s picture

StatusFileSize
new36.42 KB
new924 bytes

Rerolled, and made a couple of minor docs tweaks. Let's get this back on the road.

I would like to revive #2004336: Default UUID key in ConfigEntityType.

Status: Needs review » Needs work

The last submitted patch, 18: 2119905-18.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new36.43 KB
new643 bytes

getControllerClasses() happened.

Status: Needs review » Needs work

The last submitted patch, 20: 2119905-20.patch, failed testing.

damiankloip’s picture

20: 2119905-20.patch queued for re-testing.

tstoeckler’s picture

+++ /dev/null
@@ -1,32 +0,0 @@
-  }
...
-    entity_info_cache_clear();
...
-  protected function preDelete($view_modes) {
...
-   */
...
-   * {@inheritdoc}
...
-  /**
...
-  }
...
-    entity_info_cache_clear();
...
-  protected function preSave(EntityInterface $view_mode) {
...
-   */
...
-   * {@inheritdoc}
...
-  /**

Are we sure it is safe deleting this? I don't see this being mentioned anywhere.

damiankloip’s picture

Are we sure it is safe deleting this? I don't see this being mentioned anywhere.

Well, these methods aren't used on storage controllers like this anymore, are they?

damiankloip’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
+++ /dev/null
@@ -1,32 +0,0 @@
-class EntityDisplayModeStorageController extends ConfigStorageController {
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function preSave(EntityInterface $view_mode) {
-    entity_info_cache_clear();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function preDelete($view_modes) {
-    entity_info_cache_clear();
-  }

This is dead code, the preSave() and preDelete() have been moved from the storage controller to the entity in #1893772: Move entity-type specific storage logic into entity classes

Looks good, thanks @damiankloip

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

2119905-20.patch no longer applies.

error: core/modules/entity/lib/Drupal/entity/Entity/EntityDisplay.php: No such file or directory

damiankloip’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new37.82 KB

Rerolled.

berdir’s picture

+++ b/core/modules/editor/lib/Drupal/editor/Entity/Editor.php
index 0000000..0f44c3d
--- /dev/null

--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityDisplay.php

+++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityDisplay.php
+++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityDisplay.php
@@ -0,0 +1,71 @@

@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\Entity\EntityDisplay.
+ */
+
+namespace Drupal\entity\Entity;

I think your merge went wrong here? The class has been renamed AFAIK.

Wondering if we shouldn't add the default storage controller to content entities too, that should be FieldableDatabaseStorageController.

Also, should we move certain annotrations to the subclasses? Only config entities have a config_prefix, only content entities can be fieldable (should be extensible).

Status: Needs review » Needs work

The last submitted patch, 28: 2119905-28.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new43.74 KB
new12.15 KB

Ok, so something like this?

I'm not sure about moving the fieldable stuff, as people could extend from EntityType and not use ContentEntityType but want to use fields etc?

Status: Needs review » Needs work

The last submitted patch, 31: 2119905-31.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new41.61 KB

Whoops

Status: Needs review » Needs work

The last submitted patch, 33: 2119905-33.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new38.54 KB
new644 bytes

Sorry.

Status: Needs review » Needs work

The last submitted patch, 35: 2119905-35.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new38.26 KB
new1.83 KB

Should fail less I think.

Status: Needs review » Needs work

The last submitted patch, 37: 2119905-37.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new38.86 KB
new615 bytes

Status: Needs review » Needs work

The last submitted patch, 39: 2119905-39.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new38.96 KB
new741 bytes

This should be it. SORRY.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice work.!

jibran’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs change record

Please set back to RTBC once change record is created. Sorry for changing it back to NR.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed b0da3ae and pushed to 8.x. Thanks!

rszrama’s picture

Thanks, this'll be helpful. : )

damiankloip’s picture

Status: Fixed » Needs review
StatusFileSize
new1.83 KB

Some minor things crept in one of the re-rolls. It's just removing a couple of things.

Can we just add this here?

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yay, more code to remove :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 8b40554 and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.