MenuLinkDefault.php in Drupal 10
File
core/lib/Drupal/Core/Menu/MenuLinkDefault.php
View source
<?php
namespace Drupal\Core\Menu;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MenuLinkDefault extends MenuLinkBase implements ContainerFactoryPluginInterface {
protected $overrideAllowed = [
'menu_name' => 1,
'parent' => 1,
'weight' => 1,
'expanded' => 1,
'enabled' => 1,
];
protected $staticOverride;
public function __construct(array $configuration, $plugin_id, $plugin_definition, StaticMenuLinkOverridesInterface $static_override) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->staticOverride = $static_override;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('menu_link.static.overrides'));
}
public function getTitle() {
return (string) $this->pluginDefinition['title'];
}
public function getDescription() {
return (string) $this->pluginDefinition['description'];
}
public function isResettable() {
return (bool) $this->staticOverride
->loadOverride($this
->getPluginId());
}
public function updateLink(array $new_definition_values, $persist) {
$overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
$this->pluginDefinition = $overrides + $this
->getPluginDefinition();
if ($persist) {
$overrides['menu_name'] = $this->pluginDefinition['menu_name'];
$this->staticOverride
->saveOverride($this
->getPluginId(), $this->pluginDefinition);
}
return $this->pluginDefinition;
}
}