Compare commits
19 Commits
225e92a51c
...
alex
Author | SHA1 | Date | |
---|---|---|---|
86c0fb1f65 | |||
92bce34fb1 | |||
02715bdc44 | |||
4ab621100f | |||
aa0c350766 | |||
17406061f9 | |||
489f4c0c94 | |||
2f06caa261 | |||
aa6d580d62 | |||
8c3f2bcbc3 | |||
55f34cb4d7 | |||
20ed3d4f39 | |||
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
|
<?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() {
|
function opencase_cases_update_8025() {
|
||||||
//check if the table exists first. If not, then create the entity.
|
//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() {
|
function opencase_cases_update_8026() {
|
||||||
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
$storage_definition = BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Role'))
|
->setLabel(t('Role'))
|
||||||
->setSetting('target_type', 'taxonomy_term')
|
->setSetting('target_type', 'taxonomy_term')
|
||||||
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])
|
->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 Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
use PHPUnit\Framework\Constraint\IsEmpty;
|
||||||
|
|
||||||
|
use function PHPUnit\Framework\isEmpty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_help().
|
* Implements hook_help().
|
||||||
@ -93,35 +96,19 @@ function opencase_cases_get_activities(Drupal\opencase_cases\entity\OCCase $case
|
|||||||
return $activities;
|
return $activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_cases_get_amount(Drupal\opencase_cases\entity\OCCaseFee $case_fee): string {
|
|
||||||
return $case_fee->amount->first()->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function opencase_cases_get_case(Drupal\opencase_cases\entity\OCCaseFee $case_fee): Drupal\opencase_cases\entity\OCCase {
|
|
||||||
return $case_fee->oc_case->referencedEntities()[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function opencase_cases_update_total_fee_for_case_belonging_to_case_fee(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
|
||||||
$total = 0;
|
|
||||||
$case = opencase_cases_get_case($case_fee);
|
|
||||||
$case_fees = opencase_cases_get_case_fees($case);
|
|
||||||
foreach($case_fees as $case_fee) {
|
|
||||||
$total += opencase_cases_get_amount($case_fee);
|
|
||||||
}
|
|
||||||
$case->set('total_fee', $total);
|
|
||||||
$case->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
function opencase_cases_oc_case_fee_update(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
function opencase_cases_oc_case_fee_update(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
||||||
opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee);
|
$case = $case_fee->getCase();
|
||||||
|
$case->addToTotalFee($case_fee->amount->value - $case_fee->original->amount->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_cases_oc_case_fee_insert(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
function opencase_cases_oc_case_fee_insert(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
||||||
opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee);
|
$case = $case_fee->getCase();
|
||||||
|
$case->addToTotalFee($case_fee->amount->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
||||||
opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee);
|
$case = $case_fee->getCase();
|
||||||
|
$case->addToTotalFee(0 - $case_fee->amount->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_cases_entity_base_field_info($entity_type) {
|
function opencase_cases_entity_base_field_info($entity_type) {
|
||||||
@ -180,9 +167,16 @@ function opencase_cases_form_alter(&$form, &$form_state, $form_id) {
|
|||||||
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
||||||
$form_state->setRedirect('<front>');
|
$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) {
|
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
||||||
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
if (!IsEmpty($form_state->getFormObject()->getEntity()->oc_case)) {
|
||||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
$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().
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
|
@ -25,8 +25,8 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
|
|||||||
* An array suitable for drupal_render().
|
* An array suitable for drupal_render().
|
||||||
*/
|
*/
|
||||||
public function revisionShow($oc_case_revision) {
|
public function revisionShow($oc_case_revision) {
|
||||||
$oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
$oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
||||||
$view_builder = $this->entityManager()->getViewBuilder('oc_case');
|
$view_builder = $this->entityTypeManager()->getViewBuilder('oc_case');
|
||||||
|
|
||||||
return $view_builder->view($oc_case);
|
return $view_builder->view($oc_case);
|
||||||
}
|
}
|
||||||
@ -41,8 +41,10 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
|
|||||||
* The page title.
|
* The page title.
|
||||||
*/
|
*/
|
||||||
public function revisionPageTitle($oc_case_revision) {
|
public function revisionPageTitle($oc_case_revision) {
|
||||||
$oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
|
$oc_case = $this->entityTypeManager()->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())]);
|
|
||||||
|
$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();
|
$langname = $oc_case->language()->getName();
|
||||||
$languages = $oc_case->getTranslationLanguages();
|
$languages = $oc_case->getTranslationLanguages();
|
||||||
$has_translations = (count($languages) > 1);
|
$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()]);
|
$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')];
|
$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.
|
// Use revision link to link to revisions that are not active.
|
||||||
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
|
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
|
||||||
if ($vid != $oc_case->getRevisionId()) {
|
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 {
|
else {
|
||||||
$link = $oc_case->link($date);
|
$link = $oc_case->toLink($date)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = [];
|
$row = [];
|
||||||
|
@ -118,13 +118,14 @@ class OCCaseFeeController extends ControllerBase implements ContainerInjectionIn
|
|||||||
// Use revision link to link to revisions that are not active.
|
// Use revision link to link to revisions that are not active.
|
||||||
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
||||||
if ($vid != $oc_case_fee->getRevisionId()) {
|
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' => $oc_case_fee->id(),
|
||||||
'oc_case_fee_revision' => $vid,
|
'oc_case_fee_revision' => $vid,
|
||||||
]));
|
]);
|
||||||
|
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$link = $oc_case_fee->link($date);
|
$link = $oc_case_fee->toLink($date)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = [];
|
$row = [];
|
||||||
|
@ -118,13 +118,14 @@ class OCCaseProvisionController extends ControllerBase implements ContainerInjec
|
|||||||
// Use revision link to link to revisions that are not active.
|
// Use revision link to link to revisions that are not active.
|
||||||
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
||||||
if ($vid != $oc_case_provision->getRevisionId()) {
|
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' => $oc_case_provision->id(),
|
||||||
'oc_case_provision_revision' => $vid,
|
'oc_case_provision_revision' => $vid,
|
||||||
]));
|
]);
|
||||||
|
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$link = $oc_case_provision->link($date);
|
$link = $oc_case_provision->toLink($date)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = [];
|
$row = [];
|
||||||
|
@ -75,30 +75,39 @@ use Drupal\user\UserInterface;
|
|||||||
* field_ui_base_route = "entity.oc_case_type.edit_form"
|
* field_ui_base_route = "entity.oc_case_type.edit_form"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||||
|
{
|
||||||
|
|
||||||
use EntityChangedTrait;
|
use EntityChangedTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
|
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
|
||||||
|
{
|
||||||
parent::preCreate($storage_controller, $values);
|
parent::preCreate($storage_controller, $values);
|
||||||
$values += [
|
$values += [
|
||||||
'user_id' => \Drupal::currentUser()->id(),
|
'user_id' => \Drupal::currentUser()->id(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function defaultTarget()
|
||||||
|
{
|
||||||
|
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
|
||||||
|
else return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function urlRouteParameters($rel) {
|
protected function urlRouteParameters($rel)
|
||||||
|
{
|
||||||
$uri_route_parameters = parent::urlRouteParameters($rel);
|
$uri_route_parameters = parent::urlRouteParameters($rel);
|
||||||
|
|
||||||
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
|
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
|
||||||
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
||||||
}
|
} elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
|
||||||
elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
|
|
||||||
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +117,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function preSave(EntityStorageInterface $storage) {
|
public function preSave(EntityStorageInterface $storage)
|
||||||
|
{
|
||||||
parent::preSave($storage);
|
parent::preSave($storage);
|
||||||
|
|
||||||
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
|
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
|
||||||
@ -130,14 +140,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->get('name')->value;
|
return $this->get('name')->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$this->set('name', $name);
|
$this->set('name', $name);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -145,14 +157,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCreatedTime() {
|
public function getCreatedTime()
|
||||||
|
{
|
||||||
return $this->get('created')->value;
|
return $this->get('created')->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setCreatedTime($timestamp) {
|
public function setCreatedTime($timestamp)
|
||||||
|
{
|
||||||
$this->set('created', $timestamp);
|
$this->set('created', $timestamp);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -160,21 +174,24 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getOwner() {
|
public function getOwner()
|
||||||
|
{
|
||||||
return $this->get('user_id')->entity;
|
return $this->get('user_id')->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getOwnerId() {
|
public function getOwnerId()
|
||||||
|
{
|
||||||
return $this->get('user_id')->target_id;
|
return $this->get('user_id')->target_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setOwnerId($uid) {
|
public function setOwnerId($uid)
|
||||||
|
{
|
||||||
$this->set('user_id', $uid);
|
$this->set('user_id', $uid);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -182,7 +199,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setOwner(UserInterface $account) {
|
public function setOwner(UserInterface $account)
|
||||||
|
{
|
||||||
$this->set('user_id', $account->id());
|
$this->set('user_id', $account->id());
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -190,22 +208,30 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function isPublished() {
|
public function isPublished()
|
||||||
return (bool) $this->getEntityKey('status');
|
{
|
||||||
|
return (bool)$this->getEntityKey('status');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setPublished($published) {
|
public function setPublished($published)
|
||||||
|
{
|
||||||
$this->set('status', $published ? TRUE : FALSE);
|
$this->set('status', $published ? TRUE : FALSE);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addToTotalFee(float $amountToAdd): void {
|
||||||
|
$this->set('total_fee', $this->total_fee->value + $amountToAdd);
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
|
||||||
|
{
|
||||||
$fields = parent::baseFieldDefinitions($entity_type);
|
$fields = parent::baseFieldDefinitions($entity_type);
|
||||||
|
|
||||||
// not currently used. Will add form and view settings when ready
|
// not currently used. Will add form and view settings when ready
|
||||||
@ -213,7 +239,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
->setLabel(t('Visible'))
|
->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.')
|
->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)
|
->setRevisionable(TRUE)
|
||||||
->setDisplayConfigurable("form", TRUE)
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true)
|
||||||
->setDefaultValue(TRUE);
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||||
@ -224,12 +251,18 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayConfigurable('view', true)
|
->setDisplayConfigurable('view', true);
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'author',
|
$fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
|
||||||
'weight' => 80,
|
->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')
|
$fields['name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Title'))
|
->setLabel(t('Title'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
@ -238,14 +271,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'hidden',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'string',
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -100,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
|
|
||||||
@ -259,18 +286,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
->setSetting('uri_scheme', 'private')
|
->setSetting('uri_scheme', 'private')
|
||||||
->setCardinality(-1)
|
->setCardinality(-1)
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayConfigurable('view', true)
|
->setDisplayConfigurable('view', true);
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'file_generic',
|
|
||||||
'weight' => -1,
|
|
||||||
'settings' => [
|
|
||||||
'progress_indicator' => 'throbber',
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'above',
|
|
||||||
'settings' => ['use_description_as_link_text' => 'true']
|
|
||||||
]);
|
|
||||||
|
|
||||||
$fields['created'] = BaseFieldDefinition::create('created')
|
$fields['created'] = BaseFieldDefinition::create('created')
|
||||||
->setLabel(t('Created on'))
|
->setLabel(t('Created on'))
|
||||||
@ -302,12 +318,13 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
|
|
||||||
|
|
||||||
$fields['total_fee'] = BaseFieldDefinition::create('decimal')
|
$fields['total_fee'] = BaseFieldDefinition::create('decimal')
|
||||||
->setLabel(t('Total Fee'))
|
->setLabel(t('Total Fee'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setSettings([
|
->setSettings([
|
||||||
'prefix' => '£',
|
'prefix' => '£',
|
||||||
])
|
])
|
||||||
->SetDisplayConfigurable("view", true);
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,10 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCase():\Drupal\opencase_cases\Entity\OCCase {
|
||||||
|
return \Drupal\opencase_cases\Entity\OCCase::load($this->oc_case->target_id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -206,21 +210,6 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
|||||||
->setSetting('target_type', 'user')
|
->setSetting('target_type', 'user')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'hidden',
|
|
||||||
'type' => 'author',
|
|
||||||
'weight' => 0,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'entity_reference_autocomplete',
|
|
||||||
'weight' => 5,
|
|
||||||
'settings' => [
|
|
||||||
'match_operator' => 'CONTAINS',
|
|
||||||
'size' => '60',
|
|
||||||
'autocomplete_type' => 'tags',
|
|
||||||
'placeholder' => '',
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->setDisplayConfigurable('form', TRUE)
|
->setDisplayConfigurable('form', TRUE)
|
||||||
->setDisplayConfigurable('view', TRUE);
|
->setDisplayConfigurable('view', TRUE);
|
||||||
|
|
||||||
@ -233,15 +222,6 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -4,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -4,
|
|
||||||
])
|
|
||||||
->setDisplayConfigurable('form', TRUE)
|
->setDisplayConfigurable('form', TRUE)
|
||||||
->setDisplayConfigurable('view', TRUE)
|
->setDisplayConfigurable('view', TRUE)
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
@ -272,10 +252,8 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
|||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setCardinality(1)
|
->setCardinality(1)
|
||||||
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
|
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable("view", true)
|
||||||
'type' => 'string',
|
->setDisplayConfigurable("form", true)
|
||||||
'weight' => 0,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['oc_fee_category'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
$fields['oc_fee_category'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||||
|
@ -77,7 +77,8 @@ use Drupal\user\UserInterface;
|
|||||||
* field_ui_base_route = "entity.oc_case_provision_type.edit_form"
|
* field_ui_base_route = "entity.oc_case_provision_type.edit_form"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvisionInterface {
|
class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvisionInterface
|
||||||
|
{
|
||||||
|
|
||||||
use EntityChangedTrait;
|
use EntityChangedTrait;
|
||||||
use EntityPublishedTrait;
|
use EntityPublishedTrait;
|
||||||
@ -85,7 +86,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
|
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
|
||||||
|
{
|
||||||
parent::preCreate($storage_controller, $values);
|
parent::preCreate($storage_controller, $values);
|
||||||
$values += [
|
$values += [
|
||||||
'user_id' => \Drupal::currentUser()->id(),
|
'user_id' => \Drupal::currentUser()->id(),
|
||||||
@ -95,13 +97,13 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function urlRouteParameters($rel) {
|
protected function urlRouteParameters($rel)
|
||||||
|
{
|
||||||
$uri_route_parameters = parent::urlRouteParameters($rel);
|
$uri_route_parameters = parent::urlRouteParameters($rel);
|
||||||
|
|
||||||
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
|
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
|
||||||
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
||||||
}
|
} elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
|
||||||
elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
|
|
||||||
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +113,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function preSave(EntityStorageInterface $storage) {
|
public function preSave(EntityStorageInterface $storage)
|
||||||
|
{
|
||||||
parent::preSave($storage);
|
parent::preSave($storage);
|
||||||
|
|
||||||
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
|
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
|
||||||
@ -133,14 +136,16 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->get('name')->value;
|
return $this->get('name')->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$this->set('name', $name);
|
$this->set('name', $name);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -148,14 +153,16 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCreatedTime() {
|
public function getCreatedTime()
|
||||||
|
{
|
||||||
return $this->get('created')->value;
|
return $this->get('created')->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setCreatedTime($timestamp) {
|
public function setCreatedTime($timestamp)
|
||||||
|
{
|
||||||
$this->set('created', $timestamp);
|
$this->set('created', $timestamp);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -163,21 +170,24 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getOwner() {
|
public function getOwner()
|
||||||
|
{
|
||||||
return $this->get('user_id')->entity;
|
return $this->get('user_id')->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getOwnerId() {
|
public function getOwnerId()
|
||||||
|
{
|
||||||
return $this->get('user_id')->target_id;
|
return $this->get('user_id')->target_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setOwnerId($uid) {
|
public function setOwnerId($uid)
|
||||||
|
{
|
||||||
$this->set('user_id', $uid);
|
$this->set('user_id', $uid);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -185,7 +195,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setOwner(UserInterface $account) {
|
public function setOwner(UserInterface $account)
|
||||||
|
{
|
||||||
$this->set('user_id', $account->id());
|
$this->set('user_id', $account->id());
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -193,7 +204,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
|
||||||
|
{
|
||||||
$fields = parent::baseFieldDefinitions($entity_type);
|
$fields = parent::baseFieldDefinitions($entity_type);
|
||||||
|
|
||||||
// Add the published field.
|
// Add the published field.
|
||||||
@ -206,21 +218,6 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
->setSetting('target_type', 'user')
|
->setSetting('target_type', 'user')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'hidden',
|
|
||||||
'type' => 'author',
|
|
||||||
'weight' => 0,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'entity_reference_autocomplete',
|
|
||||||
'weight' => 5,
|
|
||||||
'settings' => [
|
|
||||||
'match_operator' => 'CONTAINS',
|
|
||||||
'size' => '60',
|
|
||||||
'autocomplete_type' => 'tags',
|
|
||||||
'placeholder' => '',
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->setDisplayConfigurable('form', TRUE)
|
->setDisplayConfigurable('form', TRUE)
|
||||||
->setDisplayConfigurable('view', TRUE);
|
->setDisplayConfigurable('view', TRUE);
|
||||||
|
|
||||||
@ -233,23 +230,19 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -4,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -4,
|
|
||||||
])
|
|
||||||
->setDisplayConfigurable('form', TRUE)
|
->setDisplayConfigurable('form', TRUE)
|
||||||
->setDisplayConfigurable('view', TRUE)
|
->setDisplayConfigurable('view', TRUE)
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['status']->setDescription(t('A boolean indicating whether the Case Provision is published.'))
|
|
||||||
->setDisplayConfigurable('form', TRUE)
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setDisplayConfigurable('view', TRUE);
|
->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)
|
||||||
|
->setDisplayConfigurable('view', true)
|
||||||
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
|
|
||||||
$fields['created'] = BaseFieldDefinition::create('created')
|
$fields['created'] = BaseFieldDefinition::create('created')
|
||||||
->setLabel(t('Created'))
|
->setLabel(t('Created'))
|
||||||
@ -273,10 +266,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setCardinality(1)
|
->setCardinality(1)
|
||||||
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
|
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', TRUE)
|
||||||
'type' => 'string',
|
->setDisplayConfigurable('view', TRUE)
|
||||||
'weight' => 0,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['oc_provider'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
$fields['oc_provider'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||||
@ -296,7 +287,7 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['oc_case_provider_role'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
$fields['oc_case_provider_role'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Role'))
|
->setLabel(t('Role'))
|
||||||
->setSetting('target_type', 'taxonomy_term')
|
->setSetting('target_type', 'taxonomy_term')
|
||||||
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])
|
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])
|
||||||
|
@ -54,18 +54,9 @@ class OCCaseFeeForm extends ContentEntityForm {
|
|||||||
*/
|
*/
|
||||||
public function save(array $form, FormStateInterface $form_state) {
|
public function save(array $form, FormStateInterface $form_state) {
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
|
$entity->setNewRevision();
|
||||||
// Save as a new revision if requested to do so.
|
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = parent::save($form, $form_state);
|
$status = parent::save($form, $form_state);
|
||||||
|
|
||||||
|
@ -38,18 +38,9 @@ class OCCaseForm extends ContentEntityForm {
|
|||||||
*/
|
*/
|
||||||
public function save(array $form, FormStateInterface $form_state) {
|
public function save(array $form, FormStateInterface $form_state) {
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
|
$entity->setNewRevision();
|
||||||
// Save as a new revision if requested to do so.
|
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = parent::save($form, $form_state);
|
$status = parent::save($form, $form_state);
|
||||||
|
|
||||||
|
@ -54,18 +54,9 @@ class OCCaseProvisionForm extends ContentEntityForm {
|
|||||||
*/
|
*/
|
||||||
public function save(array $form, FormStateInterface $form_state) {
|
public function save(array $form, FormStateInterface $form_state) {
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
|
$entity->setNewRevision();
|
||||||
// Save as a new revision if requested to do so.
|
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = parent::save($form, $form_state);
|
$status = parent::save($form, $form_state);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ function opencase_entities_theme() {
|
|||||||
* so that it can be used as a default callback for an entity reference field.
|
* so that it can be used as a default callback for an entity reference field.
|
||||||
*/
|
*/
|
||||||
function opencase_entities_get($key) {
|
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\Component\Utility\Xss;
|
||||||
use Drupal\Core\Controller\ControllerBase;
|
use Drupal\Core\Controller\ControllerBase;
|
||||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||||
|
use Drupal\Core\Link;
|
||||||
use Drupal\Core\Url;
|
use Drupal\Core\Url;
|
||||||
use Drupal\opencase_entities\Entity\OCActivityInterface;
|
use Drupal\opencase_entities\Entity\OCActivityInterface;
|
||||||
|
|
||||||
@ -25,8 +26,8 @@ class OCActivityController extends ControllerBase implements ContainerInjectionI
|
|||||||
* An array suitable for drupal_render().
|
* An array suitable for drupal_render().
|
||||||
*/
|
*/
|
||||||
public function revisionShow($oc_activity_revision) {
|
public function revisionShow($oc_activity_revision) {
|
||||||
$oc_activity = $this->entityManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
$oc_activity = $this->entityTypeManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
||||||
$view_builder = $this->entityManager()->getViewBuilder('oc_activity');
|
$view_builder = $this->entityTypeManager()->getViewBuilder('oc_activity');
|
||||||
|
|
||||||
return $view_builder->view($oc_activity);
|
return $view_builder->view($oc_activity);
|
||||||
}
|
}
|
||||||
@ -41,8 +42,9 @@ class OCActivityController extends ControllerBase implements ContainerInjectionI
|
|||||||
* The page title.
|
* The page title.
|
||||||
*/
|
*/
|
||||||
public function revisionPageTitle($oc_activity_revision) {
|
public function revisionPageTitle($oc_activity_revision) {
|
||||||
$oc_activity = $this->entityManager()->getStorage('oc_activity')->loadRevision($oc_activity_revision);
|
$oc_activity = $this->entityTypeManager()->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())]);
|
$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();
|
$langname = $oc_activity->language()->getName();
|
||||||
$languages = $oc_activity->getTranslationLanguages();
|
$languages = $oc_activity->getTranslationLanguages();
|
||||||
$has_translations = (count($languages) > 1);
|
$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()]);
|
$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')];
|
$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.
|
// Use revision link to link to revisions that are not active.
|
||||||
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
|
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
|
||||||
if ($vid != $oc_activity->getRevisionId()) {
|
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 {
|
else {
|
||||||
$link = $oc_activity->link($date);
|
$link = $oc_activity->toLink($date)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = [];
|
$row = [];
|
||||||
|
@ -118,10 +118,11 @@ class OCOrganisationController extends ControllerBase implements ContainerInject
|
|||||||
// Use revision link to link to revisions that are not active.
|
// Use revision link to link to revisions that are not active.
|
||||||
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
|
||||||
if ($vid != $oc_organisation->getRevisionId()) {
|
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' => $oc_organisation->id(),
|
||||||
'oc_organisation_revision' => $vid,
|
'oc_organisation_revision' => $vid,
|
||||||
]));
|
]);
|
||||||
|
$link = \Drupal\Core\Link::fromTextAndUrl($date,$url)->toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$link = $oc_organisation->toLink($date)->toString();
|
$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.')
|
->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)
|
->setRevisionable(TRUE)
|
||||||
->setDisplayConfigurable('form', TRUE)
|
->setDisplayConfigurable('form', TRUE)
|
||||||
|
->setDisplayConfigurable('view', true)
|
||||||
->setDefaultValue(TRUE);
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||||
@ -277,10 +278,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setDisplayConfigurable('view', true)
|
->setDisplayConfigurable('view', true)
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', TRUE);
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'author',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$fields['name'] = BaseFieldDefinition::create('string')
|
$fields['name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Subject'))
|
->setLabel(t('Subject'))
|
||||||
@ -292,15 +290,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayConfigurable('view', true)
|
->setDisplayConfigurable('view', true)
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'hidden',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -3,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -3,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['description'] = BaseFieldDefinition::create('string_long')
|
$fields['description'] = BaseFieldDefinition::create('string_long')
|
||||||
@ -310,7 +299,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
'max_length' => 50,
|
'max_length' => 50,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayConfigurable('view', true)
|
->setDisplayConfigurable('view', true)
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
@ -322,15 +310,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
'suffix' => 'minutes',
|
'suffix' => 'minutes',
|
||||||
])
|
])
|
||||||
->SetDisplayConfigurable("form", true)
|
->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')
|
$fields['created'] = BaseFieldDefinition::create('created')
|
||||||
->setLabel(t('Created'))
|
->setLabel(t('Created'))
|
||||||
|
@ -122,7 +122,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
$name = $this->get('first_name')->value . ' ';
|
$name = $this->get('first_name')->value . ' ';
|
||||||
if ($this->get('middle_names')->value) $name .= $this->get('middle_names')->value . ' ';
|
if ($this->get('middle_names')->value) $name .= $this->get('middle_names')->value . ' ';
|
||||||
$name .= $this->get('last_name')->value . ' ';
|
$name .= $this->get('last_name')->value . ' ';
|
||||||
|
|
||||||
$this->setName($name);
|
$this->setName($name);
|
||||||
|
|
||||||
// If no revision author has been set explicitly, make the oc_actor owner the
|
// If no revision author has been set explicitly, make the oc_actor owner the
|
||||||
@ -218,6 +218,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->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.')
|
->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)
|
->setRevisionable(TRUE)
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
|
->setDisplayConfigurable("view", true)
|
||||||
->setDefaultValue(TRUE);
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
// The name gets set on preSave, from the first middle and last
|
// The name gets set on preSave, from the first middle and last
|
||||||
@ -226,7 +227,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->setSettings([
|
->setSettings([
|
||||||
'max_length' => 100,
|
'max_length' => 100,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Entered by'))
|
->setLabel(t('Entered by'))
|
||||||
@ -234,6 +235,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setSetting('target_type', 'user')
|
->setSetting('target_type', 'user')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
|
->setDisplayConfigurable("form", true)
|
||||||
|
->setDisplayConfigurable("view", true)
|
||||||
->setTranslatable(TRUE);
|
->setTranslatable(TRUE);
|
||||||
|
|
||||||
$fields['first_name'] = BaseFieldDefinition::create('string')
|
$fields['first_name'] = BaseFieldDefinition::create('string')
|
||||||
@ -247,10 +250,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true)
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -100,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['middle_names'] = BaseFieldDefinition::create('string')
|
$fields['middle_names'] = BaseFieldDefinition::create('string')
|
||||||
@ -264,10 +263,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true)
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -99,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
|
|
||||||
$fields['last_name'] = BaseFieldDefinition::create('string')
|
$fields['last_name'] = BaseFieldDefinition::create('string')
|
||||||
@ -281,10 +276,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -98,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
// Contact details.
|
// Contact details.
|
||||||
@ -297,16 +288,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true);
|
||||||
->setDisplayOptions('view', array(
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -5,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -5,
|
|
||||||
));
|
|
||||||
$fields['phone'] = BaseFieldDefinition::create('string')
|
$fields['phone'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Main Phone Number'))
|
->setLabel(t('Main Phone Number'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
@ -316,16 +298,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true);
|
||||||
->setDisplayOptions('view', array(
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -4,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -4,
|
|
||||||
));
|
|
||||||
$fields['phone2'] = BaseFieldDefinition::create('string')
|
$fields['phone2'] = BaseFieldDefinition::create('string')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Alternative Phone Number'))
|
->setLabel(t('Alternative Phone Number'))
|
||||||
@ -335,16 +308,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true);
|
||||||
->setDisplayOptions('view', array(
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -3,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -3,
|
|
||||||
));
|
|
||||||
$fields['postal_address'] = BaseFieldDefinition::create('string_long')
|
$fields['postal_address'] = BaseFieldDefinition::create('string_long')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Postal Address'))
|
->setLabel(t('Postal Address'))
|
||||||
@ -355,16 +319,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true);
|
||||||
->setDisplayOptions('view', array(
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'basic_string',
|
|
||||||
'weight' => -2,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textarea',
|
|
||||||
'weight' => -2,
|
|
||||||
));
|
|
||||||
$fields['post_code'] = BaseFieldDefinition::create('string')
|
$fields['post_code'] = BaseFieldDefinition::create('string')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Post Code'))
|
->setLabel(t('Post Code'))
|
||||||
@ -374,16 +329,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true)
|
->setDisplayConfigurable("view", true);
|
||||||
->setDisplayOptions('view', array(
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -1,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -1,
|
|
||||||
));
|
|
||||||
|
|
||||||
$fields['created'] = BaseFieldDefinition::create('created')
|
$fields['created'] = BaseFieldDefinition::create('created')
|
||||||
->setLabel(t('Created'))
|
->setLabel(t('Created'))
|
||||||
@ -400,13 +346,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setTranslatable(TRUE);
|
->setTranslatable(TRUE);
|
||||||
|
|
||||||
$fields['user_login'] = BaseFieldDefinition::create('boolean')
|
|
||||||
->setLabel(t('Login Access'))
|
|
||||||
->setDescription(t('Whether this person should be able to log into the system.'))
|
|
||||||
->setDisplayConfigurable('form', true)
|
|
||||||
->setDisplayConfigurable('display', true)
|
|
||||||
->setDefaultValue(FALSE);
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,9 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
|||||||
->setSettings([
|
->setSettings([
|
||||||
'max_length' => 50,
|
'max_length' => 50,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
]);
|
])
|
||||||
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true);
|
||||||
|
|
||||||
$fields['oc_actor'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
$fields['oc_actor'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Person'))
|
->setLabel(t('Person'))
|
||||||
@ -120,14 +122,8 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
|||||||
->setSetting('target_type', 'oc_actor')
|
->setSetting('target_type', 'oc_actor')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setCardinality(1)
|
->setCardinality(1)
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'type' => 'string',
|
->setDisplayConfigurable('view', true)
|
||||||
'weight' => -100,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'entity_reference_autocomplete_tags',
|
|
||||||
'weight' => -100,
|
|
||||||
])
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['age'] = BaseFieldDefinition::create('list_string')
|
$fields['age'] = BaseFieldDefinition::create('list_string')
|
||||||
@ -144,27 +140,13 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -5,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'options_select',
|
|
||||||
'weight' => -5,
|
|
||||||
));
|
|
||||||
$fields['access_needs'] = BaseFieldDefinition::create('string_long')
|
$fields['access_needs'] = BaseFieldDefinition::create('string_long')
|
||||||
->setLabel(t('Access Needs'))
|
->setLabel(t('Access Needs'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -4,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_long',
|
|
||||||
'weight' => -4,
|
|
||||||
));
|
|
||||||
$fields['gender'] = BaseFieldDefinition::create('list_string')
|
$fields['gender'] = BaseFieldDefinition::create('list_string')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Gender'))
|
->setLabel(t('Gender'))
|
||||||
@ -180,15 +162,7 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('view', true);
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -5,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'options_select',
|
|
||||||
'weight' => -5,
|
|
||||||
));
|
|
||||||
$fields['race_ethnicity'] = BaseFieldDefinition::create('list_string')
|
$fields['race_ethnicity'] = BaseFieldDefinition::create('list_string')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Race/Ethnicity'))
|
->setLabel(t('Race/Ethnicity'))
|
||||||
@ -215,15 +189,7 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('view', true);
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -5,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'options_select',
|
|
||||||
'weight' => -5,
|
|
||||||
));
|
|
||||||
$fields['sexuality'] = BaseFieldDefinition::create('string')
|
$fields['sexuality'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Sexuality'))
|
->setLabel(t('Sexuality'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
@ -231,18 +197,9 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
|||||||
'max_length' => 20,
|
'max_length' => 20,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable("form", true)
|
|
||||||
->setDisplayConfigurable("view", true)
|
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -1,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$fields['status']->setDescription(t('A boolean indicating whether the Equal Opps is published.'));
|
$fields['status']->setDescription(t('A boolean indicating whether the Equal Opps is published.'));
|
||||||
|
|
||||||
|
@ -149,7 +149,9 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
|||||||
->setDescription(t('The user ID of author of the Event entity.'))
|
->setDescription(t('The user ID of author of the Event entity.'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setSetting('target_type', 'user')
|
->setSetting('target_type', 'user')
|
||||||
->setSetting('handler', 'default');
|
->setSetting('handler', 'default')
|
||||||
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true);
|
||||||
|
|
||||||
$fields['name'] = BaseFieldDefinition::create('string')
|
$fields['name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Name'))
|
->setLabel(t('Name'))
|
||||||
@ -163,15 +165,16 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
|||||||
'type' => 'string_textfield',
|
'type' => 'string_textfield',
|
||||||
'weight' => -4,
|
'weight' => -4,
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable('form', TRUE)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayConfigurable('view', TRUE)
|
->setDisplayConfigurable('view', true)
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setLabel(t('Visible'))
|
->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.')
|
->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)
|
->setRevisionable(TRUE)
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true)
|
||||||
->setDefaultValue(TRUE);
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
|
|
||||||
@ -190,18 +193,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
|||||||
->setRequired(TRUE)
|
->setRequired(TRUE)
|
||||||
// Uses the currentDateTime function from the Activity entity
|
// Uses the currentDateTime function from the Activity entity
|
||||||
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
|
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'datetime_default',
|
|
||||||
'settings' => [
|
|
||||||
'format_type' => 'medium',
|
|
||||||
],
|
|
||||||
'weight' => -3,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'datetime_default',
|
|
||||||
'weight' => -3,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$fields['description'] = BaseFieldDefinition::create('string_long')
|
$fields['description'] = BaseFieldDefinition::create('string_long')
|
||||||
->setLabel(t('Description'))
|
->setLabel(t('Description'))
|
||||||
@ -211,15 +204,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'basic_string',
|
|
||||||
'weight' => -1,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textarea',
|
|
||||||
'weight' => -1,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
|
|
||||||
$fields['attendees'] = BaseFieldDefinition::create('entity_reference')
|
$fields['attendees'] = BaseFieldDefinition::create('entity_reference')
|
||||||
@ -229,14 +215,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
|||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
|
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'type' => 'string',
|
->setDisplayConfigurable('view', true)
|
||||||
'weight' => 50,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'entity_reference_autocomplete_tags',
|
|
||||||
'weight' => 50,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,19 +204,12 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
$fields['notes'] = BaseFieldDefinition::create('string_long')
|
$fields['notes'] = BaseFieldDefinition::create('string_long')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Notes'))
|
->setLabel(t('Notes'))
|
||||||
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true)
|
||||||
->setSettings(array(
|
->setSettings(array(
|
||||||
'default_value' => '',
|
'default_value' => '',
|
||||||
'max_length' => 255,
|
'max_length' => 255,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
|
||||||
->setDisplayOptions('view', array(
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'basic_string',
|
|
||||||
'weight' => 50,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textarea',
|
|
||||||
'weight' => 50,
|
|
||||||
));
|
));
|
||||||
$fields['website'] = BaseFieldDefinition::create('string')
|
$fields['website'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Website'))
|
->setLabel(t('Website'))
|
||||||
@ -226,15 +219,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 49,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 49,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
$fields['contact_name'] = BaseFieldDefinition::create('string')
|
$fields['contact_name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Contact Name'))
|
->setLabel(t('Contact Name'))
|
||||||
@ -245,15 +231,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 51,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 51,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
|
|
||||||
$fields['contact_role'] = BaseFieldDefinition::create('string')
|
$fields['contact_role'] = BaseFieldDefinition::create('string')
|
||||||
@ -265,15 +244,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 52,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 52,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
$fields['email'] = BaseFieldDefinition::create('string')
|
$fields['email'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Email Address'))
|
->setLabel(t('Email Address'))
|
||||||
@ -283,15 +255,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 100,
|
'max_length' => 100,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 52,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 52,
|
|
||||||
));
|
|
||||||
|
|
||||||
$fields['phone'] = BaseFieldDefinition::create('string')
|
$fields['phone'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Phone Number'))
|
->setLabel(t('Phone Number'))
|
||||||
@ -301,15 +266,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 20,
|
'max_length' => 20,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 53,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 53,
|
|
||||||
));
|
|
||||||
$fields['postal_address'] = BaseFieldDefinition::create('string_long')
|
$fields['postal_address'] = BaseFieldDefinition::create('string_long')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Postal Address'))
|
->setLabel(t('Postal Address'))
|
||||||
@ -319,15 +277,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 255,
|
'max_length' => 255,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'basic_string',
|
|
||||||
'weight' => 54,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textarea',
|
|
||||||
'weight' => 54,
|
|
||||||
));
|
|
||||||
$fields['post_code'] = BaseFieldDefinition::create('string')
|
$fields['post_code'] = BaseFieldDefinition::create('string')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Post Code'))
|
->setLabel(t('Post Code'))
|
||||||
@ -336,15 +287,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 10,
|
'max_length' => 10,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 55,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 55,
|
|
||||||
));
|
|
||||||
$fields['billing_contact_name'] = BaseFieldDefinition::create('string')
|
$fields['billing_contact_name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Billing Contact Name'))
|
->setLabel(t('Billing Contact Name'))
|
||||||
->setDescription(t('Name of the main contact for this client.'))
|
->setDescription(t('Name of the main contact for this client.'))
|
||||||
@ -354,15 +298,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 56,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 56,
|
|
||||||
])
|
|
||||||
->setRequired(FALSE);
|
->setRequired(FALSE);
|
||||||
|
|
||||||
$fields['billing_email'] = BaseFieldDefinition::create('string')
|
$fields['billing_email'] = BaseFieldDefinition::create('string')
|
||||||
@ -373,15 +310,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 100,
|
'max_length' => 100,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 57,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 57,
|
|
||||||
));
|
|
||||||
|
|
||||||
$fields['billing_phone'] = BaseFieldDefinition::create('string')
|
$fields['billing_phone'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Billing Phone Number'))
|
->setLabel(t('Billing Phone Number'))
|
||||||
@ -391,15 +321,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 20,
|
'max_length' => 20,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 58,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 58,
|
|
||||||
));
|
|
||||||
$fields['billing_postal_address'] = BaseFieldDefinition::create('string_long')
|
$fields['billing_postal_address'] = BaseFieldDefinition::create('string_long')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Billing Postal Address'))
|
->setLabel(t('Billing Postal Address'))
|
||||||
@ -409,15 +332,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 255,
|
'max_length' => 255,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'basic_string',
|
|
||||||
'weight' => 59,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textarea',
|
|
||||||
'weight' => 59,
|
|
||||||
));
|
|
||||||
$fields['billing_post_code'] = BaseFieldDefinition::create('string')
|
$fields['billing_post_code'] = BaseFieldDefinition::create('string')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setLabel(t('Billing Post Code'))
|
->setLabel(t('Billing Post Code'))
|
||||||
@ -426,15 +342,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'max_length' => 10,
|
'max_length' => 10,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
))
|
))
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'above',
|
->setDisplayConfigurable('view', true);
|
||||||
'type' => 'string',
|
|
||||||
'weight' => 60,
|
|
||||||
))
|
|
||||||
->setDisplayOptions('form', array(
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => 60,
|
|
||||||
));
|
|
||||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Added by'))
|
->setLabel(t('Added by'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
@ -450,24 +359,16 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
|||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
])
|
])
|
||||||
->setDefaultValue('')
|
->setDefaultValue('')
|
||||||
->setDisplayOptions('view', [
|
->setDisplayConfigurable('form', true)
|
||||||
'label' => 'hidden',
|
->setDisplayConfigurable('view', true)
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -100,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -100,
|
|
||||||
])
|
|
||||||
->setDisplayConfigurable('form', TRUE)
|
|
||||||
->setDisplayConfigurable('view', TRUE)
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setLabel(t('Visible'))
|
->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.')
|
->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)
|
->setRevisionable(TRUE)
|
||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true)
|
||||||
->setDefaultValue(TRUE);
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,18 +38,9 @@ class OCActivityForm extends ContentEntityForm {
|
|||||||
*/
|
*/
|
||||||
public function save(array $form, FormStateInterface $form_state) {
|
public function save(array $form, FormStateInterface $form_state) {
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
|
$entity->setNewRevision();
|
||||||
// Save as a new revision if requested to do so.
|
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = parent::save($form, $form_state);
|
$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 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')) {
|
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.', [
|
\Drupal::messenger()->addMessage($this->t('The %bundle is now unpublished & hidden from you.', [
|
||||||
'%bundle' => $entity->bundle(),
|
'%bundle' => $entity->bundle(),
|
||||||
]));
|
]));
|
||||||
$form_state->setRedirect('<front>');
|
$form_state->setRedirect('<front>');
|
||||||
|
@ -38,8 +38,6 @@ class OCActorForm extends ContentEntityForm {
|
|||||||
*/
|
*/
|
||||||
public function save(array $form, FormStateInterface $form_state) {
|
public function save(array $form, FormStateInterface $form_state) {
|
||||||
$entity = $this->entity;
|
$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->setNewRevision();
|
||||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||||
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||||
|
@ -54,18 +54,9 @@ class OCOrganisationForm extends ContentEntityForm {
|
|||||||
*/
|
*/
|
||||||
public function save(array $form, FormStateInterface $form_state) {
|
public function save(array $form, FormStateInterface $form_state) {
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
|
$entity->setNewRevision();
|
||||||
// Save as a new revision if requested to do so.
|
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||||
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) {
|
$entity->setRevisionUserId(\Drupal::currentUser()->id());
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = parent::save($form, $form_state);
|
$status = parent::save($form, $form_state);
|
||||||
|
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
opencase.see_all:
|
opencase.see_all:
|
||||||
title: 'See all...'
|
title: 'See all...'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
route_name: opencase.opencase_cases_menu
|
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.see_all_events_links: //@TODO findout why "view.events.page_1" does not work
|
||||||
|
# class: Drupal\opencase\Plugin\Menu\SeeAllEventsMenuLink
|
||||||
|
# deriver: Drupal\opencase\Plugin\Derivative\SeeAllEventsMenuLink
|
||||||
|
# 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
|
||||||
route_name: opencase.opencase_add_new_things_menu
|
route_name: opencase.opencase_add_new_things_menu
|
||||||
weight: 1
|
weight: 1
|
||||||
opencase.add_people_links:
|
opencase.add_people_links:
|
||||||
@ -33,45 +48,64 @@ opencase.opencase_admin_menu:
|
|||||||
title: 'Administration'
|
title: 'Administration'
|
||||||
description: 'Management and Configuration'
|
description: 'Management and Configuration'
|
||||||
route_name: opencase.opencase_admin_menu
|
route_name: opencase.opencase_admin_menu
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
weight: 100
|
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:
|
opencase.manage_user_logins:
|
||||||
title: 'Manage user logins'
|
title: 'Manage user logins'
|
||||||
description: 'Manage who can access the system'
|
description: 'Manage who can access the system'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
parent: opencase.opencase_admin_menu
|
parent: opencase.opencase_admin_menu
|
||||||
url: internal:/admin/people
|
url: internal:/admin/people
|
||||||
weight: 0
|
weight: 0
|
||||||
opencase.manage_organisation_types:
|
opencase.manage_organisation_types:
|
||||||
title: 'Manage organisation types'
|
title: 'Manage organisation types'
|
||||||
description: 'Configure types of people and their fields'
|
description: 'Configure types of people and their fields'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
parent: opencase.opencase_admin_menu
|
parent: opencase.opencase_admin_menu
|
||||||
url: internal:/admin/opencase/oc_organisation_type
|
url: internal:/admin/opencase/oc_organisation_type
|
||||||
weight: 1
|
weight: 1
|
||||||
opencase.manage_person_types:
|
opencase.manage_person_types:
|
||||||
title: 'Manage person types'
|
title: 'Manage person types'
|
||||||
description: 'Configure types of people and their fields'
|
description: 'Configure types of people and their fields'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
parent: opencase.opencase_admin_menu
|
parent: opencase.opencase_admin_menu
|
||||||
url: internal:/admin/opencase/oc_actor_type
|
url: internal:/admin/opencase/oc_actor_type
|
||||||
weight: 1
|
weight: 1
|
||||||
opencase.manage_activity_types:
|
opencase.manage_activity_types:
|
||||||
title: 'Manage activity types'
|
title: 'Manage activity types'
|
||||||
description: 'Configure types of activities and their fields'
|
description: 'Configure types of activities and their fields'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
parent: opencase.opencase_admin_menu
|
parent: opencase.opencase_admin_menu
|
||||||
url: internal:/admin/opencase/oc_activity_type
|
url: internal:/admin/opencase/oc_activity_type
|
||||||
weight: 3
|
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:
|
opencase.manage_event_types:
|
||||||
title: 'Manage event types'
|
title: 'Manage event types'
|
||||||
description: 'Configure types of people and their fields'
|
description: 'Configure types of people and their fields'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
parent: opencase.opencase_admin_menu
|
parent: opencase.opencase_admin_menu
|
||||||
url: internal:/admin/opencase/oc_event_type
|
url: internal:/admin/opencase/oc_event_type
|
||||||
weight: 1
|
weight: 1
|
||||||
opencase.reporting:
|
opencase.reporting:
|
||||||
title: 'Reporting'
|
title: 'Reporting'
|
||||||
menu_name: opencase
|
menu_name: opencase
|
||||||
route_name: opencase.opencase_reporting_menu
|
route_name: opencase.opencase_reporting_menu
|
||||||
weight: 0
|
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;
|
||||||
|
}
|
||||||
|
}
|
60
src/Plugin/Derivative/SeeAllEventsMenuLink.php
Normal file
60
src/Plugin/Derivative/SeeAllEventsMenuLink.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\opencase\Plugin\Derivative;
|
||||||
|
|
||||||
|
use Drupal\Component\Plugin\Derivative\DeriverBase;
|
||||||
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||||
|
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Derivative class that provides the menu links adding various types of events
|
||||||
|
* */
|
||||||
|
class SeeAllEventsMenuLink 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 = [];
|
||||||
|
$eventTypes = $this->entityTypeManager->getStorage('oc_event_type')->loadMultiple();
|
||||||
|
foreach ($eventTypes as $id => $eventType) {
|
||||||
|
$links[$id] = [
|
||||||
|
'title' => $eventType->label(),
|
||||||
|
'route_name' => "view.events.page_1",
|
||||||
|
'route_parameters' => ['type' => $eventType->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/SeeAllEventsMenuLink.php
Normal file
9
src/Plugin/Menu/SeeAllEventsMenuLink.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 Events of various types.
|
||||||
|
*/
|
||||||
|
class SeeAllEventsMenuLink 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 {}
|
Reference in New Issue
Block a user