public function EntityCloneServiceProvider::entityTypeHasOwnerTrait in Entity Clone 8
Checks if the given entity implements has owner trait.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity: Entity to be tested.
Return value
bool Returns boolean for the owner trait test.
File
- src/
Services/ EntityCloneServiceProvider.php, line 27
Class
- EntityCloneServiceProvider
- Service Provider Class.
Namespace
Drupal\entity_clone\ServicesCode
public function entityTypeHasOwnerTrait(EntityTypeInterface $entityType) {
try {
$reflectionClass = new \ReflectionClass($entityType
->getOriginalClass());
} catch (\ReflectionException $e) {
return FALSE;
}
return in_array(EntityOwnerTrait::class, array_keys($reflectionClass
->getTraits()));
}