Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Munavijayalakshmi created an issue. See original summary.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
Status: Active » Needs review
FileSize
26.77 KB

Jaypan’s picture

Status: Needs review » Fixed

Nice work on this patch. Thanks!

almaudoh’s picture

This patch broke some things...

--- a/private_message.module
+++ b/private_message.module
@@ -32,7 +32,7 @@ function private_message_entity_extra_field_info() {
     'visible' => TRUE,
   ];
 
-  $user_bundles = \Drupal::entityManager()->getBundleInfo('user');
+  $user_bundles = \Drupal::entityTypeManager()->getBundleInfo('user');

::getBundleInfo('user') actually belongs in EntityTypeBundleInfo class, so this should be changed to \Drupal::service('entity_type.bundle.info')->getBundleInfo('user')

Also,

--- a/src/Form/PrivateMessageForm.php
+++ b/src/Form/PrivateMessageForm.php
@@ -7,8 +7,8 @@ use Drupal\Core\Ajax\ReplaceCommand;
 use Drupal\Component\Utility\Html;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Entity\ContentEntityForm;
-use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
+#use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Entity\Entity\EntityFormDisplay ;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Session\AccountProxyInterface;
@@ -76,7 +76,7 @@ class PrivateMessageForm extends ContentEntityForm {
   /**
    * Constructs a PrivateMessageForm object
    *
-   * @param \Drupal\Core\Entity\EntityManagerInterface $entityManager
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
    *   The entity manager service
    * @param \Drupal\Core\Session\AccountProxyInterface $currentUser
    *   The current user
@@ -91,8 +91,8 @@ class PrivateMessageForm extends ContentEntityForm {
    * @param \Drupal\private_message\Service\PrivateMessageServiceInterface $privateMessageService
    *   The private message service
    */
-  public function __construct(EntityManagerInterface $entityManager, AccountProxyInterface $currentUser, EntityTypeManagerInterface $entityTypeManager, TypedDataManagerInterface $typedDataManager, UserDataInterface $userData, ConfigFactoryInterface $configFactory, PrivateMessageServiceInterface $privateMessageService) {
-    parent::__construct($entityManager);
+  public function __construct(EntityTypeManagerInterface $entityTypeManager, AccountProxyInterface $currentUser, EntityTypeManagerInterface $entityTypeManager, TypedDataManagerInterface $typedDataManager, UserDataInterface $userData, ConfigFactoryInterface $configFactory, PrivateMessageServiceInterface $privateMessageService) {
+    parent::__construct($entityTypeManager);
 
     $this->currentUser = $currentUser;
     $this->entityTypeManager = $entityTypeManager;
@@ -107,7 +107,7 @@ class PrivateMessageForm extends ContentEntityForm {
    */
   public static function create(ContainerInterface $container) {
     return new static(
-      $container->get('entity.manager'),
+      $container->get('entity_type.manager'),

This should not be changed since the super class ContentEntityForm still uses an EntityManager object.

Jaypan’s picture

Status: Fixed » Needs work

@Munavijayalakshmi Do you want to provide a patch to fix that?

Jaypan’s picture

For the time being, I've reverted this patch. Hopefully Munavijayalakshmi will come along and pick it back up.

Jaypan’s picture

Status: Needs work » Needs review
FileSize
26.47 KB

I really dropped the ball with this, I should have checked the patch better before applying it. Munavijayalakshmi doesn't seem to be coming back, so I've created a new patch.

joshmiller’s picture

Note there is a related Drupal core issue:

#2894261: Deprecated service entity.manager needs to be replaced with entity_type.manager in ContentEntityForm

Related to the following comment:

This should not be changed since the super class ContentEntityForm still uses an EntityManager object.

joshmiller’s picture

Jaypan’s picture

@joshmiller - I've read through the issue you linked, am I correct in understanding that it's not possible to switch from entity manager to entity type manager at this point in time? Or does it just need some additional loving?

Also, I checked out your guys' booth at Drupalcon - I'm originally from Kamloops (out of the country 20 years though) so I thought I'd say hello to some people from my neck of the woods!

Jaypan’s picture

Status: Needs review » Postponed (maintainer needs more info)
joshmiller’s picture

Status: Postponed (maintainer needs more info) » Postponed

Hi Jaypan.

Yes, basically, it's postponed until Core makes a class that we can extend that isn't deprecated.

Jaypan’s picture

Thanks Josh.

phjou’s picture

It seems that the core issue has been fixed. Can we try to fix that issue again?

anmolgoyal74’s picture

Status: Postponed » Active

Since the core issue is fixed, We can move forward with this.

anmolgoyal74’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
ravi.shankar’s picture

Status: Active » Needs review
FileSize
5.49 KB

I have removed.

anmolgoyal74’s picture

Please also share the patch for 8.x-1.x-dev.

phjou’s picture

The current patch is not enough. When I check the code after applying the patch.

When I run grep -inr "entityManager" | wc -l , I have still 78 remaining references.

anmolgoyal74’s picture

Status: Needs review » Needs work

Yes, there are many more instances, where changes need to be done.

MeenakshiG’s picture

Assigned: Unassigned » MeenakshiG
MeenakshiG’s picture

Status: Needs work » Needs review
FileSize
33.33 KB
26.85 KB
MeenakshiG’s picture

Assigned: MeenakshiG » Unassigned

anmolgoyal74’s picture

anmolgoyal74’s picture

Status: Needs review » Fixed

  • anmolgoyal74 committed 151a65e on 8.x-2.x
    Revert "Issue #2873522 by Meenakshi.g, Jaypan, Munavijayalakshmi, ravi....
anmolgoyal74’s picture

Status: Fixed » Needs work

Reverted the last commit. There is some issue with the last patch.

MeenakshiG’s picture

Status: Needs work » Needs review
FileSize
34.39 KB
2.61 KB

Fixed the issue.

AkashKumar07’s picture

Status: Needs review » Needs work

In class private_message/src/Entity/Builder/PrivateMessageThreadViewBuilder.php
Please provide parent::__construct parameters in correct format.
Argument 2 to parent class expects EntityRepositoryInterface, instance of EntityTypeManager given.
Hope this will help.
Thanks

anmolgoyal74’s picture

Status: Needs work » Needs review
FileSize
35.73 KB
4.96 KB
AkashKumar07’s picture

Status: Needs review » Reviewed & tested by the community

I applied the patch and tested. It's working fine now. Thanks

  • anmolgoyal74 committed 2cbe81f on 8.x-2.x
    Issue #2873522 by Meenakshi.g, anmolgoyal74, Jaypan, Munavijayalakshmi,...
anmolgoyal74’s picture

anmolgoyal74’s picture

Status: Reviewed & tested by the community » Fixed

Fixed.
Feel free to re-open the issue if you face any issue.

zenimagine’s picture

Priority: Normal » Major
Status: Fixed » Needs work

Sorry to re-open this problem and the /admin/structure/private-message/private-message-thread/display page now displays :

The website encountered an unexpected error. Please try again later.

Type 	php
Date 	Vendredi, 13 décembre, 2019 - 10:18
Utilisateur 	administrateur
Emplacement 	https://dev.example.com/fr/admin/structure/private-message/private-message-thread/display
Référent 	
Message 	Error: Call to undefined method Drupal\Core\Entity\EntityTypeManager::getViewModes() in Drupal\private_message\Plugin\Field\FieldFormatter\PrivateMessageThreadMemberFormatter->settingsForm() (line 166 of /var/www/www-example-com/web/modules/contrib/private_message/src/Plugin/Field/FieldFormatter/PrivateMessageThreadMemberFormatter.php) #0 /var/www/www-example-com/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(455): Drupal\private_message\Plugin\Field\FieldFormatter\PrivateMessageThreadMemberFormatter->settingsForm(Array, Object(Drupal\Core\Form\FormState)) #1 /var/www/www-example-com/web/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php(40): Drupal\field_ui\Form\EntityDisplayFormBase->buildFieldRow(Object(Drupal\Core\Field\BaseFieldDefinition), Array, Object(Drupal\Core\Form\FormState)) #2 /var/www/www-example-com/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(218): Drupal\field_ui\Form\EntityViewDisplayEditForm->buildFieldRow(Object(Drupal\Core\Field\BaseFieldDefinition), Array, Object(Drupal\Core\Form\FormState)) #3 /var/www/www-example-com/web/core/lib/Drupal/Core/Entity/EntityForm.php(144): Drupal\field_ui\Form\EntityDisplayFormBase->form(Array, Object(Drupal\Core\Form\FormState)) #4 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState)) #5 /var/www/www-example-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(520): call_user_func_array(Array, Array) #6 /var/www/www-example-com/web/core/lib/Drupal/Core/Form/FormBuilder.php(277): Drupal\Core\Form\FormBuilder->retrieveForm('entity_view_dis...', Object(Drupal\Core\Form\FormState)) #7 /var/www/www-example-com/web/core/lib/Drupal/Core/Controller/FormController.php(91): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\field_ui\Form\EntityViewDisplayEditForm), Object(Drupal\Core\Form\FormState)) #8 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #9 /var/www/www-example-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #10 /var/www/www-example-com/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #11 /var/www/www-example-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #12 /var/www/www-example-com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #13 /var/www/www-example-com/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #14 /var/www/www-example-com/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #15 /var/www/www-example-com/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /var/www/www-example-com/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /var/www/www-example-com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /var/www/www-example-com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/www-example-com/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/www-example-com/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/www-example-com/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/www-example-com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/www-example-com/web/core/lib/Drupal/Core/DrupalKernel.php(694): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/www-example-com/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #25 {main}.
Severity 	Erreur
anmolgoyal74’s picture

Assigned: Unassigned » anmolgoyal74

Thanks for pointing out the error.
I will fix the error.

  • anmolgoyal74 committed a40e51b on 8.x-2.x
    Issue #2873522 by Meenakshi.g, anmolgoyal74, Jaypan, Munavijayalakshmi,...
anmolgoyal74’s picture

Status: Needs work » Needs review
zenimagine’s picture

Thanks it works

anmolgoyal74’s picture

Status: Needs review » Fixed
anmolgoyal74’s picture

Status: Fixed » Closed (fixed)

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