You are here

class EntityDecorator in Automatic Entity Label 8

Same name and namespace in other branches
  1. 8.3 src/EntityDecorator.php \Drupal\auto_entitylabel\EntityDecorator
  2. 8.2 src/EntityDecorator.php \Drupal\auto_entitylabel\EntityDecorator

Provides an content entity decorator for automatic label generation.

Hierarchy

Expanded class hierarchy of EntityDecorator

1 string reference to 'EntityDecorator'
auto_entitylabel.services.yml in ./auto_entitylabel.services.yml
auto_entitylabel.services.yml
1 service uses EntityDecorator
auto_entitylabel.entity_decorator in ./auto_entitylabel.services.yml
Drupal\auto_entitylabel\EntityDecorator

File

src/EntityDecorator.php, line 13

Namespace

Drupal\auto_entitylabel
View source
class EntityDecorator implements EntityDecoratorInterface {

  /**
   * The content entity that is decorated.
   *
   * @var \Drupal\Core\Entity\ContentEntityInterface
   */
  protected $entity;

  /**
   * Config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManager
   */
  protected $entityTypeManager;

  /**
   * Token service.
   *
   * @var \Drupal\Core\Utility\Token
   */
  protected $token;

  /**
   * Automatic label configuration for the entity.
   *
   * @var array
   */
  protected $config;

  /**
   * Constructs an EntityDecorator object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   Configuration factory.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   Entity type manager.
   * @param \Drupal\Core\Utility\Token $token
   *   Token manager.
   */
  public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, Token $token) {
    $this->configFactory = $config_factory;
    $this->entityTypeManager = $entity_type_manager;
    $this->token = $token;
  }

  /**
   * {@inheritdoc}
   */
  public function decorate(ContentEntityInterface $entity) {
    $this->entity = new AutoEntityLabelManager($entity, $this->configFactory, $this->entityTypeManager, $this->token);
    return $this->entity;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDecorator::$config protected property Automatic label configuration for the entity.
EntityDecorator::$configFactory protected property Config factory.
EntityDecorator::$entity protected property The content entity that is decorated.
EntityDecorator::$entityTypeManager protected property The entity type manager.
EntityDecorator::$token protected property Token service.
EntityDecorator::decorate public function Automatic entity label entity decorator. Overrides EntityDecoratorInterface::decorate
EntityDecorator::__construct public function Constructs an EntityDecorator object.