Definition of Drupal\text\Type\TextItem.
<?php
/**
* @file
* Definition of Drupal\text\Type\TextItem.
*/
namespace Drupal\text\Type;
use Drupal\Core\Entity\Field\FieldItemBase;
/**
* Defines the 'text_field' and 'text_long_field' entity field items.
*/
class TextItem extends FieldItemBase {
/**
* Definitions of the contained properties.
*
* @see TextItem::getPropertyDefinitions()
*
* @var array
*/
static $propertyDefinitions;
/**
* Implements ComplexDataInterface::getPropertyDefinitions().
*/
public function getPropertyDefinitions() {
if (!isset(static::$propertyDefinitions)) {
static::$propertyDefinitions['value'] = array(
'type' => 'string',
'label' => t('Text value'),
);
static::$propertyDefinitions['format'] = array(
'type' => 'string',
'label' => t('Text format'),
);
static::$propertyDefinitions['processed'] = array(
'type' => 'string',
'label' => t('Processed text'),
'description' => t('The text value with the text format applied.'),
'computed' => TRUE,
'class' => '\\Drupal\\text\\TextProcessed',
'settings' => array(
'text source' => 'value',
),
);
}
return static::$propertyDefinitions;
}
/**
* {@inheritdoc}
*/
public function isEmpty() {
$value = $this
->get('value')
->getValue();
return $value === NULL || $value === '';
}
}