Comments

Berdir created an issue. See original summary.

berdir’s picture

Status: Active » Needs review
StatusFileSize
new17.74 KB

Deprecated most of the easy cases, a bunch of usages left that need other services that aren't already injected.

Status: Needs review » Needs work

The last submitted patch, 2: entity-form-entity-manager-2969109-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kaythay’s picture

Status: Needs work » Needs review
StatusFileSize
new20.12 KB
new3.88 KB

Rerolling with some test fixes.

berdir’s picture

Status: Needs review » Needs work
Parent issue: » #2886622: Deprecate all EntityManager methods with E_USER_DEPRECATED
+++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
@@ -48,6 +48,13 @@
 
+  /**
+   * The entity field manager.
+   *
+   * @var \Drupal\Core\Entity\EntityFieldManagerInterface;
+   */
+  protected $entityFieldManager;
+

this seems to be some kind of leftover that's not actually injected or used here as far as I see?

Also not sure why the changes to BlockContentTypeTest were added, that's not a form?

martin107’s picture

Assigned: Unassigned » martin107

I am looking at this now.

martin107’s picture

Assigned: martin107 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.83 KB
new16.73 KB

a) entityFieldManager - "not actually injected or used". Confirmed .. a good reason to remove it

b) BlockContentTypeTest - although the work looks good we do need to deconflict to prevent overlap

Just as a mini review - I have visually scanned the patch all changes look good.

berdir’s picture

