Added Provider field to cases, auto-completed from actor linked to logged-in user. DB update required
This commit is contained in:
parent
40435a16be
commit
cc551b0851
@ -149,3 +149,17 @@ function opencase_entities_update_8003() {
|
|||||||
\Drupal::entityDefinitionUpdateManager()
|
\Drupal::entityDefinitionUpdateManager()
|
||||||
->installFieldStorageDefinition('activity_date_time', 'oc_activity', 'oc_activity', $storage_definition);
|
->installFieldStorageDefinition('activity_date_time', 'oc_activity', 'oc_activity', $storage_definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function opencase_entities_update_90001() {
|
||||||
|
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||||
|
->setLabel(t('Provider'))
|
||||||
|
->setRevisionable(TRUE)
|
||||||
|
->setSetting('target_type', 'oc_actor')
|
||||||
|
->setSetting('handler', 'default')
|
||||||
|
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::loggedInActorId')
|
||||||
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true);
|
||||||
|
\Drupal::entityDefinitionUpdateManager()
|
||||||
|
->installFieldStorageDefinition('oc_provider', 'oc_activity', 'oc_activity', $storage_definition);
|
||||||
|
}
|
||||||
|
@ -93,6 +93,11 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
$formatted = $current_time->format('Y-m-d');
|
$formatted = $current_time->format('Y-m-d');
|
||||||
return $formatted;
|
return $formatted;
|
||||||
}
|
}
|
||||||
|
public static function loggedInActorId() {
|
||||||
|
$linked_actor = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id())->field_linked_opencase_actor;
|
||||||
|
if (empty($linked_actor)) return [];
|
||||||
|
else return $linked_actor->target_id ;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -231,6 +236,14 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
->setSettings([
|
->setSettings([
|
||||||
'datetime_type' => 'date'
|
'datetime_type' => 'date'
|
||||||
]);
|
]);
|
||||||
|
$fields['oc_provider'] = BaseFieldDefinition::create('entity_reference')
|
||||||
|
->setLabel(t('Provider'))
|
||||||
|
->setRevisionable(TRUE)
|
||||||
|
->setSetting('target_type', 'oc_actor')
|
||||||
|
->setSetting('handler', 'default')
|
||||||
|
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::loggedInActorId')
|
||||||
|
->setDisplayConfigurable('form', true)
|
||||||
|
->setDisplayConfigurable('view', true);
|
||||||
|
|
||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setLabel(t('Visible'))
|
->setLabel(t('Visible'))
|
||||||
|
Reference in New Issue
Block a user