2020-11-09 17:50:09 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Drupal\opencase\Plugin\Derivative;
|
|
|
|
|
|
|
|
|
|
use Drupal\Component\Plugin\Derivative\DeriverBase;
|
|
|
|
|
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
|
|
|
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Derivative class that provides the menu links adding various types of actors
|
|
|
|
|
*/
|
|
|
|
|
class SeeAllActorsMenuLink extends DeriverBase implements ContainerDeriverInterface {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var EntityTypeManagerInterface $entityTypeManager.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
protected $entityTypeManager;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a SeeAllActorsMenuLink instance.
|
|
|
|
|
*
|
|
|
|
|
* @param $base_plugin_id
|
|
|
|
|
* @param EntityTypeManagerInterface $entity_type_manager
|
|
|
|
|
*/
|
|
|
|
|
public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager) {
|
|
|
|
|
$this->entityTypeManager = $entity_type_manager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
|
|
|
|
public static function create(ContainerInterface $container, $base_plugin_id) {
|
|
|
|
|
return new static(
|
|
|
|
|
$base_plugin_id,
|
|
|
|
|
$container->get('entity_type.manager')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
|
|
|
|
public function getDerivativeDefinitions($base_plugin_definition) {
|
|
|
|
|
$links = [];
|
|
|
|
|
$actorTypes = $this->entityTypeManager->getStorage('oc_actor_type')->loadMultiple();
|
|
|
|
|
foreach ($actorTypes as $id => $actorType) {
|
|
|
|
|
$links[$id] = [
|
|
|
|
|
'title' => $actorType->label().'s',
|
2020-11-18 12:58:39 +00:00
|
|
|
|
'route_name' => "view.all_persons_of_a_type.page_1",
|
2020-11-09 17:50:09 +00:00
|
|
|
|
'route_parameters' => ['actor_type' => $actorType->id()]
|
|
|
|
|
] + $base_plugin_definition;
|
|
|
|
|
}
|
|
|
|
|
return $links;
|
|
|
|
|
}
|
|
|
|
|
}
|