public static function NifItem::propertyDefinitions in Field NIF 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/ NifItem.php, line 26
Class
- NifItem
- Plugin implementation of the 'nif' field type.
Namespace
Drupal\field_nif\Plugin\Field\FieldTypeCode
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
// Computed property for an easier access to the complete document number.
$properties['value'] = DataDefinition::create('string')
->setLabel(t('NIF value'))
->setComputed(TRUE)
->setClass('\\Drupal\\field_nif\\NifProcessed')
->setSetting('document source', [
'first_letter',
'number',
'last_letter',
]);
$properties['number'] = DataDefinition::create('string')
->setLabel(t('Document number'));
$properties['first_letter'] = DataDefinition::create('string')
->setLabel(t('First letter of the NIF/CIF/NIE'));
$properties['last_letter'] = DataDefinition::create('string')
->setLabel(t('Last letter of the NIF/CIF/NIE'));
$properties['type'] = DataDefinition::create('string')
->setLabel(t('Type of document'));
return $properties;
}