Compare commits
11 Commits
225e92a51c
...
refactor
Author | SHA1 | Date | |
---|---|---|---|
d8f1f4cbdd | |||
22640f02b6 | |||
797da77803 | |||
66f95f46bf | |||
b85cbaf398 | |||
34b7a1c7c9 | |||
fb2249d9bd | |||
614293c114 | |||
167166b898 | |||
c3f802835f | |||
13ddf5aa13 |
@ -0,0 +1,8 @@
|
||||
uuid: 85aacc47-8df9-4309-b7f4-f58be70f83d0
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
name: 'Case Provider Roles'
|
||||
vid: oc_case_provider_role
|
||||
description: ''
|
||||
weight: 0
|
8
config/install/taxonomy.vocabulary.oc_fee_category.yml
Normal file
8
config/install/taxonomy.vocabulary.oc_fee_category.yml
Normal file
@ -0,0 +1,8 @@
|
||||
uuid: 93a96bb4-da95-4d69-be37-d1477624f849
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
name: 'Fee categories'
|
||||
vid: oc_fee_category
|
||||
description: ''
|
||||
weight: 0
|
@ -1,4 +1,20 @@
|
||||
<?php
|
||||
use \Drupal\Core\Field\BaseFieldDefinition;
|
||||
|
||||
function opencase_cases_update_90002() {
|
||||
$field_storage_definition = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Target'))
|
||||
->setRevisionable(TRUE)
|
||||
->setSetting('target_type', 'oc_actor')
|
||||
->setSetting('handler', 'default')
|
||||
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
|
||||
\Drupal::entityDefinitionUpdateManager()
|
||||
->installFieldStorageDefinition('oc_target', 'oc_case', 'opencase_cases', $field_storage_definition);
|
||||
}
|
||||
|
||||
function opencase_cases_update_8025() {
|
||||
//check if the table exists first. If not, then create the entity.
|
||||
@ -10,7 +26,7 @@ function opencase_cases_update_8025() {
|
||||
}
|
||||
|
||||
function opencase_cases_update_8026() {
|
||||
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||
$storage_definition = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Role'))
|
||||
->setSetting('target_type', 'taxonomy_term')
|
||||
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])
|
||||
|
@ -7,6 +7,9 @@ declare(strict_types = 1);
|
||||
*/
|
||||
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use PHPUnit\Framework\Constraint\IsEmpty;
|
||||
|
||||
use function PHPUnit\Framework\isEmpty;
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
@ -94,7 +97,8 @@ function opencase_cases_get_activities(Drupal\opencase_cases\entity\OCCase $case
|
||||
}
|
||||
|
||||
function opencase_cases_get_amount(Drupal\opencase_cases\entity\OCCaseFee $case_fee): string {
|
||||
return $case_fee->amount->first()->value;
|
||||
if (!isEmpty($case_fee->amount)) return $case_fee->amount->first()->value;
|
||||
else return '0';
|
||||
}
|
||||
|
||||
function opencase_cases_get_case(Drupal\opencase_cases\entity\OCCaseFee $case_fee): Drupal\opencase_cases\entity\OCCase {
|
||||
@ -180,9 +184,16 @@ function opencase_cases_form_alter(&$form, &$form_state, $form_id) {
|
||||
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
||||
$form_state->setRedirect('<front>');
|
||||
}
|
||||
|
||||
// Upon deletion of an activity, go to the related case if there is one, otherwise to its target.
|
||||
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
||||
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
||||
if (!IsEmpty($form_state->getFormObject()->getEntity()->oc_case)) {
|
||||
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
||||
} else {
|
||||
$target_actor_id = $form_state->getFormObject()->getEntity()->oc_target->target_id;
|
||||
$form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK().
|
||||
|
@ -25,8 +25,8 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
|
||||
* An array suitable for drupal_render().
|
||||
*/
|
||||
public function revisionShow($oc_case_revision) {
|
||||
$oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
||||
$view_builder = $this->entityManager()->getViewBuilder('oc_case');
|
||||
$oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
||||
$view_builder = $this->entityTypeManager()->getViewBuilder('oc_case');
|
||||
|
||||
return $view_builder->view($oc_case);
|
||||
}
|
||||
@ -41,8 +41,10 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
|
||||
* The page title.
|
||||
*/
|
||||
public function revisionPageTitle($oc_case_revision) {
|
||||
$oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
||||
return $this->t('Revision of %title from %date', ['%title' => $oc_case->label(), '%date' => format_date($oc_case->getRevisionCreationTime())]);
|
||||
$oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
||||
|
||||
$date = \Drupal::service('date.formatter')->format($oc_case->getRevisionCreationTime());
|
||||
return $this->t('Revision of %title from %date', ['%title' => $oc_case->label(), '%date' => $date]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +62,7 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
|
||||
$langname = $oc_case->language()->getName();
|
||||
$languages = $oc_case->getTranslationLanguages();
|
||||
$has_translations = (count($languages) > 1);
|
||||
$oc_case_storage = $this->entityManager()->getStorage('oc_case');
|
||||
$oc_case_storage = $this->entityTypeManager()->getStorage('oc_case');
|
||||
|
||||
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case->label()]);
|
||||
$header = [$this->t('Revision'), $this->t('Operations')];
|
||||
@ -88,10 +90,11 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
|
||||
// Use revision link to link to revisions that are not active.
|
||||
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
|
||||
if ($vid != $oc_case->getRevisionId()) {
|
||||
$link = $this->l($date, new Url('entity.oc_case.revision', ['oc_case' => $oc_case->id(), 'oc_case_revision' => $vid]));
|
||||
$url = new Url('entity.oc_case.revision', ['oc_case' => $oc_case->id(), 'oc_case_revision' => $vid]);
|
||||
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
|
||||
}
|
||||
else {
|
||||
$link = $oc_case->link($date);
|
||||
$link = $oc_case->toLink($date)->toString();
|
||||
}
|
||||
|
||||
$row = [];
|
||||
|
@ -118,13 +118,14 @@ class OCCaseFeeController extends ControllerBase implements ContainerInjectionIn
|
||||
// Use revision link to link to revisions that are not active.
|
||||
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
||||
if ($vid != $oc_case_fee->getRevisionId()) {
|
||||
$link = $this->l($date, new Url('entity.oc_case_fee.revision', [
|
||||
$url = new Url('entity.oc_case_fee.revision', [
|
||||
'oc_case_fee' => $oc_case_fee->id(),
|
||||
'oc_case_fee_revision' => $vid,
|
||||
]));
|
||||
]);
|
||||
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
|
||||
}
|
||||
else {
|
||||
$link = $oc_case_fee->link($date);
|
||||
$link = $oc_case_fee->toLink($date)->toString();
|
||||
}
|
||||
|
||||
$row = [];
|
||||
|
@ -118,13 +118,14 @@ class OCCaseProvisionController extends ControllerBase implements ContainerInjec
|
||||
// Use revision link to link to revisions that are not active.
|
||||
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
||||
if ($vid != $oc_case_provision->getRevisionId()) {
|
||||
$link = $this->l($date, new Url('entity.oc_case_provision.revision', [
|
||||
$url = new Url('entity.oc_case_provision.revision', [
|
||||
'oc_case_provision' => $oc_case_provision->id(),
|
||||
'oc_case_provision_revision' => $vid,
|
||||
]));
|
||||
]);
|
||||
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
|
||||
}
|
||||
else {
|
||||
$link = $oc_case_provision->link($date);
|
||||
$link = $oc_case_provision->toLink($date)->toString();
|
||||
}
|
||||
|
||||
$row = [];
|
||||
|
@ -89,6 +89,12 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function defaultTarget() {
|
||||
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
|
||||
else return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -202,6 +208,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -230,6 +238,17 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
'type' => 'author',
|
||||
'weight' => 80,
|
||||
]);
|
||||
|
||||
|
||||
$fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Target'))
|
||||
->setRevisionable(TRUE)
|
||||
->setSetting('target_type', 'oc_actor')
|
||||
->setSetting('handler', 'default')
|
||||
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Title'))
|
||||
->setRevisionable(TRUE)
|
||||
|
@ -272,10 +272,8 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
||||
->setTranslatable(TRUE)
|
||||
->setCardinality(1)
|
||||
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
|
||||
->setDisplayOptions('view', [
|
||||
'type' => 'string',
|
||||
'weight' => 0,
|
||||
])
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['oc_fee_category'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||
|
@ -246,10 +246,14 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['status']->setDescription(t('A boolean indicating whether the Case Provision is published.'))
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE);
|
||||
|
||||
|
||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Visible'))
|
||||
->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)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
|
||||
$fields['created'] = BaseFieldDefinition::create('created')
|
||||
->setLabel(t('Created'))
|
||||
@ -273,10 +277,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
->setTranslatable(TRUE)
|
||||
->setCardinality(1)
|
||||
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
|
||||
->setDisplayOptions('view', [
|
||||
'type' => 'string',
|
||||
'weight' => 0,
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['oc_provider'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||
|
@ -54,18 +54,9 @@ class OCCaseFeeForm extends ContentEntityForm {
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$entity = $this->entity;
|
||||
|
||||
// Save as a new revision if requested to do so.
|
||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
||||
$entity->setNewRevision();
|
||||
|
||||
// If a new revision is created, save the current user as revision author.
|
||||
$entity->setRevisionCreationTime($this->time->getRequestTime());
|
||||
$entity->setRevisionUserId($this->account->id());
|
||||
}
|
||||
else {
|
||||
$entity->setNewRevision(FALSE);
|
||||
}
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
|
||||
$status = parent::save($form, $form_state);
|
||||
|
||||
|
@ -38,18 +38,9 @@ class OCCaseForm extends ContentEntityForm {
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$entity = $this->entity;
|
||||
|
||||
// Save as a new revision if requested to do so.
|
||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
||||
$entity->setNewRevision();
|
||||
|
||||
// If a new revision is created, save the current user as revision author.
|
||||
$entity->setRevisionCreationTime( \Drupal::time()->getRequestTime());
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
}
|
||||
else {
|
||||
$entity->setNewRevision(FALSE);
|
||||
}
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
|
||||
$status = parent::save($form, $form_state);
|
||||
|
||||
|
@ -54,18 +54,9 @@ class OCCaseProvisionForm extends ContentEntityForm {
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$entity = $this->entity;
|
||||
|
||||
// Save as a new revision if requested to do so.
|
||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
||||
$entity->setNewRevision();
|
||||
|
||||
// If a new revision is created, save the current user as revision author.
|
||||
$entity->setRevisionCreationTime($this->time->getRequestTime());
|
||||
$entity->setRevisionUserId($this->account->id());
|
||||
}
|
||||
else {
|
||||
$entity->setNewRevision(FALSE);
|
||||
}
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
|
||||
$status = parent::save($form, $form_state);
|
||||
|
||||
|
9
modules/opencase_cases/src/Helper/HookHelper.php
Normal file
9
modules/opencase_cases/src/Helper/HookHelper.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_cases\Helper;
|
||||
|
||||
class HookHelper {
|
||||
public static function onCaseFeeUpdate(\Drupal\opencase_cases\Entity\OCCaseFee $caseFee) {
|
||||
|
||||
}
|
||||
}
|
@ -91,7 +91,7 @@ function opencase_entities_theme() {
|
||||
* so that it can be used as a default callback for an entity reference field.
|
||||
*/
|
||||
function opencase_entities_get($key) {
|
||||
\Drupal::request()->query->get($key);
|
||||
return \Drupal::request()->query->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ namespace Drupal\opencase_entities\Controller;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\opencase_entities\Entity\OCActivityInterface;
|
||||
|
||||
@ -25,8 +26,8 @@ class OCActivityController extends ControllerBase implements ContainerInjectionI
|
||||
* An array suitable for drupal_render().
|
||||
*/
|
||||
public function revisionShow($oc_activity_revision) {
|
||||
$oc_activity = $this->entityManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
||||
$view_builder = $this->entityManager()->getViewBuilder('oc_activity');
|
||||
$oc_activity = $this->entityTypeManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
||||
$view_builder = $this->entityTypeManager()->getViewBuilder('oc_activity');
|
||||
|
||||
return $view_builder->view($oc_activity);
|
||||
}
|
||||
@ -41,8 +42,9 @@ class OCActivityController extends ControllerBase implements ContainerInjectionI
|
||||
* The page title.
|
||||
*/
|
||||
public function revisionPageTitle($oc_activity_revision) {
|
||||
$oc_activity = $this->entityManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
||||
return $this->t('Revision of %title from %date', ['%title' => $oc_activity->label(), '%date' => format_date($oc_activity->getRevisionCreationTime())]);
|
||||
$oc_activity = $this->entityTypeManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
||||
$date = \Drupal::service('date.formatter')->format($oc_activity->getRevisionCreationTime());
|
||||
return $this->t('Revision of %title from %date', ['%title' => $oc_activity->label(), '%date' => $date]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +62,7 @@ class OCActivityController extends ControllerBase implements ContainerInjectionI
|
||||
$langname = $oc_activity->language()->getName();
|
||||
$languages = $oc_activity->getTranslationLanguages();
|
||||
$has_translations = (count($languages) > 1);
|
||||
$oc_activity_storage = $this->entityManager()->getStorage('oc_activity');
|
||||
$oc_activity_storage = $this->entityTypeManager()->getStorage('oc_activity');
|
||||
|
||||
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_activity->label()]) : $this->t('Revisions for %title', ['%title' => $oc_activity->label()]);
|
||||
$header = [$this->t('Revision'), $this->t('Operations')];
|
||||
@ -88,10 +90,11 @@ class OCActivityController extends ControllerBase implements ContainerInjectionI
|
||||
// Use revision link to link to revisions that are not active.
|
||||
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
|
||||
if ($vid != $oc_activity->getRevisionId()) {
|
||||
$link = $this->l($date, new Url('entity.oc_activity.revision', ['oc_activity' => $oc_activity->id(), 'oc_activity_revision' => $vid]));
|
||||
$url = new Url('entity.oc_activity.revision', ['oc_activity' => $oc_activity->id(), 'oc_activity_revision' => $vid]);
|
||||
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
|
||||
}
|
||||
else {
|
||||
$link = $oc_activity->link($date);
|
||||
$link = $oc_activity->toLink($date)->toString();
|
||||
}
|
||||
|
||||
$row = [];
|
||||
|
@ -118,10 +118,11 @@ class OCOrganisationController extends ControllerBase implements ContainerInject
|
||||
// Use revision link to link to revisions that are not active.
|
||||
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
||||
if ($vid != $oc_organisation->getRevisionId()) {
|
||||
$link = $this->l($date, new Url('entity.oc_organisation.revision', [
|
||||
$url = new Url('entity.oc_organisation.revision', [
|
||||
'oc_organisation' => $oc_organisation->id(),
|
||||
'oc_organisation_revision' => $vid,
|
||||
]));
|
||||
]);
|
||||
$link = \Drupal\Core\Link::fromTextAndUrl($date,$url)->toString();
|
||||
}
|
||||
else {
|
||||
$link = $oc_organisation->toLink($date)->toString();
|
||||
|
@ -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'))
|
||||
|
@ -234,7 +234,7 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
||||
'weight' => 50,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'entity_reference_autocomplete_tags',
|
||||
'type' => 'entity_reference_autocomplete',
|
||||
'weight' => 50,
|
||||
])
|
||||
->setRequired(FALSE);
|
||||
|
@ -38,18 +38,9 @@ class OCActivityForm extends ContentEntityForm {
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$entity = $this->entity;
|
||||
|
||||
// Save as a new revision if requested to do so.
|
||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
||||
$entity->setNewRevision();
|
||||
|
||||
// If a new revision is created, save the current user as revision author.
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
}
|
||||
else {
|
||||
$entity->setNewRevision(FALSE);
|
||||
}
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
|
||||
$status = parent::save($form, $form_state);
|
||||
|
||||
@ -66,8 +57,8 @@ class OCActivityForm extends ContentEntityForm {
|
||||
]));
|
||||
}
|
||||
// If you have unpublished the entity and you can't see unpublished entities, redirect to a more informative message than just "Access Denied".
|
||||
if (!$form_state->getValue('status')['value'] && !\Drupal::currentUser()->hasPermission('view unpublished activity entities')) {
|
||||
\Drupal::messenger()->addMessage($this->t('The %bundle is now unpublished & hidden from you.', [
|
||||
if (is_array($form_state->getValue('status')) && $form_state->getValue('status')['value'] == false && !\Drupal::currentUser()->hasPermission('view unpublished actor entities')) {
|
||||
\Drupal::messenger()->addMessage($this->t('The %bundle is now unpublished & hidden from you.', [
|
||||
'%bundle' => $entity->bundle(),
|
||||
]));
|
||||
$form_state->setRedirect('<front>');
|
||||
|
@ -38,8 +38,6 @@ class OCActorForm extends ContentEntityForm {
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$entity = $this->entity;
|
||||
// Always make a new revision for a person. They are not changed often and people are likely to
|
||||
// want to know what has happened to them over time.
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
|
@ -54,18 +54,9 @@ class OCOrganisationForm extends ContentEntityForm {
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$entity = $this->entity;
|
||||
|
||||
// Save as a new revision if requested to do so.
|
||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
||||
$entity->setNewRevision();
|
||||
|
||||
// If a new revision is created, save the current user as revision author.
|
||||
$entity->setRevisionCreationTime($this->time->getRequestTime());
|
||||
$entity->setRevisionUserId($this->account->id());
|
||||
}
|
||||
else {
|
||||
$entity->setNewRevision(FALSE);
|
||||
}
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||
|
||||
$status = parent::save($form, $form_state);
|
||||
|
||||
|
@ -1,11 +1,21 @@
|
||||
opencase.see_all:
|
||||
title: 'See all...'
|
||||
menu_name: opencase
|
||||
menu_name: opencase
|
||||
route_name: opencase.opencase_cases_menu
|
||||
weight: 0
|
||||
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:
|
||||
@ -33,45 +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
|
||||
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
|
||||
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
|
||||
|
52
src/Plugin/Derivative/ManageTaxonomyMenuLink.php
Normal file
52
src/Plugin/Derivative/ManageTaxonomyMenuLink.php
Normal 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;
|
||||
}
|
||||
}
|
55
src/Plugin/Derivative/SeeAllActorsMenuLink.php
Normal file
55
src/Plugin/Derivative/SeeAllActorsMenuLink.php
Normal 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 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 = [];
|
||||
$actorTypes = $this->entityTypeManager->getStorage('oc_actor_type')->loadMultiple();
|
||||
foreach ($actorTypes as $id => $actorType) {
|
||||
$links[$id] = [
|
||||
'title' => $actorType->label(),
|
||||
'route_name' => "view.actors.page_1",
|
||||
'route_parameters' => ['type' => $actorType->id()]
|
||||
] + $base_plugin_definition;
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
}
|
55
src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php
Normal file
55
src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php
Normal 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;
|
||||
}
|
||||
}
|
6
src/Plugin/Menu/ManageTaxonomyMenuLink.php
Normal file
6
src/Plugin/Menu/ManageTaxonomyMenuLink.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Drupal\opencase\Plugin\Menu;
|
||||
|
||||
use Drupal\Core\Menu\MenuLinkDefault;
|
||||
|
||||
class ManageTaxonomyMenuLink extends MenuLinkDefault {}
|
9
src/Plugin/Menu/SeeAllActorsMenuLink.php
Normal file
9
src/Plugin/Menu/SeeAllActorsMenuLink.php
Normal 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 various types.
|
||||
*/
|
||||
class SeeAllActorsMenuLink extends MenuLinkDefault {}
|
9
src/Plugin/Menu/SeeAllOrganisationsMenuLink.php
Normal file
9
src/Plugin/Menu/SeeAllOrganisationsMenuLink.php
Normal 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 {}
|
16
tests/src/Unit/HookHelperTest.php
Normal file
16
tests/src/Unit/HookHelperTest.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user