You are here

class CommerceAutoSkuConfigTask in Commerce AutoSKU 8.2

Hierarchy

Expanded class hierarchy of CommerceAutoSkuConfigTask

1 string reference to 'CommerceAutoSkuConfigTask'
commerce_autosku.links.task.yml in ./commerce_autosku.links.task.yml
commerce_autosku.links.task.yml

File

src/Plugin/Derivative/CommerceAutoSkuConfigTask.php, line 10

Namespace

Drupal\commerce_autosku\Plugin\Derivative
View source
class CommerceAutoSkuConfigTask extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The entity manager
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityManager;

  /**
   * Creates an FieldUiLocalTask object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
   *   The entity manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_manager) {
    $this->entityManager = $entity_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('entity_type.manager'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = array();
    foreach ($this->entityManager
      ->getDefinitions() as $entity_type_id => $entity_type) {
      if (!$entity_type
        ->hasLinkTemplate('auto-sku')) {
        continue;
      }
      $this->derivatives["{$entity_type_id}.auto_sku_tab"] = array(
        'route_name' => "entity.{$entity_type_id}.auto_sku",
        'title' => 'Automatic SKU',
        'base_route' => "entity.{$entity_type_id}.edit_form",
        'weight' => 100,
      );
    }
    foreach ($this->derivatives as &$entry) {
      $entry += $base_plugin_definition;
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommerceAutoSkuConfigTask::$entityManager protected property The entity manager
CommerceAutoSkuConfigTask::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
CommerceAutoSkuConfigTask::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
CommerceAutoSkuConfigTask::__construct public function Creates an FieldUiLocalTask object.
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition