moved consent field to opencase_defaults and removed automatic "see all people" menu links
This commit is contained in:
parent
7c5ee54a44
commit
dfb12d9be6
@ -91,6 +91,20 @@ function opencase_defaults_block_access(\Drupal\block\Entity\Block $block, $oper
|
||||
|
||||
function opencase_defaults_entity_base_field_info($entity_type) {
|
||||
$fields = array();
|
||||
|
||||
// Add consent field to person
|
||||
if ($entity_type->id() === 'oc_actor') {
|
||||
$fields['consent'] = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Consent to data storage'))
|
||||
->setDescription(t('Has this person explicitly consented to having their personal data stored on this system?'))
|
||||
->setRevisionable(TRUE)
|
||||
->setDefaultValue(FALSE)
|
||||
->setRequired(TRUE)
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'boolean_checkbox',
|
||||
'weight' => -6,
|
||||
));
|
||||
}
|
||||
|
||||
// Add a Client field to cases
|
||||
if ($entity_type->id() === 'oc_case') {
|
||||
@ -117,7 +131,7 @@ function opencase_defaults_entity_base_field_info($entity_type) {
|
||||
])
|
||||
->setDefaultValueCallback('opencase_defaults_actors_involved_callback')
|
||||
->setRequired(TRUE);
|
||||
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -283,17 +283,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
])
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['consent'] = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Consent to data storage'))
|
||||
->setDescription(t('Has this person explicitly consented to having their personal data stored on this system?'))
|
||||
->setRevisionable(TRUE)
|
||||
->setDefaultValue(FALSE)
|
||||
->setRequired(TRUE)
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'boolean_checkbox',
|
||||
'weight' => -6,
|
||||
));
|
||||
|
||||
// Contact details.
|
||||
// so it is not exposed to user configuration.
|
||||
$fields['email'] = BaseFieldDefinition::create('string')
|
||||
|
@ -3,11 +3,6 @@ opencase.see_all:
|
||||
menu_name: opencase
|
||||
route_name: opencase.opencase_cases_menu
|
||||
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:
|
||||
title: 'Add new...'
|
||||
menu_name: opencase
|
||||
|
@ -1,55 +0,0 @@
|
||||
<?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_persons_of_a_type.page_1",
|
||||
'route_parameters' => ['actor_type' => $actorType->id()]
|
||||
] + $base_plugin_definition;
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?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 {}
|
Reference in New Issue
Block a user