Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
86c0fb1f65 | |||
92bce34fb1 | |||
02715bdc44 | |||
4ab621100f | |||
aa0c350766 | |||
17406061f9 | |||
489f4c0c94 | |||
2f06caa261 | |||
aa6d580d62 | |||
8c3f2bcbc3 | |||
55f34cb4d7 | |||
20ed3d4f39 |
@ -96,36 +96,19 @@ function opencase_cases_get_activities(Drupal\opencase_cases\entity\OCCase $case
|
||||
return $activities;
|
||||
}
|
||||
|
||||
function opencase_cases_get_amount(Drupal\opencase_cases\entity\OCCaseFee $case_fee): string {
|
||||
if (!isEmpty($case_fee->amount)) return $case_fee->amount->first()->value;
|
||||
else return '0';
|
||||
}
|
||||
|
||||
function opencase_cases_get_case(Drupal\opencase_cases\entity\OCCaseFee $case_fee): Drupal\opencase_cases\entity\OCCase {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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) {
|
||||
|
@ -75,14 +75,16 @@ use Drupal\user\UserInterface;
|
||||
* field_ui_base_route = "entity.oc_case_type.edit_form"
|
||||
* )
|
||||
*/
|
||||
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||
{
|
||||
|
||||
use EntityChangedTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
|
||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
|
||||
{
|
||||
parent::preCreate($storage_controller, $values);
|
||||
$values += [
|
||||
'user_id' => \Drupal::currentUser()->id(),
|
||||
@ -90,7 +92,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
}
|
||||
|
||||
|
||||
public static function defaultTarget() {
|
||||
public static function defaultTarget()
|
||||
{
|
||||
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
|
||||
else return [];
|
||||
}
|
||||
@ -98,13 +101,13 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function urlRouteParameters($rel) {
|
||||
protected function urlRouteParameters($rel)
|
||||
{
|
||||
$uri_route_parameters = parent::urlRouteParameters($rel);
|
||||
|
||||
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
|
||||
$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();
|
||||
}
|
||||
|
||||
@ -114,7 +117,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preSave(EntityStorageInterface $storage) {
|
||||
public function preSave(EntityStorageInterface $storage)
|
||||
{
|
||||
parent::preSave($storage);
|
||||
|
||||
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
|
||||
@ -136,14 +140,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName()
|
||||
{
|
||||
return $this->get('name')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name) {
|
||||
public function setName($name)
|
||||
{
|
||||
$this->set('name', $name);
|
||||
return $this;
|
||||
}
|
||||
@ -151,14 +157,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedTime() {
|
||||
public function getCreatedTime()
|
||||
{
|
||||
return $this->get('created')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCreatedTime($timestamp) {
|
||||
public function setCreatedTime($timestamp)
|
||||
{
|
||||
$this->set('created', $timestamp);
|
||||
return $this;
|
||||
}
|
||||
@ -166,21 +174,24 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() {
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->get('user_id')->entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwnerId() {
|
||||
public function getOwnerId()
|
||||
{
|
||||
return $this->get('user_id')->target_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOwnerId($uid) {
|
||||
public function setOwnerId($uid)
|
||||
{
|
||||
$this->set('user_id', $uid);
|
||||
return $this;
|
||||
}
|
||||
@ -188,7 +199,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOwner(UserInterface $account) {
|
||||
public function setOwner(UserInterface $account)
|
||||
{
|
||||
$this->set('user_id', $account->id());
|
||||
return $this;
|
||||
}
|
||||
@ -196,24 +208,30 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isPublished() {
|
||||
public function isPublished()
|
||||
{
|
||||
return (bool)$this->getEntityKey('status');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPublished($published) {
|
||||
public function setPublished($published)
|
||||
{
|
||||
$this->set('status', $published ? TRUE : FALSE);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function addToTotalFee(float $amountToAdd): void {
|
||||
$this->set('total_fee', $this->total_fee->value + $amountToAdd);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
|
||||
{
|
||||
$fields = parent::baseFieldDefinitions($entity_type);
|
||||
|
||||
// not currently used. Will add form and view settings when ready
|
||||
@ -221,7 +239,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
->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('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||
@ -232,12 +251,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
->setSetting('handler', 'default')
|
||||
->setTranslatable(TRUE)
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'author',
|
||||
'weight' => 80,
|
||||
]);
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
|
||||
$fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
|
||||
@ -257,14 +271,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'hidden',
|
||||
'type' => 'string',
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -100,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(TRUE);
|
||||
|
||||
|
||||
@ -278,18 +286,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
->setSetting('uri_scheme', 'private')
|
||||
->setCardinality(-1)
|
||||
->setDisplayConfigurable('form', 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']
|
||||
]);
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['created'] = BaseFieldDefinition::create('created')
|
||||
->setLabel(t('Created on'))
|
||||
@ -326,7 +323,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||
->setSettings([
|
||||
'prefix' => '£',
|
||||
])
|
||||
->SetDisplayConfigurable("view", true);
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
@ -190,6 +190,10 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCase():\Drupal\opencase_cases\Entity\OCCase {
|
||||
return \Drupal\opencase_cases\Entity\OCCase::load($this->oc_case->target_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -206,21 +210,6 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
||||
->setSetting('target_type', 'user')
|
||||
->setSetting('handler', 'default')
|
||||
->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('view', TRUE);
|
||||
|
||||
@ -233,15 +222,6 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -4,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -4,
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setRequired(TRUE);
|
||||
|
@ -77,7 +77,8 @@ use Drupal\user\UserInterface;
|
||||
* 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 EntityPublishedTrait;
|
||||
@ -85,7 +86,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
|
||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
|
||||
{
|
||||
parent::preCreate($storage_controller, $values);
|
||||
$values += [
|
||||
'user_id' => \Drupal::currentUser()->id(),
|
||||
@ -95,13 +97,13 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function urlRouteParameters($rel) {
|
||||
protected function urlRouteParameters($rel)
|
||||
{
|
||||
$uri_route_parameters = parent::urlRouteParameters($rel);
|
||||
|
||||
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
|
||||
$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();
|
||||
}
|
||||
|
||||
@ -111,7 +113,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preSave(EntityStorageInterface $storage) {
|
||||
public function preSave(EntityStorageInterface $storage)
|
||||
{
|
||||
parent::preSave($storage);
|
||||
|
||||
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
|
||||
@ -133,14 +136,16 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName()
|
||||
{
|
||||
return $this->get('name')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name) {
|
||||
public function setName($name)
|
||||
{
|
||||
$this->set('name', $name);
|
||||
return $this;
|
||||
}
|
||||
@ -148,14 +153,16 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedTime() {
|
||||
public function getCreatedTime()
|
||||
{
|
||||
return $this->get('created')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCreatedTime($timestamp) {
|
||||
public function setCreatedTime($timestamp)
|
||||
{
|
||||
$this->set('created', $timestamp);
|
||||
return $this;
|
||||
}
|
||||
@ -163,21 +170,24 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() {
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->get('user_id')->entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwnerId() {
|
||||
public function getOwnerId()
|
||||
{
|
||||
return $this->get('user_id')->target_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOwnerId($uid) {
|
||||
public function setOwnerId($uid)
|
||||
{
|
||||
$this->set('user_id', $uid);
|
||||
return $this;
|
||||
}
|
||||
@ -185,7 +195,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOwner(UserInterface $account) {
|
||||
public function setOwner(UserInterface $account)
|
||||
{
|
||||
$this->set('user_id', $account->id());
|
||||
return $this;
|
||||
}
|
||||
@ -193,7 +204,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
|
||||
{
|
||||
$fields = parent::baseFieldDefinitions($entity_type);
|
||||
|
||||
// Add the published field.
|
||||
@ -206,21 +218,6 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
->setSetting('target_type', 'user')
|
||||
->setSetting('handler', 'default')
|
||||
->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('view', TRUE);
|
||||
|
||||
@ -233,15 +230,6 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -4,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -4,
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setRequired(TRUE);
|
||||
@ -251,7 +239,8 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
||||
->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('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_cases\Helper;
|
||||
|
||||
class HookHelper {
|
||||
public static function onCaseFeeUpdate(\Drupal\opencase_cases\Entity\OCCaseFee $caseFee) {
|
||||
|
||||
}
|
||||
}
|
@ -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.')
|
||||
->setRevisionable(TRUE)
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
// The name gets set on preSave, from the first middle and last
|
||||
@ -234,6 +235,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
->setRevisionable(TRUE)
|
||||
->setSetting('target_type', 'user')
|
||||
->setSetting('handler', 'default')
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setTranslatable(TRUE);
|
||||
|
||||
$fields['first_name'] = BaseFieldDefinition::create('string')
|
||||
@ -247,10 +250,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -100,
|
||||
])
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['middle_names'] = BaseFieldDefinition::create('string')
|
||||
@ -264,10 +263,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -99,
|
||||
])
|
||||
->setRequired(FALSE);
|
||||
|
||||
$fields['last_name'] = BaseFieldDefinition::create('string')
|
||||
@ -281,10 +276,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -98,
|
||||
])
|
||||
->setRequired(TRUE);
|
||||
|
||||
// Contact details.
|
||||
@ -297,16 +288,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -5,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -5,
|
||||
));
|
||||
->setDisplayConfigurable("view", true);
|
||||
$fields['phone'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Main Phone Number'))
|
||||
->setRevisionable(TRUE)
|
||||
@ -316,16 +298,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -4,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -4,
|
||||
));
|
||||
->setDisplayConfigurable("view", true);
|
||||
$fields['phone2'] = BaseFieldDefinition::create('string')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Alternative Phone Number'))
|
||||
@ -335,16 +308,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -3,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -3,
|
||||
));
|
||||
->setDisplayConfigurable("view", true);
|
||||
$fields['postal_address'] = BaseFieldDefinition::create('string_long')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Postal Address'))
|
||||
@ -355,16 +319,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'basic_string',
|
||||
'weight' => -2,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textarea',
|
||||
'weight' => -2,
|
||||
));
|
||||
->setDisplayConfigurable("view", true);
|
||||
$fields['post_code'] = BaseFieldDefinition::create('string')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Post Code'))
|
||||
@ -374,16 +329,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -1,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -1,
|
||||
));
|
||||
->setDisplayConfigurable("view", true);
|
||||
|
||||
$fields['created'] = BaseFieldDefinition::create('created')
|
||||
->setLabel(t('Created'))
|
||||
@ -400,13 +346,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
->setRevisionable(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;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,9 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
||||
->setSettings([
|
||||
'max_length' => 50,
|
||||
'text_processing' => 0,
|
||||
]);
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['oc_actor'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Person'))
|
||||
@ -120,14 +122,8 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
||||
->setSetting('target_type', 'oc_actor')
|
||||
->setSetting('handler', 'default')
|
||||
->setCardinality(1)
|
||||
->setDisplayOptions('view', [
|
||||
'type' => 'string',
|
||||
'weight' => -100,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'entity_reference_autocomplete_tags',
|
||||
'weight' => -100,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['age'] = BaseFieldDefinition::create('list_string')
|
||||
@ -144,27 +140,13 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
||||
],
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -5,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'options_select',
|
||||
'weight' => -5,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['access_needs'] = BaseFieldDefinition::create('string_long')
|
||||
->setLabel(t('Access Needs'))
|
||||
->setRevisionable(TRUE)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -4,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_long',
|
||||
'weight' => -4,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['gender'] = BaseFieldDefinition::create('list_string')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Gender'))
|
||||
@ -180,15 +162,7 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
||||
],
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -5,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'options_select',
|
||||
'weight' => -5,
|
||||
));
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['race_ethnicity'] = BaseFieldDefinition::create('list_string')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Race/Ethnicity'))
|
||||
@ -215,15 +189,7 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
||||
],
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -5,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'options_select',
|
||||
'weight' => -5,
|
||||
));
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['sexuality'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Sexuality'))
|
||||
->setRevisionable(TRUE)
|
||||
@ -231,18 +197,9 @@ class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
|
||||
'max_length' => 20,
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable("view", true)
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => -1,
|
||||
))
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -1,
|
||||
]);
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$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.'))
|
||||
->setRevisionable(TRUE)
|
||||
->setSetting('target_type', 'user')
|
||||
->setSetting('handler', 'default');
|
||||
->setSetting('handler', 'default')
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Name'))
|
||||
@ -163,15 +165,16 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -4,
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Visible'))
|
||||
->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.')
|
||||
->setRevisionable(TRUE)
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
|
||||
@ -190,18 +193,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
||||
->setRequired(TRUE)
|
||||
// Uses the currentDateTime function from the Activity entity
|
||||
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'datetime_default',
|
||||
'settings' => [
|
||||
'format_type' => 'medium',
|
||||
],
|
||||
'weight' => -3,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'datetime_default',
|
||||
'weight' => -3,
|
||||
]);
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['description'] = BaseFieldDefinition::create('string_long')
|
||||
->setLabel(t('Description'))
|
||||
@ -211,15 +204,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'basic_string',
|
||||
'weight' => -1,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textarea',
|
||||
'weight' => -1,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
|
||||
$fields['attendees'] = BaseFieldDefinition::create('entity_reference')
|
||||
@ -229,14 +215,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
|
||||
->setSetting('handler', 'default')
|
||||
->setTranslatable(TRUE)
|
||||
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
|
||||
->setDisplayOptions('view', [
|
||||
'type' => 'string',
|
||||
'weight' => 50,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'entity_reference_autocomplete',
|
||||
'weight' => 50,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
|
||||
|
||||
|
@ -204,19 +204,12 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
$fields['notes'] = BaseFieldDefinition::create('string_long')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Notes'))
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setSettings(array(
|
||||
'default_value' => '',
|
||||
'max_length' => 255,
|
||||
'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')
|
||||
->setLabel(t('Website'))
|
||||
@ -226,15 +219,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 49,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 49,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
$fields['contact_name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Contact Name'))
|
||||
@ -245,15 +231,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 51,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 51,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
|
||||
$fields['contact_role'] = BaseFieldDefinition::create('string')
|
||||
@ -265,15 +244,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 52,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 52,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
$fields['email'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Email Address'))
|
||||
@ -283,15 +255,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 100,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 52,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 52,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['phone'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Phone Number'))
|
||||
@ -301,15 +266,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 20,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 53,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 53,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['postal_address'] = BaseFieldDefinition::create('string_long')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Postal Address'))
|
||||
@ -319,15 +277,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 255,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'basic_string',
|
||||
'weight' => 54,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textarea',
|
||||
'weight' => 54,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['post_code'] = BaseFieldDefinition::create('string')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Post Code'))
|
||||
@ -336,15 +287,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 10,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 55,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 55,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['billing_contact_name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Billing Contact Name'))
|
||||
->setDescription(t('Name of the main contact for this client.'))
|
||||
@ -354,15 +298,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 56,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 56,
|
||||
])
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(FALSE);
|
||||
|
||||
$fields['billing_email'] = BaseFieldDefinition::create('string')
|
||||
@ -373,15 +310,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 100,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 57,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 57,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
|
||||
$fields['billing_phone'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Billing Phone Number'))
|
||||
@ -391,15 +321,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 20,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 58,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 58,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['billing_postal_address'] = BaseFieldDefinition::create('string_long')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Billing Postal Address'))
|
||||
@ -409,15 +332,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 255,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'basic_string',
|
||||
'weight' => 59,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textarea',
|
||||
'weight' => 59,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['billing_post_code'] = BaseFieldDefinition::create('string')
|
||||
->setRevisionable(TRUE)
|
||||
->setLabel(t('Billing Post Code'))
|
||||
@ -426,15 +342,8 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'max_length' => 10,
|
||||
'text_processing' => 0,
|
||||
))
|
||||
->setDisplayOptions('view', array(
|
||||
'label' => 'above',
|
||||
'type' => 'string',
|
||||
'weight' => 60,
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 60,
|
||||
));
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true);
|
||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Added by'))
|
||||
->setRevisionable(TRUE)
|
||||
@ -450,24 +359,16 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
|
||||
'text_processing' => 0,
|
||||
])
|
||||
->setDefaultValue('')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'hidden',
|
||||
'type' => 'string',
|
||||
'weight' => -100,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => -100,
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Visible'))
|
||||
->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.')
|
||||
->setRevisionable(TRUE)
|
||||
->setDisplayConfigurable("form", true)
|
||||
->setDisplayConfigurable('form', true)
|
||||
->setDisplayConfigurable('view', true)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
|
||||
|
@ -13,6 +13,11 @@ opencase.see_all_organisations_links:
|
||||
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:
|
||||
title: 'Add new...'
|
||||
menu_name: opencase
|
||||
|
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;
|
||||
}
|
||||
}
|
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 {}
|
@ -1,16 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
use PHPUnit\Framework\TestCase;
|
||||
include '../../../modules/opencase_cases/src/Entity/OCCase.php';
|
||||
|
||||
final class HookHelperTest extends TestCase
|
||||
{
|
||||
public function testOnCaseFeeUpdate(): void
|
||||
{
|
||||
$caseStub = $this->createStub(\Drupal\opencase_cases\Entity\OCCase::class);
|
||||
$caseStub->total_fee = 5;
|
||||
$caseFeeStub = $this->createStub(\Drupal\opencase_cases\Entity\OCCaseFee::class);
|
||||
$caseFeeStub->amount = 10;
|
||||
$caseFeeStub->method('getCase')->will($this->returnValue($caseStub));
|
||||
$this->assertSame(5,5);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user