Title: Replace deprecated usages of entityManager in entity form classes » Replace deprecated usages of entityManager in form classes
Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php
@@ -33,12 +33,12 @@ trait ConfigDependencyDeleteFormTrait {
-   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    *   The entity manager.

"The entity type manager"

This is also not complete yet, there are a few more. I'm expanding it to all form classes, sincde there aren't many more.

find core/ -name "*Form.php" | xargs grep "entityManager-"
core/modules/views_ui/src/Form/BreakLockForm.php:    $account = $this->entityManager->getStorage('user')->load($locked->getOwnerId());
core/modules/config/src/Form/ConfigSingleImportForm.php:      $definition = $this->entityManager->getDefinition($this->data['config_type']);
core/modules/config/src/Form/ConfigSingleImportForm.php:    foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
core/modules/config/src/Form/ConfigSingleImportForm.php:      $definition = $this->entityManager->getDefinition($form_state->getValue('config_type'));
core/modules/config/src/Form/ConfigSingleImportForm.php:      $entity_storage = $this->entityManager->getStorage($form_state->getValue('config_type'));
core/modules/config/src/Form/ConfigSingleExportForm.php:    foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
core/modules/config/src/Form/ConfigSingleExportForm.php:      $definition = $this->entityManager->getDefinition($form_state->getValue('config_type'));
core/modules/config/src/Form/ConfigSingleExportForm.php:      $entity_storage = $this->entityManager->getStorage($config_type);
core/modules/comment/src/CommentTypeForm.php:      foreach ($this->entityManager->getDefinitions() as $entity_type) {
core/modules/comment/src/CommentTypeForm.php:        '#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(),
core/modules/language/src/Form/ContentLanguageSettingsForm.php:    $entity_types = $this->entityManager->getDefinitions();
core/modules/language/src/Form/ContentLanguageSettingsForm.php:    $bundles = $this->entityManager->getAllBundleInfo();
core/modules/field_ui/src/Form/FieldConfigEditForm.php:    $bundles = $this->entityManager->getBundleInfo($this->entity->getTargetEntityTypeId());
core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php:    return $this->entityManager->getFormModes($this->entity->getTargetEntityTypeId());
core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php:    return $this->entityManager->getFormModeOptions($this->entity->getTargetEntityTypeId());
core/modules/field_ui/src/Form/FieldConfigDeleteForm.php:    $bundles = $this->entityManager->getBundleInfo($this->entity->getTargetEntityTypeId());
core/modules/field_ui/src/Form/FieldStorageAddForm.php:    $entity_type = $this->entityManager->getDefinition($this->entityTypeId);
core/modules/field_ui/src/Form/FieldStorageAddForm.php:        $this->entityManager->getStorage('field_storage_config')->create($field_storage_values)->save();
core/modules/field_ui/src/Form/FieldStorageAddForm.php:        $field = $this->entityManager->getStorage('field_config')->create($field_values);
core/modules/field_ui/src/Form/FieldStorageAddForm.php:        $field = $this->entityManager->getStorage('field_config')->create([
core/modules/field_ui/src/Form/FieldStorageAddForm.php:    foreach ($this->entityManager->getFieldStorageDefinitions($this->entityTypeId) as $field_name => $field_storage) {
core/modules/field_ui/src/Form/FieldStorageAddForm.php:    $field_ids = $this->entityManager->getStorage('field_config')->getQuery()
core/modules/field_ui/src/Form/FieldStorageAddForm.php:    $fields = $this->entityManager->getStorage('field_config')->loadMultiple($field_ids);
core/modules/field_ui/src/Form/FieldStorageAddForm.php:    $field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($this->entityTypeId);
core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php:    return $this->entityManager->getViewModes($this->entity->getTargetEntityTypeId());
core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php:    return $this->entityManager->getViewModeOptions($this->entity->getTargetEntityTypeId());
core/modules/node/src/Form/NodePreviewForm.php:    $view_mode_options = ['full' => $this->t('Full')] + $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());
core/modules/node/src/NodeTypeForm.php:      $fields = $this->entityManager->getBaseFieldDefinitions('node');
core/modules/node/src/NodeTypeForm.php:      $node = $this->entityManager->getStorage('node')->create(['type' => $type->uuid()]);
core/modules/node/src/NodeTypeForm.php:      $fields = $this->entityManager->getFieldDefinitions('node', $type->id());
core/modules/node/src/NodeTypeForm.php:      $node = $this->entityManager->getStorage('node')->create(['type' => $type->id()]);
core/modules/node/src/NodeTypeForm.php:    $fields = $this->entityManager->getFieldDefinitions('node', $type->id());
core/modules/node/src/NodeTypeForm.php:    $node = $this->entityManager->getStorage('node')->create(['type' => $type->id()]);
core/modules/node/src/NodeTypeForm.php:    $this->entityManager->clearCachedFieldDefinitions();

Some are already being updated in #3025427: Add @trigger_error() to deprecated EntityManager->EntityTypeBundleInfo methods, you might want to skip those or wait on that to get in.

berdir’s picture

That issue landed, so this could use a reroll, happy to do reviews here.

martin107’s picture

Status: Needs work » Needs review

so after a git pull I am one commit ahead ...

2969109-8.patch still applies so no reroll is needed.

commit 3eeddcfcaccfb06760a748d8c2a22ac077fee2ec (HEAD -> 8.7.x, origin/8.7.x)
Author: Gábor Hojtsy <gabor@hojtsy.hu>
Date:   Tue Feb 26 16:37:13 2019 +0100

    Issue #2937639 by hotwebmatter, hiway, andrewmacpherson, markconroy, shaal, cehfisher, mgifford, kjay, Eli-T, kbeck303: Umami Theme - a11y context is needed for read more links

commit 81915a93a35b0b97314e008827745de5122bac9b
Author: Alex Pott <alex.a.pott@googlemail.com>
Date:   Tue Feb 26 15:05:23 2019 +0000

    Issue #3025427 by Berdir, amateescu: Add @trigger_error() to deprecated EntityManager->EntityTypeBundleInfo methods
berdir’s picture

Status: Needs review » Needs work

Ok, still a bunch of forms left however that need to be updated :)

alexpott’s picture

Also can we use the deprecated property trait so we can prove we've removed all usages in core?

berdir’s picture

The thing is that forms and some other entity handlers are different and get the entity (type) manager injected through setter methods, so we can't remove the property as it would always be triggered. And I'd rather not remove that method/call.

Doing a grep on all *Form.php files is pretty easy as I did in #9 and we will catch anything we missed as soon as we deprecate the methods entirely.

martin107’s picture

Assigned: Unassigned » martin107

I am going to chew on this awhile.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new48.78 KB
new34.22 KB

Ok progress, not ready for human review yet.. BUT testbot should return a list of broken test for me to address.

So in this patch

a) Fixed the "The entity type manager" change form #9

b) Regarding the question

Also can we use the deprecated property trait so we can prove we've removed all usages in core?

and the "injected through setter method" response in #14

In the last batch of changes there were only two such classes EntityViewDisplayEditForm and EntityFormDisplayEditForm both derived from a FormBase class

So that prompted the query against both

find core/ -name "*Form.php" | xargs grep "entityManager-"

and

find core/ -name "*FormBase.php" | xargs grep "entityManager-"

I have made lots of little changes so the potential for err is large. All I can say is that site install works.

Status: Needs review » Needs work

The last submitted patch, 16: 2969109-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

martin107’s picture

Status: Needs work » Needs review
Issue tags: +Needs change record
StatusFileSize
new52.1 KB
new11.95 KB

This should have fewer errors.

Note to self.

So at least some of the entity_type method calls need to be made to the other services formed when it was broken up. ( I used this change record as a reference https://www.drupal.org/node/2549139 )

Additionally I need to write a change record as the end.
[
a) EntityFormInterface was given an additional setter
b) I add the EntityFIeldManagerInterface and the EntityDisplayRepositoryInterface to a few constructors
]

