Comments

ravi.shankar created an issue. See original summary.

ravi.shankar’s picture

Status: Active » Needs review
StatusFileSize
new899 bytes

I have removed.

pratik_kamble’s picture

Status: Needs review » Reviewed & tested by the community

Patch LGTM.

berdir’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Drupal 9 readiness

There are a lot more remaining entity.manager usages:

$ grep -R "entity.manager" .
./src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php:    $entity_manager = \Drupal::entityTypeManager();
./src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php:      $entity_type = $entity_manager->getDefinition($target_type);
./src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php:      $paragraphs_entity = $entity_manager->getStorage($target_type)->create(array(
./src/Plugin/migrate/source/DrupalSqlBase.php:  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_manager) {
./src/Plugin/migrate/source/DrupalSqlBase.php:    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
./src/Plugin/migrate/source/d7/FieldableEntity.php:  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_manager) {
./src/Plugin/migrate/source/d7/FieldableEntity.php:    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
./src/Plugin/EntityReferenceSelection/ParagraphSelection.php:   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
./src/Plugin/EntityReferenceSelection/ParagraphSelection.php:   *   The entity manager service.
./src/Plugin/EntityReferenceSelection/ParagraphSelection.php:  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
./src/Plugin/EntityReferenceSelection/ParagraphSelection.php:    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user);
./src/Plugin/EntityReferenceSelection/ParagraphSelection.php:      $container->get('entity.manager'),
./src/Feeds/Target/Paragraphs.php: *   arguments = {"@entity.manager", "@current_user"}
./modules/paragraphs_library/src/Form/LibraryItemForm.php:   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
./modules/paragraphs_library/src/Form/LibraryItemForm.php:   *   The entity manager.
./modules/paragraphs_library/src/Form/LibraryItemForm.php:  public function __construct(EntityManagerInterface $entity_manager, MessengerInterface $messenger, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
./modules/paragraphs_library/src/Form/LibraryItemForm.php:    parent::__construct($entity_manager, $entity_type_bundle_info, $time);
./modules/paragraphs_library/src/Form/LibraryItemForm.php:      $container->get('entity.manager'),
./modules/paragraphs_library/paragraphs_library.install:  \Drupal::service('entity.manager')->clearCachedDefinitions();
pratik_kamble’s picture

Assigned: Unassigned » pratik_kamble
pratik_kamble’s picture

Starting work on it.

ravi.shankar’s picture

Ok @pratik_kamble

berdir’s picture

@pratik_kamble, are you still working on this? If you're stuck then I'd suggest you post what you have and unassign, so that someone else can pick it up.

pratik_kamble’s picture

@Berdir yes I am still working. I will post the patch by tomorrow.

pratik_kamble’s picture

Status: Needs work » Needs review
StatusFileSize
new10.7 KB

Please find the attached patch to remove the use of the EntityManagerInterface.

ravi.shankar’s picture

Status: Needs review » Needs work

The above patch has failed in some tests so back to needs work.

berdir’s picture

  1. +++ b/modules/paragraphs_library/src/Form/LibraryItemForm.php
    @@ -39,8 +39,8 @@ class LibraryItemForm extends ContentEntityForm {
        */
    -  public function __construct(EntityManagerInterface $entity_manager, MessengerInterface $messenger, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
    -    parent::__construct($entity_manager, $entity_type_bundle_info, $time);
    +  public function __construct(EntityTypeManagerInterface $entity_type_manager, MessengerInterface $messenger, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
    +    parent::__construct($entity_type_manager, $entity_type_bundle_info, $time);
         $this->messenger = $messenger;
       }
     
    @@ -62,7 +62,7 @@ class LibraryItemForm extends ContentEntityForm {
    
    @@ -62,7 +62,7 @@ class LibraryItemForm extends ContentEntityForm {
        */
       public static function create(ContainerInterface $container) {
         return new static(
    -      $container->get('entity.manager'),
    +      $container->get('entity_type.manager'),
           $container->get('messenger'),
    

    You need to check what service the parent needs.

    Alternatively, we could use the new pattern that doesn't require a constructor, see https://www.previousnext.com.au/blog/safely-extending-drupal-8-plugin-cl...

  2. +++ b/src/Plugin/EntityReferenceSelection/ParagraphSelection.php
    @@ -50,8 +50,8 @@ class ParagraphSelection extends DefaultSelection {
        *   Entity type bundle info service.
        */
    -  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
    -    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user);
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
    +    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $module_handler, $current_user);
     
         $this->entityTypeBundleInfo = $entity_type_bundle_info;
       }
    

    we can remove the constructor here completely because the parent now has entityTYpeBundleInfo.

berdir’s picture

Assigned: pratik_kamble » berdir

I'll have a look at this, this has some tricky parts.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new10.78 KB
new4.06 KB

Lets see about this.

  • Berdir committed 19e82d3 on 8.x-1.x
    Issue #3083331 by Berdir, pratik_kamble, ravi.shankar: Removing...
berdir’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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