Added the seeAllEvents but it is not workgin do to a bug I can't seem to fin

This commit is contained in:
Nick 2022-04-15 16:29:26 +02:00
parent 20ed3d4f39
commit 55f34cb4d7
3 changed files with 74 additions and 0 deletions

View File

@ -13,6 +13,11 @@ opencase.see_all_organisations_links:
deriver: Drupal\opencase\Plugin\Derivative\SeeAllOrganisationsMenuLink
menu_name: opencase
parent: opencase.see_all
opencase.see_all_events_links:
class: Drupal\opencase\Plugin\Menu\SeeAllEventsMenuLink
deriver: Drupal\opencase\Plugin\Derivative\SeeAllEventsMenuLink
menu_name: opencase
parent: opencase.see_all
opencase.opencase_add_new_things_menu:
title: 'Add new...'
menu_name: opencase

View File

@ -0,0 +1,60 @@
<?php
namespace Drupal\opencase\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*  * Derivative class that provides the menu links adding various types of events
*  */
class SeeAllEventsMenuLink extends DeriverBase implements ContainerDeriverInterface
{
/**
*    * @var EntityTypeManagerInterface $entityTypeManager .
*    */
protected $entityTypeManager;
/**
*    * Creates a AddActorsMenuLink 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 = [];
$eventTypes = $this->entityTypeManager->getStorage('oc_event_type')->loadMultiple();
foreach ($eventTypes as $id => $eventType) {
$links[$id] = [
'title' => $eventType->label(),
'route_name' => "view.actors.page_1", //@TODO findout why "view.events.page_1" does not work
'route_parameters' => ['type' => $eventType->id()]
] + $base_plugin_definition;
}
return $links;
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace Drupal\opencase\Plugin\Menu;
use Drupal\Core\Menu\MenuLinkDefault;
/**
* Represents a menu link for seeing all Events of various types.
*/
class SeeAllEventsMenuLink extends MenuLinkDefault {}