You are here

class DynamicLocalTasks in Thunder 8.2

Same name and namespace in other branches
  1. 8.5 modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\thunder_article\Plugin\Derivative\DynamicLocalTasks
  2. 8.3 modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\thunder_article\Plugin\Derivative\DynamicLocalTasks
  3. 8.4 modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\thunder_article\Plugin\Derivative\DynamicLocalTasks
  4. 6.2.x modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\thunder_article\Plugin\Derivative\DynamicLocalTasks
  5. 6.0.x modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\thunder_article\Plugin\Derivative\DynamicLocalTasks
  6. 6.1.x modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\thunder_article\Plugin\Derivative\DynamicLocalTasks

Generates content view local tasks.

Hierarchy

Expanded class hierarchy of DynamicLocalTasks

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

File

modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php, line 17

Namespace

Drupal\thunder_article\Plugin\Derivative
View source
class DynamicLocalTasks extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

  /**
   * The module handler service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * The route provider service.
   *
   * @var \Drupal\Core\Routing\RouteProviderInterface
   */
  protected $routeProvider;

  /**
   * The config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Creates an DynamicLocalTasks object.
   *
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The translation manager.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler service.
   * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
   *   The route provider service.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory service.
   */
  public function __construct(TranslationInterface $string_translation, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ConfigFactoryInterface $config_factory) {
    $this->stringTranslation = $string_translation;
    $this->moduleHandler = $module_handler;
    $this->routeProvider = $route_provider;
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('string_translation'), $container
      ->get('module_handler'), $container
      ->get('router.route_provider'), $container
      ->get('config.factory'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    if ($this->moduleHandler
      ->moduleExists('content_lock') && $this->routeProvider
      ->getRoutesByNames([
      'view.locked_content.page_1',
    ])) {
      $this->derivatives["thunder_article.content_lock"] = [
        'route_name' => "view.locked_content.page_1",
        'title' => $this
          ->t('Locked content'),
        'parent_id' => "system.admin_content",
        'weight' => 2,
      ] + $base_plugin_definition;
    }
    if ($this->moduleHandler
      ->moduleExists('scheduler') && $this->routeProvider
      ->getRoutesByNames([
      'view.scheduler_scheduled_content.overview',
    ])) {

      // See thunder_article_menu_local_tasks_alter() for how this is displayed
      // or not depending on configuration.
      $this->derivatives["thunder_article.scheduler"] = [
        'route_name' => "view.scheduler_scheduled_content.overview",
        'title' => $this
          ->t('Scheduled content'),
        'parent_id' => "system.admin_content",
        'weight' => 3,
        'cache_tags' => $this->configFactory
          ->get('thunder_article.settings')
          ->getCacheTags(),
      ] + $base_plugin_definition;
    }
    if ($this->moduleHandler
      ->moduleExists('access_unpublished') && $this->routeProvider
      ->getRoutesByNames([
      'access_unpublished.access_token.list',
    ])) {
      $this->derivatives["thunder_article.access_unpublished"] = [
        'route_name' => "access_unpublished.access_token.list",
        'title' => $this
          ->t('Unpublished access'),
        'parent_id' => "system.admin_content",
        'weight' => 4,
      ] + $base_plugin_definition;
    }
    return $this->derivatives;
  }

}

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
DynamicLocalTasks::$configFactory protected property The config factory service.
DynamicLocalTasks::$moduleHandler protected property The module handler service.
DynamicLocalTasks::$routeProvider protected property The route provider service.
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 an DynamicLocalTasks object.
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.