Compare commits

...
This repository has been archived on 2022-07-12. You can view files and clone it, but cannot push or open issues or pull requests.

4 Commits

Author SHA1 Message Date
naomi d8f1f4cbdd Added links to admin menu for managing taxonomies 2022-04-21 08:46:13 +01:00
naomi 22640f02b6 Started adding HookHelper and tests but the tests aren't working 2022-04-21 08:29:32 +01:00
naomi 797da77803 mob next [ci-skip] [ci skip] [skip ci] 2022-04-08 12:51:38 +01:00
Nick 66f95f46bf mob next [ci-skip] [ci skip] [skip ci]
lastFile:src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php
2022-04-08 13:20:01 +02:00
8 changed files with 172 additions and 35 deletions

View File

@ -0,0 +1,9 @@
<?php
namespace Drupal\opencase_cases\Helper;
class HookHelper {
public static function onCaseFeeUpdate(\Drupal\opencase_cases\Entity\OCCaseFee $caseFee) {
}
}

View File

@ -267,6 +267,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.')
->setRevisionable(TRUE)
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', true)
->setDefaultValue(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
@ -277,10 +278,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayConfigurable('view', true)
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'author',
]);
->setDisplayConfigurable('form', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Subject'))
@ -292,15 +290,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setDefaultValue('')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -3,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -3,
])
->setRequired(TRUE);
$fields['description'] = BaseFieldDefinition::create('string_long')
@ -310,7 +299,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setRequired(FALSE);
@ -322,15 +310,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
'suffix' => 'minutes',
])
->SetDisplayConfigurable("form", true)
->SetDisplayConfigurable("view", true)
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'weight' => -3,
])
->setDisplayOptions('form', [
'weight' => -3,
]);
->SetDisplayConfigurable("view", true);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))

View File

@ -1,16 +1,21 @@
opencase.see_all:
title: 'See all...'
menu_name: opencase
menu_name: opencase
route_name: opencase.opencase_cases_menu
weight:
weight:
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.see_all_organisations_links:
class: Drupal\opencase\Plugin\Menu\SeeAllOrganisationsMenuLink
deriver: Drupal\opencase\Plugin\Derivative\SeeAllOrganisationsMenuLink
menu_name: opencase
parent: opencase.see_all
opencase.opencase_add_new_things_menu:
title: 'Add new...'
menu_name: opencase
menu_name: opencase
route_name: opencase.opencase_add_new_things_menu
weight: 1
opencase.add_people_links:
@ -38,59 +43,64 @@ opencase.opencase_admin_menu:
title: 'Administration'
description: 'Management and Configuration'
route_name: opencase.opencase_admin_menu
menu_name: opencase
menu_name: opencase
weight: 100
opencase.manage_taxonomy_links:
class: Drupal\opencase\Plugin\Menu\ManageTaxonomyMenuLink
deriver: Drupal\opencase\Plugin\Derivative\ManageTaxonomyMenuLink
menu_name: opencase
parent: opencase.opencase_admin_menu
opencase.manage_user_logins:
title: 'Manage user logins'
description: 'Manage who can access the system'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/admin/people
weight: 0
opencase.manage_organisation_types:
title: 'Manage organisation types'
description: 'Configure types of people and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_organisation_type
weight: 1
opencase.manage_person_types:
title: 'Manage person types'
description: 'Configure types of people and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_actor_type
weight: 1
opencase.manage_activity_types:
title: 'Manage activity types'
description: 'Configure types of activities and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_activity_type
weight: 3
opencase.manage_case_fee_types:
title: 'Manage case fee types'
description: 'Configure types of case fees and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/opencase/oc_case_fee_type
weight: 3
opencase.manage_case_provision_types:
title: 'Manage case provision types'
description: 'Configure types of case provisions and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/opencase/oc_case_provision_type
weight: 3
opencase.manage_event_types:
title: 'Manage event types'
description: 'Configure types of people and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_event_type
weight: 1
opencase.reporting:
title: 'Reporting'
menu_name: opencase
menu_name: opencase
route_name: opencase.opencase_reporting_menu
weight: 0

View File

@ -0,0 +1,52 @@
<?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;
class ManageTaxonomyMenuLink extends DeriverBase implements ContainerDeriverInterface {
/**
   * @var EntityTypeManagerInterface $entityTypeManager.
   */
protected $entityTypeManager;
/**
   * Creates a AddEventsMenuLink 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 = [];
$vocabs = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->loadMultiple();
foreach ($vocabs as $id => $vocab) {
$links[$id] = [
'title' => 'Manage ' . $vocab->label(),
'route_name' => "entity.taxonomy_vocabulary.overview_form",
'route_parameters' => ['taxonomy_vocabulary' => $vocab->id()]
] + $base_plugin_definition;
}
return $links;
}
}

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 organisations
 */
class SeeAllOrganisationsMenuLink 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 = [];
$organisationTypes = $this->entityTypeManager->getStorage('oc_organisation_type')->loadMultiple();
foreach ($organisationTypes as $id => $organisationType) {
$links[$id] = [
'title' => $organisationType->label(),
'route_name' => "view.organisations.page_1",
'route_parameters' => ['type' => $organisationType->id()]
] + $base_plugin_definition;
}
return $links;
}
}

View File

@ -0,0 +1,6 @@
<?php
namespace Drupal\opencase\Plugin\Menu;
use Drupal\Core\Menu\MenuLinkDefault;
class ManageTaxonomyMenuLink extends MenuLinkDefault {}

View File

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

View File

@ -0,0 +1,16 @@
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
include '../../../modules/opencase_cases/src/Entity/OCCase.php';
final class HookHelperTest extends TestCase
{
public function testOnCaseFeeUpdate(): void
{
$caseStub = $this->createStub(\Drupal\opencase_cases\Entity\OCCase::class);
$caseStub->total_fee = 5;
$caseFeeStub = $this->createStub(\Drupal\opencase_cases\Entity\OCCaseFee::class);
$caseFeeStub->amount = 10;
$caseFeeStub->method('getCase')->will($this->returnValue($caseStub));
$this->assertSame(5,5);
}
}