made fields configurable for case and sub cases
This commit is contained in:
parent
2f06caa261
commit
489f4c0c94
@ -75,22 +75,25 @@ 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() {
|
public static function defaultTarget()
|
||||||
|
{
|
||||||
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
|
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
|
||||||
else return [];
|
else return [];
|
||||||
}
|
}
|
||||||
@ -98,13 +101,13 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
/**
|
/**
|
||||||
* {@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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,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) {
|
||||||
@ -136,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;
|
||||||
}
|
}
|
||||||
@ -151,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;
|
||||||
}
|
}
|
||||||
@ -166,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;
|
||||||
}
|
}
|
||||||
@ -188,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;
|
||||||
}
|
}
|
||||||
@ -196,24 +208,26 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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
|
||||||
@ -221,7 +235,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')
|
||||||
@ -232,22 +247,17 @@ 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',
|
|
||||||
'weight' => 80,
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
$fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
|
$fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Target'))
|
->setLabel(t('Target'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setSetting('target_type', 'oc_actor')
|
->setSetting('target_type', 'oc_actor')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
|
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
|
||||||
->setDisplayConfigurable('form', true)
|
->setDisplayConfigurable('form', true)
|
||||||
->setDisplayConfigurable('view', true);
|
->setDisplayConfigurable('view', true);
|
||||||
|
|
||||||
$fields['name'] = BaseFieldDefinition::create('string')
|
$fields['name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Title'))
|
->setLabel(t('Title'))
|
||||||
@ -257,14 +267,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);
|
||||||
|
|
||||||
|
|
||||||
@ -278,18 +282,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'))
|
||||||
@ -321,12 +314,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;
|
||||||
}
|
}
|
||||||
|
@ -206,21 +206,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 +218,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);
|
||||||
|
@ -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,25 +230,17 @@ 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'] = 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);
|
||||||
|
|
||||||
|
|
||||||
@ -298,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']])
|
||||||
|
Reference in New Issue
Block a user