class LayoutBuilderLocalTaskDeriver

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Plugin/Derivative/LayoutBuilderLocalTaskDeriver.php \Drupal\layout_builder\Plugin\Derivative\LayoutBuilderLocalTaskDeriver
  2. 10 core/modules/layout_builder/src/Plugin/Derivative/LayoutBuilderLocalTaskDeriver.php \Drupal\layout_builder\Plugin\Derivative\LayoutBuilderLocalTaskDeriver
  3. 11.x core/modules/layout_builder/src/Plugin/Derivative/LayoutBuilderLocalTaskDeriver.php \Drupal\layout_builder\Plugin\Derivative\LayoutBuilderLocalTaskDeriver

Provides local task definitions for the layout builder user interface.

@todo Remove this in https://www.drupal.org/project/drupal/issues/2936655.

@internal Plugin derivers are internal.

Hierarchy

Expanded class hierarchy of LayoutBuilderLocalTaskDeriver

1 string reference to 'LayoutBuilderLocalTaskDeriver'
layout_builder.links.task.yml in core/modules/layout_builder/layout_builder.links.task.yml
core/modules/layout_builder/layout_builder.links.task.yml

File

core/modules/layout_builder/src/Plugin/Derivative/LayoutBuilderLocalTaskDeriver.php, line 21

Namespace

Drupal\layout_builder\Plugin\Derivative
View source
class LayoutBuilderLocalTaskDeriver extends DeriverBase implements ContainerDeriverInterface {
    use StringTranslationTrait;
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * The section storage manager.
     *
     * @var \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface
     */
    protected $sectionStorageManager;
    
    /**
     * Constructs a new LayoutBuilderLocalTaskDeriver.
     *
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     * @param \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager
     *   The section storage manager.
     */
    public function __construct(EntityTypeManagerInterface $entity_type_manager, SectionStorageManagerInterface $section_storage_manager) {
        $this->entityTypeManager = $entity_type_manager;
        $this->sectionStorageManager = $section_storage_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($container->get('entity_type.manager'), $container->get('plugin.manager.layout_builder.section_storage'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        foreach ($this->sectionStorageManager
            ->getDefinitions() as $plugin_id => $definition) {
            $section_storage = $this->sectionStorageManager
                ->loadEmpty($plugin_id);
            if ($section_storage instanceof SectionStorageLocalTaskProviderInterface) {
                $this->derivatives += $section_storage->buildLocalTasks($base_plugin_definition);
            }
        }
        return $this->derivatives;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
LayoutBuilderLocalTaskDeriver::$entityTypeManager protected property The entity type manager.
LayoutBuilderLocalTaskDeriver::$sectionStorageManager protected property The section storage manager.
LayoutBuilderLocalTaskDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
LayoutBuilderLocalTaskDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
LayoutBuilderLocalTaskDeriver::__construct public function Constructs a new LayoutBuilderLocalTaskDeriver.
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.