TaxonomyMenuMenuLink.php in Zircon Profile 8
File
modules/taxonomy_menu/src/Plugin/Menu/TaxonomyMenuMenuLink.php
View source
<?php
namespace Drupal\taxonomy_menu\Plugin\Menu;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Menu\MenuLinkBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TaxonomyMenuMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterface {
protected $overrideAllowed = array(
'weight' => 1,
'expanded' => 1,
'enabled' => 1,
);
protected $entityManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
$this->configuration = $configuration;
$this->pluginId = $plugin_id;
$this->pluginDefinition = $plugin_definition;
$this->entityManager = $entity_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity.manager'));
}
public function getTitle() {
return $this->entityManager
->getStorage('taxonomy_term')
->load($this->pluginDefinition['metadata']['taxonomy_term_id'])
->label();
}
public function getDescription() {
return $this->entityManager
->getStorage('taxonomy_term')
->load($this->pluginDefinition['metadata']['taxonomy_term_id'])
->getDescription();
}
public function updateLink(array $new_definition_values, $persist) {
$overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
$this->pluginDefinition = $overrides + $this->pluginDefinition;
if ($persist) {
}
return $this->pluginDefinition;
}
public function isDeletable() {
return TRUE;
}
public function deleteLink() {
}
}