public static function WorkflowItem::propertyDefinitions in Workflow 8
Defines field item properties.
Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().
Return value
\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.
Overrides FieldItemInterface::propertyDefinitions
See also
\Drupal\Core\Field\BaseFieldDefinition
File
- src/
Plugin/ Field/ FieldType/ WorkflowItem.php, line 57
Class
- WorkflowItem
- Plugin implementation of the 'workflow' field type.
Namespace
Drupal\workflow\Plugin\Field\FieldTypeCode
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
/**
* Property definitions of the contained properties.
*
* @see FileItem::getPropertyDefinitions()
*
* @var array
*/
static $propertyDefinitions;
$definition['settings']['target_type'] = 'workflow_transition';
// Definitions vary by entity type and bundle, so key them accordingly.
$key = $definition['settings']['target_type'] . ':';
$key .= isset($definition['settings']['target_bundle']) ? $definition['settings']['target_bundle'] : '';
if (!isset($propertyDefinitions[$key])) {
$propertyDefinitions[$key]['value'] = DataDefinition::create('string')
->setLabel(t('Workflow state'))
->addConstraint('Length', [
'max' => 128,
])
->setRequired(TRUE);
//workflow_debug(__FILE__, __FUNCTION__, __LINE__); // @todo D8: test this snippet.
/*
$propertyDefinitions[$key]['workflow_transition'] = DataDefinition::create('any')
// $properties['workflow_transition'] = DataDefinition::create('WorkflowTransition')
->setLabel(t('Transition'))
->setDescription(t('The computed WorkflowItem object.'))
->setComputed(TRUE)
->setClass('\Drupal\workflow\Entity\WorkflowTransition')
->setSetting('date source', 'value');
$propertyDefinitions[$key]['display'] = array(
'type' => 'boolean',
'label' => t('Flag to control whether this file should be displayed when viewing content.'),
);
$propertyDefinitions[$key]['description'] = array(
'type' => 'string',
'label' => t('A description of the file.'),
);
$propertyDefinitions[$key]['display'] = array(
'type' => 'boolean',
'label' => t('Flag to control whether this file should be displayed when viewing content.'),
);
$propertyDefinitions[$key]['description'] = array(
'type' => 'string',
'label' => t('A description of the file.'),
);
*/
}
return $propertyDefinitions[$key];
}