parent
77abeaef4d
commit
be7f5fc591
@ -1,16 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use \Drupal\Core\Field\BaseFieldDefinition;
|
use \Drupal\Core\Field\BaseFieldDefinition;
|
||||||
|
|
||||||
function opencase_cases_update_90005() {
|
|
||||||
$field_storage_definition = BaseFieldDefinition::create('integer')
|
|
||||||
->setLabel(t('Number of Cases'))
|
|
||||||
->setRevisionable(TRUE)
|
|
||||||
->setDisplayConfigurable('view', true);
|
|
||||||
|
|
||||||
\Drupal::entityDefinitionUpdateManager()
|
|
||||||
->installFieldStorageDefinition('total_cases', 'oc_actor', 'opencase_cases', $field_storage_definition);
|
|
||||||
}
|
|
||||||
|
|
||||||
function opencase_cases_update_90004() {
|
function opencase_cases_update_90004() {
|
||||||
$field_storage_definition = BaseFieldDefinition::create('string_long')
|
$field_storage_definition = BaseFieldDefinition::create('string_long')
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
|
@ -97,23 +97,6 @@ function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFe
|
|||||||
$case->addToTotalFee(0 - $case_fee->amount->value);
|
$case->addToTotalFee(0 - $case_fee->amount->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function opencase_cases_oc_case_provision_insert(Drupal\opencase_cases\entity\OCCaseProvision $case_provision): void {
|
|
||||||
$provider = $case_provision->getProvider()->incrementTotalCases();
|
|
||||||
}
|
|
||||||
function opencase_cases_oc_case_provision_delete(Drupal\opencase_cases\entity\OCCaseProvision $case_provision): void {
|
|
||||||
$provider = $case_provision->getProvider()->decrementTotalCases();
|
|
||||||
}
|
|
||||||
|
|
||||||
function opencase_cases_oc_case_provision_update(Drupal\opencase_cases\entity\OCCaseProvision $case_provision): void {
|
|
||||||
$new_provider_id = $case_provision->oc_provider->target_id;
|
|
||||||
$old_provider_id = $case_provision->original->oc_provider->target_id;
|
|
||||||
if ($new_provider_id != $old_provider_id) {
|
|
||||||
$case_provision->getProvider()->incrementTotalCases();
|
|
||||||
$case_provision->original->getProvider()->decrementTotalCases();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
function opencase_cases_entity_base_field_info($entity_type) {
|
function opencase_cases_entity_base_field_info($entity_type) {
|
||||||
$fields = array();
|
$fields = array();
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ use Drupal\Core\Entity\EntityChangedTrait;
|
|||||||
use Drupal\Core\Entity\EntityPublishedTrait;
|
use Drupal\Core\Entity\EntityPublishedTrait;
|
||||||
use Drupal\Core\Entity\EntityTypeInterface;
|
use Drupal\Core\Entity\EntityTypeInterface;
|
||||||
use Drupal\user\UserInterface;
|
use Drupal\user\UserInterface;
|
||||||
use Drupal\opencase_entities\Entity\OCActor;
|
|
||||||
use Error;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the Case Provision entity.
|
* Defines the Case Provision entity.
|
||||||
@ -203,10 +201,6 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProvider():?OCActor {
|
|
||||||
return OCActor::load($this->oc_provider->target_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -207,17 +207,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function incrementTotalCases(): void {
|
|
||||||
$this->set('total_cases', $this->total_cases->value + 1);
|
|
||||||
$this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function decrementTotalCases(): void {
|
|
||||||
$this->set('total_cases', $this->total_cases->value - 1);
|
|
||||||
$this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -342,11 +331,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
|||||||
->setDisplayConfigurable("form", true)
|
->setDisplayConfigurable("form", true)
|
||||||
->setDisplayConfigurable("view", true);
|
->setDisplayConfigurable("view", true);
|
||||||
|
|
||||||
$fields['total_cases'] = BaseFieldDefinition::create('integer')
|
|
||||||
->setLabel(t('Number of Cases'))
|
|
||||||
->setRevisionable(TRUE)
|
|
||||||
->setDisplayConfigurable('view', true);
|
|
||||||
|
|
||||||
$fields['created'] = BaseFieldDefinition::create('created')
|
$fields['created'] = BaseFieldDefinition::create('created')
|
||||||
->setLabel(t('Created'))
|
->setLabel(t('Created'))
|
||||||
->setDescription(t('The time that the entity was created.'));
|
->setDescription(t('The time that the entity was created.'));
|
||||||
|
Reference in New Issue
Block a user