class LocalActionDefault in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Menu/LocalActionDefault.php \Drupal\Core\Menu\LocalActionDefault
Provides a default implementation for local action plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Menu\LocalActionDefault implements LocalActionInterface, ContainerFactoryPluginInterface uses DependencySerializationTrait
Expanded class hierarchy of LocalActionDefault
6 files declare their use of LocalActionDefault
- BlockContentAddLocalAction.php in core/
modules/ block_content/ src/ Plugin/ Menu/ LocalAction/ BlockContentAddLocalAction.php - Contains \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction.
- LocalActionDefaultTest.php in core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalActionDefaultTest.php - Contains \Drupal\Tests\Core\Menu\LocalActionDefaultTest.
- MenuLinkAdd.php in core/
modules/ menu_ui/ src/ Plugin/ Menu/ LocalAction/ MenuLinkAdd.php - Contains \Drupal\menu_ui\Plugin\Menu\LocalAction\MenuLinkAdd.
- TestLocalAction.php in core/
modules/ system/ tests/ modules/ menu_test/ src/ Plugin/ Menu/ LocalAction/ TestLocalAction.php - Contains \Drupal\menu_test\Plugin\Menu\LocalAction\TestLocalAction.
- TestLocalAction4.php in core/
modules/ system/ tests/ modules/ menu_test/ src/ Plugin/ Menu/ LocalAction/ TestLocalAction4.php - Contains \Drupal\menu_test\Plugin\Menu\LocalAction\TestLocalAction4.
2 string references to 'LocalActionDefault'
- field_ui.links.action.yml in core/
modules/ field_ui/ field_ui.links.action.yml - core/modules/field_ui/field_ui.links.action.yml
- menu_test.links.action.yml in core/
modules/ system/ tests/ modules/ menu_test/ menu_test.links.action.yml - core/modules/system/tests/modules/menu_test/menu_test.links.action.yml
File
- core/
lib/ Drupal/ Core/ Menu/ LocalActionDefault.php, line 21 - Contains \Drupal\Core\Menu\LocalActionDefault.
Namespace
Drupal\Core\MenuView source
class LocalActionDefault extends PluginBase implements LocalActionInterface, ContainerFactoryPluginInterface {
use DependencySerializationTrait;
/**
* The route provider to load routes by name.
*
* @var \Drupal\Core\Routing\RouteProviderInterface
*/
protected $routeProvider;
/**
* Constructs a LocalActionDefault object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* The route provider to load routes by name.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->routeProvider = $route_provider;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('router.route_provider'));
}
/**
* {@inheritdoc}
*/
public function getRouteName() {
return $this->pluginDefinition['route_name'];
}
/**
* {@inheritdoc}
*/
public function getTitle(Request $request = NULL) {
// Subclasses may pull in the request or specific attributes as parameters.
// The title from YAML file discovery may be a TranslatableMarkup object.
return (string) $this->pluginDefinition['title'];
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->pluginDefinition['weight'];
}
/**
* {@inheritdoc}
*/
public function getRouteParameters(RouteMatchInterface $route_match) {
$parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array();
$route = $this->routeProvider
->getRouteByName($this
->getRouteName());
$variables = $route
->compile()
->getVariables();
// Normally the \Drupal\Core\ParamConverter\ParamConverterManager has
// processed the Request attributes, and in that case the _raw_variables
// attribute holds the original path strings keyed to the corresponding
// slugs in the path patterns. For example, if the route's path pattern is
// /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
// $raw_variables->get('filter_format') == 'plain_text'.
$raw_variables = $route_match
->getRawParameters();
foreach ($variables as $name) {
if (isset($parameters[$name])) {
continue;
}
if ($raw_variables && $raw_variables
->has($name)) {
$parameters[$name] = $raw_variables
->get($name);
}
elseif ($value = $route_match
->getRawParameter($name)) {
$parameters[$name] = $value;
}
}
// The UrlGenerator will throw an exception if expected parameters are
// missing. This method should be overridden if that is possible.
return $parameters;
}
/**
* {@inheritdoc}
*/
public function getOptions(RouteMatchInterface $route_match) {
return (array) $this->pluginDefinition['options'];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
LocalActionDefault:: |
protected | property | The route provider to load routes by name. | |
LocalActionDefault:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
LocalActionDefault:: |
public | function |
Returns options for rendering a link for the local action. Overrides LocalActionInterface:: |
2 |
LocalActionDefault:: |
public | function |
Get the route name from the settings. Overrides LocalActionInterface:: |
|
LocalActionDefault:: |
public | function |
Returns the route parameters needed to render a link for the local action. Overrides LocalActionInterface:: |
|
LocalActionDefault:: |
public | function |
Returns the localized title to be shown for this action. Overrides LocalActionInterface:: |
3 |
LocalActionDefault:: |
public | function |
Returns the weight for the local action. Overrides LocalActionInterface:: |
|
LocalActionDefault:: |
public | function |
Constructs a LocalActionDefault object. Overrides PluginBase:: |
1 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 2 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |