Added menu links for seeing lists of things, also updated install.txt

This commit is contained in:
Naomi 2020-11-09 17:50:09 +00:00
parent df2c826a33
commit 27cb58512e
5 changed files with 78 additions and 2 deletions

View File

@ -3,15 +3,23 @@ SYSTEM
apt install php-gd php-mbstring php-xml php-curl composer apt install php-gd php-mbstring php-xml php-curl composer
a2enmod rewrite a2enmod rewrite
SITE SITE
==== ====
#TODO make the vhost #TODO make the vhost
#TODO in apache2.conf set Override All on the directory #TODO in apache2.conf set Override All on the directory
DRUPAL DRUPAL
====== ======
composer create-project drupal/recommended-project drupal composer create-project drupal/recommended-project drupal
#TODO place composer.json in the drupal directory that should have appeared
composer install
mysql -uroot -p mysql -uroot -p
drop database ...; drop database ...;
create database ...; create database ...;

View File

@ -16,5 +16,4 @@ opencase.opencase_all_cases:
menu_name: opencase menu_name: opencase
parent: opencase.see_all parent: opencase.see_all
url: internal:/opencase/all-cases url: internal:/opencase/all-cases
weight: 1 weight: -1

View File

@ -3,6 +3,11 @@ opencase.see_all:
menu_name: opencase menu_name: opencase
route_name: opencase.opencase_cases_menu route_name: opencase.opencase_cases_menu
weight: 0 weight: 0
opencase.see_all_people_links:
class: Drupal\opencase\Plugin\Menu\SeeAllActorsMenuLink
deriver: Drupal\opencase\Plugin\Derivative\SeeAllActorsMenuLink
menu_name: opencase
parent: opencase.see_all
opencase.opencase_add_new_things_menu: opencase.opencase_add_new_things_menu:
title: 'Add new...' title: 'Add new...'
menu_name: opencase menu_name: opencase

View File

@ -0,0 +1,55 @@
<?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',
'route_name' => "view.all_actors_of_a_type.page_1",
'route_parameters' => ['actor_type' => $actorType->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 actors of some type.
*/
class SeeAllActorsMenuLink extends MenuLinkDefault {}