Same filename in other branches
Namespace
Drupal\entity_clone\ServicesFile
-
src/
Services/ EntityCloneServiceProvider.php
View source
<?php
namespace Drupal\entity_clone\Services;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\EntityOwnerTrait;
/**
* Service Provider Class.
*/
class EntityCloneServiceProvider {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeInterface
*/
protected $entityType;
/**
* Constructs a new ServiceProvider object.
*/
public function __construct() {
}
/**
* Checks if the given entity implements has owner trait.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entityType
* Entity to be tested.
*
* @return bool
* Returns boolean for the owner trait test.
*/
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()));
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
EntityCloneServiceProvider | Service Provider Class. |