You are here

class TotalControlMenuLink in Total Control Admin Dashboard 3.0.x

Same name in this branch
  1. 3.0.x src/Plugin/Derivative/TotalControlMenuLink.php \Drupal\total_control\Plugin\Derivative\TotalControlMenuLink
  2. 3.0.x src/Plugin/Menu/TotalControlMenuLink.php \Drupal\total_control\Plugin\Menu\TotalControlMenuLink
Same name and namespace in other branches
  1. 8.2 src/Plugin/Derivative/TotalControlMenuLink.php \Drupal\total_control\Plugin\Derivative\TotalControlMenuLink

Represents a menu link for a Total Control Menu Link.

Hierarchy

Expanded class hierarchy of TotalControlMenuLink

1 string reference to 'TotalControlMenuLink'
total_control.links.menu.yml in ./total_control.links.menu.yml
total_control.links.menu.yml

File

src/Plugin/Derivative/TotalControlMenuLink.php, line 15

Namespace

Drupal\total_control\Plugin\Derivative
View source
class TotalControlMenuLink extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Creates a Total Control Menu Link instance.
   *
   * @param string $base_plugin_id
   *   Base plugin id.
   * @param Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   Entity type manager.
   * @param Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The string translation service.
   */
  public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
    $this->entityTypeManager = $entity_type_manager;
    $this
      ->setStringTranslation($string_translation);
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($base_plugin_id, $container
      ->get('entity_type.manager'), $container
      ->get('string_translation'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $router = \Drupal::service('router.route_provider');
    if (!empty($router
      ->getRoutesByNames([
      'page_manager.page_view_total_control_dashboard_total_control_dashboard-http_status_code-0',
    ]))) {
      $links['system.total_control_dashboard'] = [
        'title' => $this
          ->t('Dashboard'),
        'route_name' => 'page_manager.page_view_total_control_dashboard_total_control_dashboard-http_status_code-0',
        'parent' => 'system.admin',
        'weight' => '-20',
      ] + $base_plugin_definition;
      return $links;
    }
    return [];
  }

}

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
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
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.
TotalControlMenuLink::$entityTypeManager protected property The entity type manager.
TotalControlMenuLink::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
TotalControlMenuLink::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
TotalControlMenuLink::__construct public function Creates a Total Control Menu Link instance.