You are here

class EntityCloneServiceProvider in Entity Clone 8

Service Provider Class.

Hierarchy

Expanded class hierarchy of EntityCloneServiceProvider

2 files declare their use of EntityCloneServiceProvider
EntityCloneForm.php in src/Form/EntityCloneForm.php
EntityClonePermissions.php in src/EntityClonePermissions.php
1 string reference to 'EntityCloneServiceProvider'
entity_clone.services.yml in ./entity_clone.services.yml
entity_clone.services.yml
1 service uses EntityCloneServiceProvider
entity_clone.service_provider in ./entity_clone.services.yml
Drupal\entity_clone\Services\EntityCloneServiceProvider

File

src/Services/EntityCloneServiceProvider.php, line 11

Namespace

Drupal\entity_clone\Services
View source
class EntityCloneServiceProvider {

  /**
   * Constructs a new ServiceProvider object.
   */
  public function __construct() {
  }

  /**
   * Checks if the given entity implements has owner trait.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity
   *   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()));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityCloneServiceProvider::entityTypeHasOwnerTrait public function Checks if the given entity implements has owner trait.
EntityCloneServiceProvider::__construct public function Constructs a new ServiceProvider object.