Compare commits
1 Commits
refactor
...
aa0c350766
Author | SHA1 | Date | |
---|---|---|---|
aa0c350766 |
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_cases\Helper;
|
||||
|
||||
class HookHelper {
|
||||
public static function onCaseFeeUpdate(\Drupal\opencase_cases\Entity\OCCaseFee $caseFee) {
|
||||
|
||||
}
|
||||
}
|
@ -267,7 +267,6 @@ 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')
|
||||
@ -278,7 +277,10 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
||||
->setSetting('handler', 'default')
|
||||
->setTranslatable(TRUE)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setDisplayConfigurable('form', TRUE);
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'author',
|
||||
]);
|
||||
|
||||
$fields['name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Subject'))
|
||||
@ -290,6 +292,15 @@ 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')
|
||||
@ -299,6 +310,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
||||
'max_length' => 50,
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
@ -310,7 +322,15 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
||||
'suffix' => 'minutes',
|
||||
])
|
||||
->SetDisplayConfigurable("form", true)
|
||||
->SetDisplayConfigurable("view", true);
|
||||
->SetDisplayConfigurable("view", true)
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'weight' => -3,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'weight' => -3,
|
||||
]);
|
||||
|
||||
$fields['created'] = BaseFieldDefinition::create('created')
|
||||
->setLabel(t('Created'))
|
||||
|
@ -8,11 +8,6 @@ opencase.see_all_people_links:
|
||||
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
|
||||
|
@ -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 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;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?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 {}
|
@ -1,16 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user