Defines the 'taxonomy_term_reference' entity field item.
Expanded class hierarchy of TaxonomyTermReferenceItem
class TaxonomyTermReferenceItem extends FieldItemBase {
/**
* Property definitions of the contained properties.
*
* @see self::getPropertyDefinitions()
*
* @var array
*/
static $propertyDefinitions;
/**
* Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions().
*/
public function getPropertyDefinitions() {
if (!isset(self::$propertyDefinitions)) {
self::$propertyDefinitions['tid'] = array(
'type' => 'integer',
'label' => t('Referenced taxonomy term id.'),
);
self::$propertyDefinitions['entity'] = array(
'type' => 'entity',
'constraints' => array(
'entity type' => 'taxonomy_term',
),
'label' => t('Term'),
'description' => t('The referenced taxonomy term'),
// The entity object is computed out of the tid.
'computed' => TRUE,
'read-only' => FALSE,
'settings' => array(
'id source' => 'tid',
),
);
}
return self::$propertyDefinitions;
}
/**
* Overrides \Drupal\Core\Entity\Field\FieldItemBase::setValue().
*/
public function setValue($values) {
// Treat the values as property value of the entity field, if no array
// is given.
if (!is_array($values)) {
$values = array(
'entity' => $values,
);
}
// Entity is computed out of the ID, so we only need to update the ID. Only
// set the entity field if no ID is given.
if (isset($values['tid'])) {
$this->properties['tid']
->setValue($values['tid']);
}
elseif (isset($values['entity'])) {
$this->properties['entity']
->setValue($values['entity']);
}
else {
$this->properties['entity']
->setValue(NULL);
}
unset($values['entity'], $values['tid']);
if ($values) {
throw new \InvalidArgumentException('Property ' . key($values) . ' is unknown.');
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldItemBase:: |
protected | property | The item delta or name. | |
FieldItemBase:: |
protected | property | The parent entity field. | |
FieldItemBase:: |
protected | property | The array of properties. | |
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::get(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function | Implements IteratorAggregate::getIterator(). | |
FieldItemBase:: |
public | function |
Implements ContextAwareInterface::getName(). Overrides ContextAwareInterface:: |
|
FieldItemBase:: |
public | function |
Implements ContextAwareInterface::getParent(). Overrides ContextAwareInterface:: |
|
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::getProperties(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::getPropertyDefinition(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::getPropertyValues(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function |
Implements TypedDataInterface::getString(). Overrides TypedData:: |
|
FieldItemBase:: |
public | function |
Implements TypedDataInterface::getValue(). Overrides TypedData:: |
|
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::isEmpty(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::set(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function |
Implements ContextAwareInterface::setName(). Overrides ContextAwareInterface:: |
|
FieldItemBase:: |
public | function |
Implements ContextAwareInterface::setParent(). Overrides ContextAwareInterface:: |
|
FieldItemBase:: |
public | function |
Implements ComplexDataInterface::setPropertyValues(). Overrides ComplexDataInterface:: |
|
FieldItemBase:: |
public | function |
Implements TypedDataInterface::validate(). Overrides TypedDataInterface:: |
|
FieldItemBase:: |
public | function | Implements a deep clone. | |
FieldItemBase:: |
public | function |
Implements TypedDataInterface::__construct(). Overrides TypedData:: |
|
FieldItemBase:: |
public | function |
Implements FieldItemInterface::__get(). Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public | function |
Implements FieldItemInterface::__isset(). Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public | function |
Implements FieldItemInterface::__set(). Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public | function |
Implements FieldItemInterface::__unset(). Overrides FieldItemInterface:: |
|
TaxonomyTermReferenceItem:: |
static | property | Property definitions of the contained properties. | |
TaxonomyTermReferenceItem:: |
public | function |
Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). Overrides ComplexDataInterface:: |
|
TaxonomyTermReferenceItem:: |
public | function |
Overrides \Drupal\Core\Entity\Field\FieldItemBase::setValue(). Overrides FieldItemBase:: |
|
TypedData:: |
protected | property | The data definition. | |
TypedData:: |
public | function |
Implements TypedDataInterface::getDefinition(). Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Implements TypedDataInterface::getType(). Overrides TypedDataInterface:: |