You are here

class EntityDecorator in Commerce AutoSKU 8.2

Provides an content entity decorator for automatic label generation.

Hierarchy

Expanded class hierarchy of EntityDecorator

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

File

src/EntityDecorator.php, line 16
Contains \Drupal\commerce_autosku\EntityDecorator.

Namespace

Drupal\commerce_autosku
View source
class EntityDecorator implements EntityDecoratorInterface {

  /**
   * The content entity that is decorated.
   *
   * @var ContentEntityInterface
   */
  protected $entity;

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

  /**
   * The generator manager.
   *
   * @var \Drupal\commerce_autosku\CommerceAutoSkuGeneratorManagerInterface
   */
  protected $generatorManager;

  /**
   * Constructs an EntityDecorator object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   Entity type manager
   * @param \Drupal\commerce_autosku\CommerceAutoSkuGeneratorManagerInterface $generator_manager
   *   The generator manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager, CommerceAutoSkuGeneratorManagerInterface $generator_manager) {
    $this->entityTypeManager = $entity_type_manager;
    $this->generatorManager = $generator_manager;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDecorator::$entity protected property The content entity that is decorated.
EntityDecorator::$entityTypeManager protected property The entity type manager.
EntityDecorator::$generatorManager protected property The generator manager.
EntityDecorator::decorate public function Automatic entity label entity decorator. Overrides EntityDecoratorInterface::decorate
EntityDecorator::__construct public function Constructs an EntityDecorator object.