class DynamicLocalTasks

Same name in this branch
  1. 10 core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks
Same name in other branches
  1. 9 core/modules/media/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\media\Plugin\Derivative\DynamicLocalTasks
  2. 9 core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks
  3. 8.9.x core/modules/media/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\media\Plugin\Derivative\DynamicLocalTasks
  4. 8.9.x core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks
  5. 11.x core/modules/media/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\media\Plugin\Derivative\DynamicLocalTasks
  6. 11.x core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks

Generates media-related local tasks.

Hierarchy

Expanded class hierarchy of DynamicLocalTasks

1 string reference to 'DynamicLocalTasks'
media.links.task.yml in core/modules/media/media.links.task.yml
core/modules/media/media.links.task.yml

File

core/modules/media/src/Plugin/Derivative/DynamicLocalTasks.php, line 16

Namespace

Drupal\media\Plugin\Derivative
View source
class DynamicLocalTasks extends DeriverBase implements ContainerDeriverInterface {
    use StringTranslationTrait;
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * The media settings config.
     *
     * @var \Drupal\Core\Config\ImmutableConfig
     */
    protected $config;
    
    /**
     * Creates a DynamicLocalTasks object.
     *
     * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
     *   The translation manager.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
     *   The config factory.
     */
    public function __construct(TranslationInterface $string_translation, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory) {
        $this->stringTranslation = $string_translation;
        $this->entityTypeManager = $entity_type_manager;
        $this->config = $config_factory->get('media.settings');
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($container->get('string_translation'), $container->get('entity_type.manager'), $container->get('config.factory'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        // Provide an edit_form task if standalone media URLs are enabled.
        $this->derivatives["entity.media.canonical"] = [
            'route_name' => "entity.media.canonical",
            'title' => $this->t('Edit'),
            'base_route' => "entity.media.canonical",
            'weight' => 1,
        ] + $base_plugin_definition;
        if ($this->config
            ->get('standalone_url')) {
            $this->derivatives["entity.media.canonical"]['title'] = $this->t('View');
            $this->derivatives["entity.media.edit_form"] = [
                'route_name' => "entity.media.edit_form",
                'title' => $this->t('Edit'),
                'base_route' => 'entity.media.canonical',
                'weight' => 2,
            ] + $base_plugin_definition;
        }
        $this->derivatives["entity.media.delete_form"] = [
            'route_name' => "entity.media.delete_form",
            'title' => $this->t('Delete'),
            'base_route' => "entity.media.canonical",
            'weight' => 10,
        ] + $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
DynamicLocalTasks::$config protected property The media settings config.
DynamicLocalTasks::$entityTypeManager protected property The entity type manager.
DynamicLocalTasks::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
DynamicLocalTasks::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
DynamicLocalTasks::__construct public function Creates a DynamicLocalTasks object.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
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.