public function AddMenuOverride::addMenuOverride in Entity Reference Hierarchy 8.2
Same name and namespace in other branches
- 3.x modules/entity_hierarchy_microsite/src/Controller/AddMenuOverride.php \Drupal\entity_hierarchy_microsite\Controller\AddMenuOverride::addMenuOverride()
Route callback for adding a new override.
Parameters
string $target: Target UUID.
Return value
array Form.
1 string reference to 'AddMenuOverride::addMenuOverride'
- entity_hierarchy_microsite.routing.yml in modules/
entity_hierarchy_microsite/ entity_hierarchy_microsite.routing.yml - modules/entity_hierarchy_microsite/entity_hierarchy_microsite.routing.yml
File
- modules/
entity_hierarchy_microsite/ src/ Controller/ AddMenuOverride.php, line 75
Class
- AddMenuOverride
- Defines a class for a controller for adding a menu overrride.
Namespace
Drupal\entity_hierarchy_microsite\ControllerCode
public function addMenuOverride(string $target) {
$plugin_id = 'entity_hierarchy_microsite:' . $target;
if (!$this->menuLinkManager
->hasDefinition($plugin_id)) {
throw new NotFoundHttpException();
}
$storage = $this->entityTypeManager
->getStorage('eh_microsite_menu_override');
if ($storage
->loadByProperties([
'target' => $target,
])) {
throw new NotFoundHttpException();
}
/** @var \Drupal\entity_hierarchy_microsite\Plugin\Menu\MicrositeMenuItem $instance */
$instance = $this->menuLinkManager
->createInstance($plugin_id);
$override = $storage
->create([
'target' => $target,
'enabled' => $instance
->isEnabled(),
'weight' => $instance
->getWeight(),
'title' => $instance
->getTitle(),
'parent' => $instance
->getParent(),
]);
return $this->entityFormBuilder
->getForm($override);
}