I will work on the remaining failures tomorrow.

Status: Needs review » Needs work

The last submitted patch, 18: 2969109-18.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

  1. +++ b/core/lib/Drupal/Core/Entity/EntityForm.php
    @@ -441,4 +441,11 @@ public function setEntityTypeManager(EntityTypeManagerInterface $entity_type_man
     
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function setEntityFieldManager(EntityFieldManagerInterface $entity_field_manager) {
    +    $this->entityFieldManager = $entity_field_manager;
    +    return $this;
    +  }
     }
    

    we should not do this. Instead inject this service to teh specific forms that need it, should only be a few.

  2. +++ b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
    @@ -67,14 +67,14 @@ protected function getDefaultPlugin($field_type) {
        */
       protected function getDisplayModes() {
    -    return $this->entityManager->getFormModes($this->entity->getTargetEntityTypeId());
    +    return $this->entityTypeManager->getFormModes($this->entity->getTargetEntityTypeId());
       }
     
       /**
        * {@inheritdoc}
        */
       protected function getDisplayModeOptions() {
    -    return $this->entityManager->getFormModeOptions($this->entity->getTargetEntityTypeId());
    +    return $this->entityTypeManager->getFormModeOptions($this->entity->getTargetEntityTypeId());
       }
    

    this is on the entity display repository, again something that you need to inject through the constructor.

  3. +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php
    @@ -57,17 +73,24 @@ class FieldStorageAddForm extends FormBase {
         $this->fieldTypePluginManager = $field_type_plugin_manager;
         $this->configFactory = $config_factory;
    +    if (!$this->entity_field_manager) {
    +      @trigger_error('\Drupal\Core\Entity\EntityFieldManagerInterface is a dependency of this class in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
    +      $entity_field_mananger = \Drupal::service('file_system');
    +    }
    

    wrong service.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new52.58 KB
new5.5 KB

1) implemented the setEntityFieldManager() suggestion -- after seeing the new implementation I am happy enough that the one in a hundred contrib module affected by this will "feel" guided by core to the correct alteration.

2, 3 fixed.

Status: Needs review » Needs work

The last submitted patch, 21: 2969109-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new52.98 KB
new5.5 KB

Ok so just cleaning up unforced errors on my part ... as clear sign I should spent the rest of the weekend doing something relaxing.

It is not reasonable that others fix my mistakes .. so more from me Monday night.

Status: Needs review » Needs work

The last submitted patch, 23: 2969109-23.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

+++ b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
+++ b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
@@ -100,14 +100,14 @@ protected function getDefaultPlugin($field_type) {

@@ -100,14 +100,14 @@ protected function getDefaultPlugin($field_type) {
    * {@inheritdoc}
    */
   protected function getDisplayModes() {
-    return $this->entityTypeManager->getViewModes($this->entity->getTargetEntityTypeId());
+    return $this->entityFieldManager->getViewModes($this->entity->getTargetEntityTypeId());
   }
 
   /**

not entity field manager, entity display repository :)

that's why we shouldn't add a setEntityFieldManager(), there are several new services and each form that used entity manager is likely going to need a different set of replacement services.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new52.31 KB
new7.99 KB

a) #25 -- I have fix up the code in this area. Thanks for the rapid review.

b) The changes made to NodePreviewForm are questionable - I expect to undo them ... but they may be useful for a conversation.

The argument signature of

NodePreviewForm::create()
NodePreviewFrom::constructor()

have changed so what I have done will be a breaking change, as if contrib has done any dependency injection then this will spawn errors.

If contrib has only extended buildFrom() then this would be a inconsequential change.

Alternately what I am trying to say is that following the pattern of :-

leaving a entityManagerInterface as the first parameter and adding
a optional EntityDisplayRepositoryInterface to the end of the constructor with the appropriate trigger warning -
is not going to cut it here as we are just making work for ourself and contrib. In D9 we would have to come back and adjust the signatures to remove the entityManger parameter.

berdir’s picture

Status: Needs review » Needs work
Issue tags: -Needs change record
+++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
@@ -63,17 +63,17 @@ abstract class EntityDisplayFormBase extends EntityForm {
+    if (!$entity_display_repository) {
+      @trigger_error('\Drupal\Core\Entity\EntityDisplayRepositoryInterface is a dependency of this class in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/2969109.', E_USER_DEPRECATED);
+      $entity_display_repository = \Drupal::service('entity_display.repository');
     }

The format for these messages has changed a few times and is pretty inconsistent but I'd suggest to follow the format that I've used in the last few issues, see for example \Drupal\Core\Entity\Sql\SqlContentEntityStorage::__construct()

  1. +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
    @@ -730,11 +745,11 @@ public function reduceOrder($array, $a) {
       protected function getExtraFields() {
         $context = $this->displayContext == 'view' ? 'display' : $this->displayContext;
    -    $extra_fields = $this->entityManager->getExtraFields($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle());
    +    $extra_fields = $this->entityFieldManager->getExtraFields($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle());
         return isset($extra_fields[$context]) ? $extra_fields[$context] : [];
    

    Here you correctly still use $this->entityFieldManager, but you removed that now. So that's going to fail. You need to inject both services for it to work.

  2. +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php
    @@ -57,17 +73,24 @@ class FieldStorageAddForm extends FormBase {
    +    if (!$this->entity_field_manager) {
    +      @trigger_error('\Drupal\Core\Entity\EntityFieldManagerInterface is a dependency of this class in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/2969109.', E_USER_DEPRECATED);
    +      $entity_field_manager = \Drupal::service('entity_field.manager');
    +    }
    +    $this->entityFieldManager = $entity_field_manager;
    

    This should check for $entity_field_manager, not $this->entity_field_manager because that will always be NULL at this point.

  3. +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php
    @@ -82,7 +105,7 @@ public function getFormId() {
         return new static(
    -      $container->get('entity.manager'),
    +      $container->get('entity_type.manager'),
           $container->get('plugin.manager.field.field_type'),
           $container->get('config.factory')
         );
    

    looks like you're not yet injecting the new entity_field.manager dependency, so that should result in a deprecation messages.

  4. +++ b/core/modules/node/src/Form/NodePreviewForm.php
    @@ -35,19 +44,22 @@ class NodePreviewForm extends FormBase {
        */
    -  public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory) {
    -    $this->entityManager = $entity_manager;
    +  public function __construct(EntityDisplayRepositoryInterface $entity_display_repository , ConfigFactoryInterface $config_factory) {
    +    $this->entityDisplayRepository = $entity_display_repository;
         $this->configFactory = $config_factory;
    

    This is perfectly fine, actually. The trick here is that EntityManagerInterface/$entity_manager also includes EntityDisplayRepositoryInterface, so if someone still passes in $entity_manager, that will not cause any issues, other than triggering some deprecation messages later on when we finally have @trigger_error()'s in all entity manager methods.

    This is the same as switching entityManager to entityTypeManager, which we also do in a few places.

  5. +++ b/core/modules/node/src/NodeTypeForm.php
    @@ -15,22 +17,44 @@
        */
    -  public function __construct(EntityManagerInterface $entity_manager) {
    -    $this->entityManager = $entity_manager;
    +  public function __construct(EntityTypeManagerInterface $entity_type_manager, $entity_field_manager = NULL) {
    +    $this->entityTypeManager = $entity_type_manager;
    +    if (!$this->entity_field_manager) {
    +      @trigger_error('\Drupal\Core\Entity\EntityFieldManagerInterface is a dependency of this class in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/2969109.', E_USER_DEPRECATED);
    +      $entity_field_manager = \Drupal::service('entity_field.manager');
    +    }
    +    $this->entityFieldManager = $entity_field_manager;
       }
    

    $this->entityTypeManager is already set 2 levels up on EntityForm and injected through setEntityTypeManager(), that means you can instead only pass in entity_field.manager as a replacement for entity_manager, like above.

  6. +++ b/core/modules/node/src/NodeTypeForm.php
    @@ -252,7 +276,7 @@ public function save(array $form, FormStateInterface $form_state) {
     
    -    $this->entityManager->clearCachedFieldDefinitions();
    +    $this->entityFieldManager->clearCachedFieldDefinitions();
         $form_state->setRedirectUrl($type->toUrl('collection'));
       }
    

    this is most likely unnecessary at this point, but we might not want to change that here.

  7. +++ b/core/modules/views_ui/src/Form/BreakLockForm.php
    @@ -32,13 +41,13 @@ class BreakLockForm extends EntityConfirmFormBase {
        */
    -  public function __construct(EntityManagerInterface $entity_manager, SharedTempStoreFactory $temp_store_factory) {
    -    $this->entityManager = $entity_manager;
    +  public function __construct(EntityTypeManagerInterface $entity_type_manager, SharedTempStoreFactory $temp_store_factory) {
    +    $this->entityTypeManager = $entity_type_manager;
         $this->tempStore = $temp_store_factory->get('views');
    

    this one is tricky. same as above, injecting entity type manager here is pointless because it has it already due to being an entity form.

    However, we don't need something else here and it is not the last argument, so removing the argument requires some pretty weird trickery.

    What you'd need to do is remove the argument and remove the type hint from $temp_store_factory, and if that is actaully not a SharedTEmpStorageFactory that means someone passed in an entity manager and we'd need to do a @trigger_error(). Maybe just leave it like this for now...

andypost’s picture

Assigned: martin107 » andypost

Better use https://www.drupal.org/node/2549139 as CR, working on it

andypost’s picture

StatusFileSize
new9.22 KB
new54.17 KB

First round of clean-up - address #27 1-3

andypost’s picture

StatusFileSize
new570 bytes
new54.21 KB

one more fix

martin107’s picture

@andypost ... thanks I was going to have to wait for the weekend

andypost’s picture

Assigned: andypost » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.82 KB

Fix core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayFormBaseTest.php

Feedback on remains of #27
4. NodePreviewForm marked internal so I think it's fine here
5. fixed
6. looks out of scope - needs follow-up
7. Removing type-hinting was unliked in other issues so I left it as is

looking through core for (7) I found only bad examples - they use type hint but checking for the same interface
- core/lib/Drupal/Core/Config/ConfigManager.php
- core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
- core/lib/Drupal/Core/ParamConverter/EntityConverter.php

andypost’s picture

patch itself

andypost’s picture

StatusFileSize
new54.84 KB

somehow patch is not attached again

Status: Needs review » Needs work

The last submitted patch, 34: 2969109-em-forms-33.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new4.7 KB
new59.54 KB

Fix last test

The last submitted patch, 34: 2969109-em-forms-33.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

andypost’s picture

Version: 8.7.x-dev » 8.8.x-dev
StatusFileSize
new2.76 KB
new59.49 KB

Fix cs

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/field_layout/src/Form/FieldLayoutEntityFormDisplayEditForm.php
    @@ -26,9 +28,13 @@ class FieldLayoutEntityFormDisplayEditForm extends EntityFormDisplayEditForm {
    +  public function __construct(FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager, LayoutPluginManagerInterface $layout_plugin_manager, EntityDisplayRepositoryInterface $entity_display_repository, EntityFieldManagerInterface $entity_field_manager) {
    

    the new arguments should use = NULL

  2. +++ b/core/modules/field_layout/src/Form/FieldLayoutEntityViewDisplayEditForm.php
    @@ -26,9 +28,13 @@ class FieldLayoutEntityViewDisplayEditForm extends EntityViewDisplayEditForm {
    +  public function __construct(FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager, LayoutPluginManagerInterface $layout_plugin_manager, EntityDisplayRepositoryInterface $entity_display_repository, EntityFieldManagerInterface $entity_field_manager) {
    

    same

  3. +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
    @@ -34,13 +36,27 @@
        */
       protected $fieldTypes;
    -
       /**
        * The entity being used by this form.
    

    that looks wrong.

  4. +++ b/core/modules/node/src/NodeTypeForm.php
    @@ -15,22 +16,34 @@
       /**
        * Constructs the NodeTypeForm object.
        *
    -   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    -   *   The entity manager.
    +   * @param \Drupal\Core\Entity\EntityFieldManagerInterface|null $entity_field_manager
    +   *   (optional) The entity field manager.
        */
    -  public function __construct(EntityManagerInterface $entity_manager) {
    -    $this->entityManager = $entity_manager;
    +  public function __construct(EntityFieldManagerInterface $entity_field_manager = NULL) {
    +    if (!$entity_field_manager) {
    +      @trigger_error('Calling NodeTypeForm::__construct() with the $entity_field_manager argument is supported in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    +      $entity_field_manager = \Drupal::service('entity_field.manager');
    +    }
    +    $this->entityFieldManager = $entity_field_manager;
    

    BC here shouldn't be necessary, as not a new argument.

  5. +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayFormBaseTest.php
    @@ -118,7 +118,12 @@ public function testCopyFormValuesToEntity() {
     
    -    $form_object = new EntityViewDisplayEditForm($this->container->get('plugin.manager.field.field_type'), $this->container->get('plugin.manager.field.formatter'));
    +    $form_object = new EntityViewDisplayEditForm(
    +      $this->container->get('plugin.manager.field.field_type'),
    +      $this->container->get('plugin.manager.field.formatter'),
    +      $this->container->get('entity_display.repository'),
    +      $this->container->get('entity_field.manager')
    +    );
         $form_object->setEntityManager($this->container->get('entity.manager'));
         $form_object->setEntity($entity->reveal());
     
    

    we should be able to remove the setEntityManager line below, one thing less to update then for 9.x

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new4.87 KB
new59.06 KB

Addressed #39 feedback

martin107’s picture

StatusFileSize
new2.92 KB
new58.98 KB

We are aiming from 8.8.0 now.

Contrib modules are going to get hit with @trigger warnings 6 months later that planned.

Such is the cruelty and glory of the periodic release window... Oh well

berdir’s picture

Status: Needs review » Reviewed & tested by the community

According to https://drupal.slack.com/archives/C1BMUQ9U6/p1551867778326000 and the reply from @alexpott, we might still be able to get this in with a deprecation message for 8.7, we're only talking about a bunch of constructors here, not a major new deprecation.

But we have no definitive feedback yet from a release manager. Either way, I think it is RTBC, either #40 or #41 can be committed. #40 to 8.7 + 8.8, #41 only to 8.8.

berdir’s picture

From slack https://drupal.slack.com/archives/CDDD98AMN/p1552125380214700:

catch: I would say beta is the cut off for deprecation messages targeting 8.7.

alexpott’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 2c166a50a6 to 8.8.x and 12af1077e5 to 8.7.x. Thanks!

  • alexpott committed 2c166a5 on 8.8.x
    Issue #2969109 by martin107, andypost, kaythay, Berdir: Replace...

Status: Fixed » Closed (fixed)

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