Seeking assistance with deprecated getContentEntities() method in Group module

Created on 29 May 2023, almost 2 years ago
Updated 30 May 2023, almost 2 years ago

Problem/Motivation

I'm facing an issue while upgrading the Group module from version 1.5 in Drupal 9 to version 3.0 in Drupal 10. After resolving several errors during the upgrade process, I'm now stuck with the following problem.

Previously, I was using the getContentEntities() method in my code like this:

$group->getContentEntities(NULL, ['type' => 'account-group_node-ship_to']);

However, after upgrading to Group 3.0, I encountered the following error:

Error: Call to undefined method Drupal\group\Entity\Group::getContentEntities() in Drupal\accounts\Service\Customer\AccountProvider->getShipsToIdsById() (line 374 of modules/custom/accounts/src/Service/Customer/AccountProvider.php).

It appears that the getContentEntities() method no longer exists in the new release.

After reviewing the change records documentation , I discovered that the Group module's getContentEntities() method has been replaced with getRelatedEntities() in Group module 3.0, which serves as an equivalent function :

$group->getRelatedEntities($plugin_id);

In my previous implementation, I utilized the getContentEntities() method with two parameters. The first parameter was set to NULL, and the second parameter was an array ['type' => 'account-group_node-ship_to']

By calling the getRelatedEntities() method on the group object and passing the $plugin_id, which in your case is 'group_node-ship_to', the new implementation will be :

 $relatedEntities = $group->getRelatedEntities('group_node:ship_to');

knowing that the plugin_id stored in the table group_relashion_field_data is 'group_node:ship_to'

After dumping the result of $relatedEntities , The returned array is empty, despite the existence of the related entity.
Any suggestions or guidance on how to handle this situation would be greatly appreciated. Thank you in advance for your support!

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

3.0

Component

Code

Created by

🇲🇦Morocco youssef.maaddi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024