class MenuLinks in Event 8
Provides a default implementation for menu link plugins.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface- class \Drupal\event\Plugin\Derivative\MenuLinks implements ContainerDeriverInterface uses StringTranslationTrait
 
Expanded class hierarchy of MenuLinks
1 string reference to 'MenuLinks'
File
- src/Plugin/ Derivative/ MenuLinks.php, line 17 
Namespace
Drupal\event\Plugin\DerivativeView source
class MenuLinks extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;
  const MAX_BUNDLE_NUMBER = 10;
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;
  /**
   * The route provider.
   *
   * @var \Drupal\Core\Routing\RouteProviderInterface
   */
  protected $routeProvider;
  /**
   * The theme handler.
   *
   * @var \Drupal\Core\Extension\ThemeHandlerInterface
   */
  protected $themeHandler;
  /**
   * {@inheritdoc}
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler) {
    $this->entityTypeManager = $entity_type_manager;
    $this->moduleHandler = $module_handler;
    $this->routeProvider = $route_provider;
    $this->themeHandler = $theme_handler;
  }
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('entity_type.manager'), $container
      ->get('module_handler'), $container
      ->get('router.route_provider'), $container
      ->get('theme_handler'));
  }
  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $links = [];
    // If module event enabled.
    if ($this->moduleHandler
      ->moduleExists('admin_toolbar')) {
      $links['event.type_add'] = [
        'title' => $this
          ->t('Add event type'),
        'route_name' => 'entity.event_type.add_form',
        'parent' => 'entity.event_type.collection',
        'weight' => -2,
      ] + $base_plugin_definition;
      // Displays event link in toolbar.
      $links['event_page'] = [
        'title' => $this
          ->t('Events'),
        'route_name' => 'entity.event.collection',
        'parent' => 'system.admin_content',
      ] + $base_plugin_definition;
      $links['add_event'] = [
        'title' => $this
          ->t('Add event'),
        'route_name' => 'entity.event.add_page',
        'parent' => $base_plugin_definition['id'] . ':event_page',
      ] + $base_plugin_definition;
      // Adds links for each event type.
      foreach ($this->entityTypeManager
        ->getStorage('event_type')
        ->loadMultiple() as $type) {
        $links['event.add.' . $type
          ->id()] = [
          'title' => $type
            ->label(),
          'route_name' => 'entity.event.add_form',
          'parent' => $base_plugin_definition['id'] . ':add_event',
          'route_parameters' => [
            'event_type' => $type
              ->id(),
          ],
        ] + $base_plugin_definition;
      }
    }
    return $links;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| DeriverBase:: | protected | property | List of derivative definitions. | 1 | 
| DeriverBase:: | public | function | Gets the definition of a derivative plugin. Overrides DeriverInterface:: | |
| MenuLinks:: | protected | property | The entity type manager. | |
| MenuLinks:: | protected | property | The module handler. | |
| MenuLinks:: | protected | property | The route provider. | |
| MenuLinks:: | protected | property | The theme handler. | |
| MenuLinks:: | public static | function | Creates a new class instance. Overrides ContainerDeriverInterface:: | |
| MenuLinks:: | public | function | Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: | |
| MenuLinks:: | constant | |||
| MenuLinks:: | public | function | ||
| StringTranslationTrait:: | protected | property | The string translation service. | 1 | 
| StringTranslationTrait:: | protected | function | Formats a string containing a count of items. | |
| StringTranslationTrait:: | protected | function | Returns the number of plurals supported by a given language. | |
| StringTranslationTrait:: | protected | function | Gets the string translation service. | |
| StringTranslationTrait:: | public | function | Sets the string translation service to use. | 2 | 
| StringTranslationTrait:: | protected | function | Translates a string to the current language or to a given language. | 
