Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 12 |
| MenuLinkPluginConverter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 12 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| convert | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 8 |
|||
| applies | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\Core\ParamConverter\MenuLinkPluginConverter. | |
| */ | |
| namespace Drupal\Core\ParamConverter; | |
| use Drupal\Core\Menu\MenuLinkManagerInterface; | |
| use Drupal\Component\Plugin\Exception\PluginException; | |
| use Symfony\Component\Routing\Route; | |
| /** | |
| * Parameter converter for upcasting entity ids to full objects. | |
| */ | |
| 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'); | |
| } | |
| } |