-
-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Lets add an extension to dynamically detect the return type for \Drupal\Core\Entity\EntityRepositoryInterface::loadEntityByUuid
We already have entityMapping
in phpstan.neon, I think the 'class' property from these can be safely reused for this purpose.
Presently doc is:
* @return \Drupal\Core\Entity\EntityInterface|null
* The entity object, or NULL if there is no entity with the given UUID.
*/
public function loadEntityByUuid($entity_type_id, $uuid);
We should be able to map the $entity_type_id
param to an item from entityMapping
, and dynamically return the class defined in class
property or NULL.
e.g
drupal:
entityMapping:
node:
class: Drupal\mymodule\Entity\Node\MyAbstractCustomNodeBase
storage: Drupal\node\NodeStorage
effectively, if $entity_type_id === 'node':
public function loadEntityByUuid($entity_type_id, $uuid): ?\Drupal\mymodule\Entity\Node\MyAbstractCustomNodeBase;
As a bonus feature, maybe theres a way to statically detect if entity type supports uuid, and add the mapping. Since an exception is thrown when the entity type ID does not support UUID's.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request