public function MenuLinkConfigForm::setMenuLinkInstance in Config menu link 8
Injects the menu link plugin instance.
Parameters
\Drupal\Core\Menu\MenuLinkInterface $menu_link: A menu link plugin instance.
Overrides MenuLinkFormInterface::setMenuLinkInstance
File
- src/
Plugin/ Menu/ Form/ MenuLinkConfigForm.php, line 103 - Contains \Drupal\menu_link_config\Plugin\Menu\Form\MenuLinkConfigForm.
Class
Namespace
Drupal\menu_link_config\Plugin\Menu\FormCode
public function setMenuLinkInstance(MenuLinkInterface $menu_link) {
// Load the entity for the entity form. Loading by entity ID is much faster
// than loading by UUID, so use that ID if we have it.
$metadata = $menu_link
->getMetaData();
if (!empty($metadata['entity_id'])) {
$this->entity = $this->entityManager
->getStorage('menu_link_config')
->load($metadata['entity_id']);
}
else {
// Fallback to the loading by UUID.
$links = $this->entityManager
->getStorage('menu_link_config')
->loadByProperties([
'uuid' => $menu_link
->getDerivativeId(),
]);
$this->entity = reset($links);
}
}