class LocalTasks in RNG - Events and Registrations 8
Same name in this branch
- 8 src/Plugin/Derivative/LocalTasks.php \Drupal\rng\Plugin\Derivative\LocalTasks
- 8 rng_debug/src/Plugin/Derivative/LocalTasks.php \Drupal\rng_debug\Plugin\Derivative\LocalTasks
Same name and namespace in other branches
- 8.2 rng_debug/src/Plugin/Derivative/LocalTasks.php \Drupal\rng_debug\Plugin\Derivative\LocalTasks
- 3.x rng_debug/src/Plugin/Derivative/LocalTasks.php \Drupal\rng_debug\Plugin\Derivative\LocalTasks
Provides dynamic tasks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\rng_debug\Plugin\Derivative\LocalTasks implements ContainerDeriverInterface
Expanded class hierarchy of LocalTasks
1 string reference to 'LocalTasks'
- rng_debug.links.task.yml in rng_debug/
rng_debug.links.task.yml - rng_debug/rng_debug.links.task.yml
File
- rng_debug/
src/ Plugin/ Derivative/ LocalTasks.php, line 14
Namespace
Drupal\rng_debug\Plugin\DerivativeView source
class LocalTasks extends DeriverBase implements ContainerDeriverInterface {
/**
* The RNG event manager.
*
* @var \Drupal\rng\EventManagerInterface
*/
protected $eventManager;
/**
* Constructs a LocalTasks object.
*
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* The route provider.
* @param \Drupal\rng\EventManagerInterface $event_manager
* The RNG event manager.
*/
public function __construct(RouteProviderInterface $route_provider, EventManagerInterface $event_manager) {
$this->routeProvider = $route_provider;
$this->eventManager = $event_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('router.route_provider'), $container
->get('rng.event_manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
$event_types = $this->eventManager
->getEventTypes();
foreach (array_keys($event_types) as $entity_type) {
// Only need one set of tasks task per entity type.
if ($this->routeProvider
->getRouteByName("entity.{$entity_type}.canonical")) {
$event_default = "rng.event.{$entity_type}.event.default";
$this->derivatives["rng.event.{$entity_type}.event.rules"] = array(
'title' => t('Rules'),
'route_name' => "rng.event.{$entity_type}.rules",
'parent_id' => 'rng.local_tasks:' . $event_default,
'weight' => 20,
);
}
}
foreach ($this->derivatives as &$entry) {
$entry += $base_plugin_definition;
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
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:: |
|
LocalTasks:: |
protected | property | The RNG event manager. | |
LocalTasks:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
LocalTasks:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
LocalTasks:: |
public | function | Constructs a LocalTasks object. |