MaestroProcessVariables.php in Maestro 8.2
File
src/Entity/MaestroProcessVariables.php
View source
<?php
namespace Drupal\maestro\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\maestro\MaestroProcessInterface;
use Drupal\user\UserInterface;
use Drupal\Core\Entity\EntityChangedTrait;
class MaestroProcessVariables extends ContentEntityBase implements MaestroProcessInterface {
use EntityChangedTrait;
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'user_id' => \Drupal::currentUser()
->id(),
];
}
public function getCreatedTime() {
return NULL;
}
public function getChangedTime() {
return NULL;
}
public function getOwner() {
return NULL;
}
public function getOwnerId() {
return $this
->get('user_id')->target_id;
}
public function setOwnerId($uid) {
$this
->set('user_id', $uid);
return $this;
}
public function setOwner(UserInterface $account) {
$this
->set('user_id', $account
->id());
return $this;
}
public function getCompletedTime() {
return NULL;
}
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('id'))
->setDescription(t('The ID of the Maestro Process Variable.'))
->setReadOnly(TRUE);
$fields['process_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Process ID'))
->setDescription(t('The process ID this variable belongs to.'))
->setSetting('target_type', 'maestro_process')
->setSetting('handler', 'default');
$fields['variable_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the variable.'))
->setSettings([
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
]);
$fields['variable_value'] = BaseFieldDefinition::create('string')
->setLabel(t('Value'))
->setDescription(t('The value of the variable.'))
->setSettings([
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
]);
return $fields;
}
}