class OgLocalTask in Organic groups 8
Provides local task definitions for all entity bundles.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\og\Plugin\Derivative\OgLocalTask implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of OgLocalTask
1 file declares its use of OgLocalTask
- OgLocalTaskTest.php in tests/
src/ Unit/ OgLocalTaskTest.php
1 string reference to 'OgLocalTask'
File
- src/
Plugin/ Derivative/ OgLocalTask.php, line 17
Namespace
Drupal\og\Plugin\DerivativeView source
class OgLocalTask extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The group type manager.
*
* @var \Drupal\og\GroupTypeManagerInterface
*/
protected $groupTypeManager;
/**
* Route provider object.
*
* @var \Drupal\Core\Routing\RouteProvider
*/
protected $routProvider;
/**
* Creates an OgLocalTask object.
*
* @param \Drupal\og\GroupTypeManagerInterface $group_type_manager
* The group type manager.
* @param \Drupal\Core\Routing\RouteProvider $route_provider
* The route provider services.
*/
public function __construct(GroupTypeManagerInterface $group_type_manager, RouteProvider $route_provider) {
$this->groupTypeManager = $group_type_manager;
$this->routProvider = $route_provider;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('og.group_type_manager'), $container
->get('router.route_provider'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$derivatives = [];
foreach (array_keys($this->groupTypeManager
->getGroupMap()) as $entity_type_id) {
$route_name = "entity.{$entity_type_id}.og_admin_routes";
if (!$this->routProvider
->getRoutesByNames([
$route_name,
])) {
// Route not found.
continue;
}
$derivatives[$entity_type_id . '.og_admin_routes'] = [
'route_name' => $route_name,
'title' => $this
->t('Group'),
'base_route' => 'entity.' . $entity_type_id . '.canonical',
'weight' => 50,
];
}
// @todo Coder throws a false positive for this line. Remove this once the
// issue is fixed in the Coder project.
// @see https://www.drupal.org/project/coder/issues/3065679
// @codingStandardsIgnoreLine
foreach ($derivatives as &$entry) {
// @codingStandardsIgnoreLine
$entry += $base_plugin_definition;
}
return $derivatives;
}
}
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:: |
|
OgLocalTask:: |
protected | property | The group type manager. | |
OgLocalTask:: |
protected | property | Route provider object. | |
OgLocalTask:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
OgLocalTask:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
OgLocalTask:: |
public | function | Creates an OgLocalTask object. | |
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. |