class DevelLocalTask

Same name in other branches
  1. 4.x src/Plugin/Derivative/DevelLocalTask.php \Drupal\devel\Plugin\Derivative\DevelLocalTask

Provides local task definitions for all entity bundles.

Hierarchy

Expanded class hierarchy of DevelLocalTask

See also

\Drupal\devel\Controller\EntityDebugController

\Drupal\devel\Routing\RouteSubscriber

1 string reference to 'DevelLocalTask'
devel.links.task.yml in ./devel.links.task.yml
devel.links.task.yml

File

src/Plugin/Derivative/DevelLocalTask.php, line 17

Namespace

Drupal\devel\Plugin\Derivative
View source
class DevelLocalTask extends DeriverBase implements ContainerDeriverInterface {
    use StringTranslationTrait;
    
    /**
     * The entity manager.
     */
    protected EntityTypeManagerInterface $entityTypeManager;
    public final function __construct() {
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) : static {
        $instance = new static();
        $instance->entityTypeManager = $container->get('entity_type.manager');
        $instance->stringTranslation = $container->get('string_translation');
        return $instance;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        $this->derivatives = [];
        foreach ($this->entityTypeManager
            ->getDefinitions() as $entity_type_id => $entity_type) {
            $has_edit_path = $entity_type->hasLinkTemplate('edit-form');
            $has_canonical_path = $entity_type->hasLinkTemplate('devel-render');
            if ($has_edit_path || $has_canonical_path) {
                $this->derivatives[$entity_type_id . '.devel_tab'] = [
                    'route_name' => sprintf('entity.%s.', $entity_type_id) . ($has_edit_path ? 'devel_load' : 'devel_render'),
                    'title' => $this->t('Devel'),
                    'base_route' => sprintf('entity.%s.', $entity_type_id) . ($has_canonical_path ? "canonical" : "edit_form"),
                    'weight' => 100,
                ];
                $this->derivatives[$entity_type_id . '.devel_definition_tab'] = [
                    'route_name' => sprintf('entity.%s.devel_definition', $entity_type_id),
                    'title' => $this->t('Definition'),
                    'parent_id' => sprintf('devel.entities:%s.devel_tab', $entity_type_id),
                    'weight' => 100,
                ];
                $this->derivatives[$entity_type_id . 'devel_path_alias_tab'] = [
                    'route_name' => sprintf('entity.%s.devel_path_alias', $entity_type_id),
                    'title' => $this->t('Path alias'),
                    'parent_id' => sprintf('devel.entities:%s.devel_tab', $entity_type_id),
                    'weight' => 100,
                ];
                if ($has_canonical_path) {
                    $this->derivatives[$entity_type_id . '.devel_render_tab'] = [
                        'route_name' => sprintf('entity.%s.devel_render', $entity_type_id),
                        'weight' => 100,
                        'title' => $this->t('Render'),
                        'parent_id' => sprintf('devel.entities:%s.devel_tab', $entity_type_id),
                    ];
                }
                if ($has_edit_path) {
                    $this->derivatives[$entity_type_id . '.devel_load_tab'] = [
                        'route_name' => sprintf('entity.%s.devel_load', $entity_type_id),
                        'weight' => 100,
                        'title' => $this->t('Load'),
                        'parent_id' => sprintf('devel.entities:%s.devel_tab', $entity_type_id),
                    ];
                    $this->derivatives[$entity_type_id . '.devel_load_with_references_tab'] = [
                        'route_name' => sprintf('entity.%s.devel_load_with_references', $entity_type_id),
                        'weight' => 100,
                        'title' => $this->t('Load (with references)'),
                        'parent_id' => sprintf('devel.entities:%s.devel_tab', $entity_type_id),
                    ];
                }
            }
        }
        foreach ($this->derivatives as &$entry) {
            $entry += $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
DevelLocalTask::$entityTypeManager protected property The entity manager.
DevelLocalTask::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
DevelLocalTask::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
DevelLocalTask::__construct final public function
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.