You are here

class MenuLinksTask in Entity Extra Field 8

Same name and namespace in other branches
  1. 2.0.x modules/entity_extra_field_ui/src/Plugin/Derivative/MenuLinksTask.php \Drupal\entity_extra_field_ui\Plugin\Derivative\MenuLinksTask

Define menu links task derivative.

Hierarchy

Expanded class hierarchy of MenuLinksTask

1 string reference to 'MenuLinksTask'
entity_extra_field_ui.links.task.yml in modules/entity_extra_field_ui/entity_extra_field_ui.links.task.yml
modules/entity_extra_field_ui/entity_extra_field_ui.links.task.yml

File

modules/entity_extra_field_ui/src/Plugin/Derivative/MenuLinksTask.php, line 14

Namespace

Drupal\entity_extra_field_ui\Plugin\Derivative
View source
class MenuLinksTask extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

  /**
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Menu links task constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_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) {
    $links = parent::getDerivativeDefinitions($base_plugin_definition);
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type_id => $definition) {
      $base_route_name = $definition
        ->get('field_ui_base_route');
      if (!isset($base_route_name)) {
        continue;
      }
      $links["{$entity_type_id}.extra_fields"] = [
        'title' => $this
          ->t('Manage extra fields'),
        'route_name' => "entity.{$entity_type_id}.extra_fields",
        'weight' => 2,
        'base_route' => $base_route_name,
      ] + $base_plugin_definition;
    }
    return $links;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
MenuLinksTask::$entityTypeManager protected property
MenuLinksTask::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
MenuLinksTask::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
MenuLinksTask::__construct public function Menu links task constructor.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.