class MenuLinkPluginConverter in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php \Drupal\Core\ParamConverter\MenuLinkPluginConverter
- 9 core/lib/Drupal/Core/ProxyClass/ParamConverter/MenuLinkPluginConverter.php \Drupal\Core\ProxyClass\ParamConverter\MenuLinkPluginConverter
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php \Drupal\Core\ParamConverter\MenuLinkPluginConverter
Parameter converter for upcasting entity ids to full objects.
Hierarchy
- class \Drupal\Core\ParamConverter\MenuLinkPluginConverter implements ParamConverterInterface
Expanded class hierarchy of MenuLinkPluginConverter
1 string reference to 'MenuLinkPluginConverter'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses MenuLinkPluginConverter
File
- core/
lib/ Drupal/ Core/ ParamConverter/ MenuLinkPluginConverter.php, line 12
Namespace
Drupal\Core\ParamConverterView source
class MenuLinkPluginConverter implements ParamConverterInterface {
/**
* Plugin manager which creates the instance from the value.
*
* @var \Drupal\Core\Menu\MenuLinkManagerInterface
*/
protected $menuLinkManager;
/**
* Constructs a new MenuLinkPluginConverter.
*
* @param \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager
* The menu link plugin manager.
*/
public function __construct(MenuLinkManagerInterface $menu_link_manager) {
$this->menuLinkManager = $menu_link_manager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
if ($value) {
try {
return $this->menuLinkManager
->createInstance($value);
} catch (PluginException $e) {
// Suppress the error.
}
}
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] === 'menu_link_plugin';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MenuLinkPluginConverter:: |
protected | property | Plugin manager which creates the instance from the value. | |
MenuLinkPluginConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
MenuLinkPluginConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
MenuLinkPluginConverter:: |
public | function | Constructs a new MenuLinkPluginConverter. |