class EntityReferenceItem in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem
Defines the 'entity_reference' entity field type.
Supported settings (below the definition's 'settings' key) are:
- target_type: The entity type to reference. Required.
Plugin annotation
@FieldType(
id = "entity_reference",
label = @Translation("Entity reference"),
description = @Translation("An entity field containing an entity reference."),
category = @Translation("Reference"),
default_widget = "entity_reference_autocomplete",
default_formatter = "entity_reference_label",
list_class = "\Drupal\Core\Field\EntityReferenceFieldItemList",
)
Hierarchy
- class \Drupal\Core\TypedData\TypedData implements PluginInspectionInterface, TypedDataInterface uses StringTranslationTrait, TypedDataTrait
- class \Drupal\Core\TypedData\Plugin\DataType\Map implements \Drupal\Core\TypedData\Plugin\DataType\IteratorAggregate, ComplexDataInterface
- class \Drupal\Core\Field\FieldItemBase implements FieldItemInterface
- class \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem implements PreconfiguredFieldUiOptionsInterface, OptionsProviderInterface
- class \Drupal\Core\Field\FieldItemBase implements FieldItemInterface
- class \Drupal\Core\TypedData\Plugin\DataType\Map implements \Drupal\Core\TypedData\Plugin\DataType\IteratorAggregate, ComplexDataInterface
Expanded class hierarchy of EntityReferenceItem
9 files declare their use of EntityReferenceItem
- ConfigurableEntityReferenceItem.php in core/
modules/ entity_reference/ src/ ConfigurableEntityReferenceItem.php - Contains \Drupal\entity_reference\ConfigurableEntityReferenceItem.
- DefaultSelection.php in core/
lib/ Drupal/ Core/ Entity/ Plugin/ EntityReferenceSelection/ DefaultSelection.php - Contains \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection.
- EntityReferenceFieldItemNormalizer.php in core/
modules/ serialization/ src/ Normalizer/ EntityReferenceFieldItemNormalizer.php - Contains \Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer.
- EntityReferenceFieldItemNormalizerTest.php in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php - Contains \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest.
- EntityReferenceFormatterBase.php in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldFormatter/ EntityReferenceFormatterBase.php - Contains \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase.
File
- core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ EntityReferenceItem.php, line 45 - Contains \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeView source
class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterface, PreconfiguredFieldUiOptionsInterface {
/**
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
return array(
'target_type' => \Drupal::moduleHandler()
->moduleExists('node') ? 'node' : 'user',
) + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
return array(
'handler' => 'default',
'handler_settings' => array(),
) + parent::defaultFieldSettings();
}
/**
* {@inheritdoc}
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$settings = $field_definition
->getSettings();
$target_type_info = \Drupal::entityManager()
->getDefinition($settings['target_type']);
$target_id_data_type = 'string';
if ($target_type_info
->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
$id_definition = \Drupal::entityManager()
->getBaseFieldDefinitions($settings['target_type'])[$target_type_info
->getKey('id')];
if ($id_definition
->getType() === 'integer') {
$target_id_data_type = 'integer';
}
}
if ($target_id_data_type === 'integer') {
$target_id_definition = DataReferenceTargetDefinition::create('integer')
->setLabel(new TranslatableMarkup('@label ID', [
'@label' => $target_type_info
->getLabel(),
]))
->setSetting('unsigned', TRUE);
}
else {
$target_id_definition = DataReferenceTargetDefinition::create('string')
->setLabel(new TranslatableMarkup('@label ID', [
'@label' => $target_type_info
->getLabel(),
]));
}
$target_id_definition
->setRequired(TRUE);
$properties['target_id'] = $target_id_definition;
$properties['entity'] = DataReferenceDefinition::create('entity')
->setLabel($target_type_info
->getLabel())
->setDescription(new TranslatableMarkup('The referenced entity'))
->setComputed(TRUE)
->setReadOnly(FALSE)
->setTargetDefinition(EntityDataDefinition::create($settings['target_type']))
->addConstraint('EntityType', $settings['target_type']);
return $properties;
}
/**
* {@inheritdoc}
*/
public static function mainPropertyName() {
return 'target_id';
}
/**
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$target_type = $field_definition
->getSetting('target_type');
$target_type_info = \Drupal::entityManager()
->getDefinition($target_type);
$properties = static::propertyDefinitions($field_definition)['target_id'];
if ($target_type_info
->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface') && $properties
->getDataType() === 'integer') {
$columns = array(
'target_id' => array(
'description' => 'The ID of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
),
);
}
else {
$columns = array(
'target_id' => array(
'description' => 'The ID of the target entity.',
'type' => 'varchar_ascii',
// If the target entities act as bundles for another entity type,
// their IDs should not exceed the maximum length for bundles.
'length' => $target_type_info
->getBundleOf() ? EntityTypeInterface::BUNDLE_MAX_LENGTH : 255,
),
);
}
$schema = array(
'columns' => $columns,
'indexes' => array(
'target_id' => array(
'target_id',
),
),
);
return $schema;
}
/**
* {@inheritdoc}
*/
public function getConstraints() {
$constraints = parent::getConstraints();
// Remove the 'AllowedValuesConstraint' validation constraint because entity
// reference fields already use the 'ValidReference' constraint.
foreach ($constraints as $key => $constraint) {
if ($constraint instanceof AllowedValuesConstraint) {
unset($constraints[$key]);
}
}
return $constraints;
}
/**
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE) {
if (isset($values) && !is_array($values)) {
// If either a scalar or an object was passed as the value for the item,
// assign it to the 'entity' property since that works for both cases.
$this
->set('entity', $values, $notify);
}
else {
parent::setValue($values, FALSE);
// Support setting the field item with only one property, but make sure
// values stay in sync if only property is passed.
// NULL is a valid value, so we use array_key_exists().
if (is_array($values) && array_key_exists('target_id', $values) && !isset($values['entity'])) {
$this
->onChange('target_id', FALSE);
}
elseif (is_array($values) && !array_key_exists('target_id', $values) && isset($values['entity'])) {
$this
->onChange('entity', FALSE);
}
elseif (is_array($values) && array_key_exists('target_id', $values) && isset($values['entity'])) {
// If both properties are passed, verify the passed values match. The
// only exception we allow is when we have a new entity: in this case
// its actual id and target_id will be different, due to the new entity
// marker.
$entity_id = $this
->get('entity')
->getTargetIdentifier();
// If the entity has been saved and we're trying to set both the
// target_id and the entity values with a non-null target ID, then the
// value for target_id should match the ID of the entity value.
if (!$this->entity
->isNew() && $values['target_id'] !== NULL && $entity_id !== $values['target_id']) {
throw new \InvalidArgumentException('The target id and entity passed to the entity reference item do not match.');
}
}
// Notify the parent if necessary.
if ($notify && $this->parent) {
$this->parent
->onChange($this
->getName());
}
}
}
/**
* {@inheritdoc}
*/
public function getValue() {
$values = parent::getValue();
// If there is an unsaved entity, return it as part of the field item values
// to ensure idempotency of getValue() / setValue().
if ($this
->hasNewEntity()) {
$values['entity'] = $this->entity;
}
return $values;
}
/**
* {@inheritdoc}
*/
public function onChange($property_name, $notify = TRUE) {
// Make sure that the target ID and the target property stay in sync.
if ($property_name == 'entity') {
$property = $this
->get('entity');
$target_id = $property
->isTargetNew() ? NULL : $property
->getTargetIdentifier();
$this
->writePropertyValue('target_id', $target_id);
}
elseif ($property_name == 'target_id') {
$this
->writePropertyValue('entity', $this->target_id);
}
parent::onChange($property_name, $notify);
}
/**
* {@inheritdoc}
*/
public function isEmpty() {
// Avoid loading the entity by first checking the 'target_id'.
if ($this->target_id !== NULL) {
return FALSE;
}
if ($this->entity && $this->entity instanceof EntityInterface) {
return FALSE;
}
return TRUE;
}
/**
* {@inheritdoc}
*/
public function preSave() {
if ($this
->hasNewEntity()) {
// Save the entity if it has not already been saved by some other code.
if ($this->entity
->isNew()) {
$this->entity
->save();
}
// Make sure the parent knows we are updating this property so it can
// react properly.
$this->target_id = $this->entity
->id();
}
if (!$this
->isEmpty() && $this->target_id === NULL) {
$this->target_id = $this->entity
->id();
}
}
/**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$manager = \Drupal::service('plugin.manager.entity_reference_selection');
if ($referenceable = $manager
->getSelectionHandler($field_definition)
->getReferenceableEntities()) {
$group = array_rand($referenceable);
$values['target_id'] = array_rand($referenceable[$group]);
return $values;
}
}
/**
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
$element['target_type'] = array(
'#type' => 'select',
'#title' => t('Type of item to reference'),
'#options' => \Drupal::entityManager()
->getEntityTypeLabels(TRUE),
'#default_value' => $this
->getSetting('target_type'),
'#required' => TRUE,
'#disabled' => $has_data,
'#size' => 1,
);
return $element;
}
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$field = $form_state
->getFormObject()
->getEntity();
// Get all selection plugins for this entity type.
$selection_plugins = \Drupal::service('plugin.manager.entity_reference_selection')
->getSelectionGroups($this
->getSetting('target_type'));
$handlers_options = array();
foreach (array_keys($selection_plugins) as $selection_group_id) {
// We only display base plugins (e.g. 'default', 'views', ...) and not
// entity type specific plugins (e.g. 'default:node', 'default:user',
// ...).
if (array_key_exists($selection_group_id, $selection_plugins[$selection_group_id])) {
$handlers_options[$selection_group_id] = Html::escape($selection_plugins[$selection_group_id][$selection_group_id]['label']);
}
elseif (array_key_exists($selection_group_id . ':' . $this
->getSetting('target_type'), $selection_plugins[$selection_group_id])) {
$selection_group_plugin = $selection_group_id . ':' . $this
->getSetting('target_type');
$handlers_options[$selection_group_plugin] = Html::escape($selection_plugins[$selection_group_id][$selection_group_plugin]['base_plugin_label']);
}
}
$form = array(
'#type' => 'container',
'#process' => array(
array(
get_class($this),
'fieldSettingsAjaxProcess',
),
),
'#element_validate' => array(
array(
get_class($this),
'fieldSettingsFormValidate',
),
),
);
$form['handler'] = array(
'#type' => 'details',
'#title' => t('Reference type'),
'#open' => TRUE,
'#tree' => TRUE,
'#process' => array(
array(
get_class($this),
'formProcessMergeParent',
),
),
);
$form['handler']['handler'] = array(
'#type' => 'select',
'#title' => t('Reference method'),
'#options' => $handlers_options,
'#default_value' => $field
->getSetting('handler'),
'#required' => TRUE,
'#ajax' => TRUE,
'#limit_validation_errors' => array(),
);
$form['handler']['handler_submit'] = array(
'#type' => 'submit',
'#value' => t('Change handler'),
'#limit_validation_errors' => array(),
'#attributes' => array(
'class' => array(
'js-hide',
),
),
'#submit' => array(
array(
get_class($this),
'settingsAjaxSubmit',
),
),
);
$form['handler']['handler_settings'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'entity_reference-settings',
),
),
);
$handler = \Drupal::service('plugin.manager.entity_reference_selection')
->getSelectionHandler($field);
$form['handler']['handler_settings'] += $handler
->buildConfigurationForm(array(), $form_state);
return $form;
}
/**
* Form element validation handler; Invokes selection plugin's validation.
*
* @param array $form
* The form where the settings form is being included in.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state of the (entire) configuration form.
*/
public static function fieldSettingsFormValidate(array $form, FormStateInterface $form_state) {
$field = $form_state
->getFormObject()
->getEntity();
$handler = \Drupal::service('plugin.manager.entity_reference_selection')
->getSelectionHandler($field);
$handler
->validateConfigurationForm($form, $form_state);
}
/**
* Determines whether the item holds an unsaved entity.
*
* This is notably used for "autocreate" widgets, and more generally to
* support referencing freshly created entities (they will get saved
* automatically as the hosting entity gets saved).
*
* @return bool
* TRUE if the item holds an unsaved entity.
*/
public function hasNewEntity() {
return !$this
->isEmpty() && $this->target_id === NULL && $this->entity
->isNew();
}
/**
* {@inheritdoc}
*/
public static function calculateDependencies(FieldDefinitionInterface $field_definition) {
$dependencies = parent::calculateDependencies($field_definition);
$manager = \Drupal::entityManager();
$target_entity_type = $manager
->getDefinition($field_definition
->getFieldStorageDefinition()
->getSetting('target_type'));
// Depend on default values entity types configurations.
if ($default_value = $field_definition
->getDefaultValueLiteral()) {
foreach ($default_value as $value) {
if (is_array($value) && isset($value['target_uuid'])) {
$entity = \Drupal::entityManager()
->loadEntityByUuid($target_entity_type
->id(), $value['target_uuid']);
// If the entity does not exist do not create the dependency.
// @see \Drupal\Core\Field\EntityReferenceFieldItemList::processDefaultValue()
if ($entity) {
$dependencies[$target_entity_type
->getConfigDependencyKey()][] = $entity
->getConfigDependencyName();
}
}
}
}
// Depend on target bundle configurations.
$handler = $field_definition
->getSetting('handler_settings');
if (!empty($handler['target_bundles'])) {
if ($bundle_entity_type_id = $target_entity_type
->getBundleEntityType()) {
if ($storage = $manager
->getStorage($bundle_entity_type_id)) {
foreach ($storage
->loadMultiple($handler['target_bundles']) as $bundle) {
$dependencies[$bundle
->getConfigDependencyKey()][] = $bundle
->getConfigDependencyName();
}
}
}
}
return $dependencies;
}
/**
* {@inheritdoc}
*/
public static function calculateStorageDependencies(FieldStorageDefinitionInterface $field_definition) {
$dependencies = parent::calculateStorageDependencies($field_definition);
$target_entity_type = \Drupal::entityManager()
->getDefinition($field_definition
->getSetting('target_type'));
$dependencies['module'][] = $target_entity_type
->getProvider();
return $dependencies;
}
/**
* {@inheritdoc}
*/
public static function onDependencyRemoval(FieldDefinitionInterface $field_definition, array $dependencies) {
$changed = parent::onDependencyRemoval($field_definition, $dependencies);
$entity_manager = \Drupal::entityManager();
$target_entity_type = $entity_manager
->getDefinition($field_definition
->getFieldStorageDefinition()
->getSetting('target_type'));
// Try to update the default value config dependency, if possible.
if ($default_value = $field_definition
->getDefaultValueLiteral()) {
foreach ($default_value as $key => $value) {
if (is_array($value) && isset($value['target_uuid'])) {
$entity = $entity_manager
->loadEntityByUuid($target_entity_type
->id(), $value['target_uuid']);
// @see \Drupal\Core\Field\EntityReferenceFieldItemList::processDefaultValue()
if ($entity && isset($dependencies[$entity
->getConfigDependencyKey()][$entity
->getConfigDependencyName()])) {
unset($default_value[$key]);
$changed = TRUE;
}
}
}
if ($changed) {
$field_definition
->setDefaultValue($default_value);
}
}
// Update the 'target_bundles' handler setting if a bundle config dependency
// has been removed.
$bundles_changed = FALSE;
$handler_settings = $field_definition
->getSetting('handler_settings');
if (!empty($handler_settings['target_bundles'])) {
if ($bundle_entity_type_id = $target_entity_type
->getBundleEntityType()) {
if ($storage = $entity_manager
->getStorage($bundle_entity_type_id)) {
foreach ($storage
->loadMultiple($handler_settings['target_bundles']) as $bundle) {
if (isset($dependencies[$bundle
->getConfigDependencyKey()][$bundle
->getConfigDependencyName()])) {
unset($handler_settings['target_bundles'][$bundle
->id()]);
$bundles_changed = TRUE;
// In case we deleted the only target bundle allowed by the field
// we have to log a warning message because the field will not
// function correctly anymore.
if ($handler_settings['target_bundles'] === []) {
\Drupal::logger('entity_reference')
->critical('The %target_bundle bundle (entity type: %target_entity_type) was deleted. As a result, the %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', [
'%target_bundle' => $bundle
->label(),
'%target_entity_type' => $bundle
->getEntityType()
->getBundleOf(),
'%field_name' => $field_definition
->getName(),
'%entity_type' => $field_definition
->getTargetEntityTypeId(),
'%bundle' => $field_definition
->getTargetBundle(),
]);
}
}
}
}
}
}
if ($bundles_changed) {
$field_definition
->setSetting('handler_settings', $handler_settings);
}
$changed |= $bundles_changed;
return $changed;
}
/**
* {@inheritdoc}
*/
public function getPossibleValues(AccountInterface $account = NULL) {
return $this
->getSettableValues($account);
}
/**
* {@inheritdoc}
*/
public function getPossibleOptions(AccountInterface $account = NULL) {
return $this
->getSettableOptions($account);
}
/**
* {@inheritdoc}
*/
public function getSettableValues(AccountInterface $account = NULL) {
// Flatten options first, because "settable options" may contain group
// arrays.
$flatten_options = OptGroup::flattenOptions($this
->getSettableOptions($account));
return array_keys($flatten_options);
}
/**
* {@inheritdoc}
*/
public function getSettableOptions(AccountInterface $account = NULL) {
$field_definition = $this
->getFieldDefinition();
if (!($options = \Drupal::service('plugin.manager.entity_reference_selection')
->getSelectionHandler($field_definition, $this
->getEntity())
->getReferenceableEntities())) {
return array();
}
// Rebuild the array by changing the bundle key into the bundle label.
$target_type = $field_definition
->getSetting('target_type');
$bundles = \Drupal::entityManager()
->getBundleInfo($target_type);
$return = array();
foreach ($options as $bundle => $entity_ids) {
// The label does not need sanitizing since it is used as an optgroup
// which is only supported by select elements and auto-escaped.
$bundle_label = (string) $bundles[$bundle]['label'];
$return[$bundle_label] = $entity_ids;
}
return count($return) == 1 ? reset($return) : $return;
}
/**
* Render API callback: Processes the field settings form and allows access to
* the form state.
*
* @see static::fieldSettingsForm()
*/
public static function fieldSettingsAjaxProcess($form, FormStateInterface $form_state) {
static::fieldSettingsAjaxProcessElement($form, $form);
return $form;
}
/**
* Adds entity_reference specific properties to AJAX form elements from the
* field settings form.
*
* @see static::fieldSettingsAjaxProcess()
*/
public static function fieldSettingsAjaxProcessElement(&$element, $main_form) {
if (!empty($element['#ajax'])) {
$element['#ajax'] = array(
'callback' => array(
get_called_class(),
'settingsAjax',
),
'wrapper' => $main_form['#id'],
'element' => $main_form['#array_parents'],
);
}
foreach (Element::children($element) as $key) {
static::fieldSettingsAjaxProcessElement($element[$key], $main_form);
}
}
/**
* Render API callback: Moves entity_reference specific Form API elements
* (i.e. 'handler_settings') up a level for easier processing by the
* validation and submission handlers.
*
* @see _entity_reference_field_settings_process()
*/
public static function formProcessMergeParent($element) {
$parents = $element['#parents'];
array_pop($parents);
$element['#parents'] = $parents;
return $element;
}
/**
* Ajax callback for the handler settings form.
*
* @see static::fieldSettingsForm()
*/
public static function settingsAjax($form, FormStateInterface $form_state) {
return NestedArray::getValue($form, $form_state
->getTriggeringElement()['#ajax']['element']);
}
/**
* Submit handler for the non-JS case.
*
* @see static::fieldSettingsForm()
*/
public static function settingsAjaxSubmit($form, FormStateInterface $form_state) {
$form_state
->setRebuild();
}
/**
* {@inheritdoc}
*/
public static function getPreconfiguredOptions() {
$options = array();
// Add all the commonly referenced entity types as distinct pre-configured
// options.
$entity_types = \Drupal::entityManager()
->getDefinitions();
$common_references = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
return $entity_type
->isCommonReferenceTarget();
});
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
foreach ($common_references as $entity_type) {
$options[$entity_type
->id()] = [
'label' => $entity_type
->getLabel(),
'field_storage_config' => [
'settings' => [
'target_type' => $entity_type
->id(),
],
],
];
}
return $options;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityReferenceItem:: |
public static | function |
Calculates dependencies for field items. Overrides FieldItemBase:: |
|
EntityReferenceItem:: |
public static | function |
Calculates dependencies for field items on the storage level. Overrides FieldItemBase:: |
|
EntityReferenceItem:: |
public static | function |
Defines the field-level settings for this plugin. Overrides FieldItemBase:: |
1 |
EntityReferenceItem:: |
public static | function |
Defines the storage-level settings for this plugin. Overrides FieldItemBase:: |
1 |
EntityReferenceItem:: |
public static | function | Render API callback: Processes the field settings form and allows access to the form state. | |
EntityReferenceItem:: |
public static | function | Adds entity_reference specific properties to AJAX form elements from the field settings form. | |
EntityReferenceItem:: |
public | function |
Returns a form for the field-level settings. Overrides FieldItemBase:: |
1 |
EntityReferenceItem:: |
public static | function | Form element validation handler; Invokes selection plugin's validation. | |
EntityReferenceItem:: |
public static | function | Render API callback: Moves entity_reference specific Form API elements (i.e. 'handler_settings') up a level for easier processing by the validation and submission handlers. | |
EntityReferenceItem:: |
public static | function |
Generates placeholder field values. Overrides FieldItemBase:: |
1 |
EntityReferenceItem:: |
public | function |
Gets a list of validation constraints. Overrides TypedData:: |
|
EntityReferenceItem:: |
public | function |
Returns an array of possible values with labels for display. Overrides OptionsProviderInterface:: |
|
EntityReferenceItem:: |
public | function |
Returns an array of possible values. Overrides OptionsProviderInterface:: |
|
EntityReferenceItem:: |
public static | function |
Returns preconfigured field options for a field type. Overrides PreconfiguredFieldUiOptionsInterface:: |
1 |
EntityReferenceItem:: |
public | function |
Returns an array of settable values with labels for display. Overrides OptionsProviderInterface:: |
|
EntityReferenceItem:: |
public | function |
Returns an array of settable values. Overrides OptionsProviderInterface:: |
|
EntityReferenceItem:: |
public | function |
Gets the data value. Overrides Map:: |
|
EntityReferenceItem:: |
public | function | Determines whether the item holds an unsaved entity. | |
EntityReferenceItem:: |
public | function |
Determines whether the data structure is empty. Overrides Map:: |
|
EntityReferenceItem:: |
public static | function |
Returns the name of the main property, if any. Overrides FieldItemBase:: |
|
EntityReferenceItem:: |
public | function |
React to changes to a child property or item. Overrides Map:: |
|
EntityReferenceItem:: |
public static | function |
Informs the plugin that a dependency of the field will be deleted. Overrides FieldItemBase:: |
|
EntityReferenceItem:: |
public | function |
Defines custom presave behavior for field values. Overrides FieldItemBase:: |
1 |
EntityReferenceItem:: |
public static | function |
Defines field item properties. Overrides FieldItemInterface:: |
1 |
EntityReferenceItem:: |
public static | function |
Returns the schema for the field. Overrides FieldItemInterface:: |
1 |
EntityReferenceItem:: |
public static | function | Ajax callback for the handler settings form. | |
EntityReferenceItem:: |
public static | function | Submit handler for the non-JS case. | |
EntityReferenceItem:: |
public | function |
Overrides \Drupal\Core\TypedData\TypedData::setValue(). Overrides FieldItemBase:: |
|
EntityReferenceItem:: |
public | function |
Returns a form for the storage-level settings. Overrides FieldItemBase:: |
1 |
FieldItemBase:: |
public | function |
Defines custom delete behavior for field values. Overrides FieldItemInterface:: |
2 |
FieldItemBase:: |
public | function |
Defines custom revision delete behavior for field values. Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public static | function |
Returns a settings array in the field type's canonical representation. Overrides FieldItemInterface:: |
1 |
FieldItemBase:: |
public static | function |
Returns a settings array that can be stored as a configuration value. Overrides FieldItemInterface:: |
1 |
FieldItemBase:: |
public | function |
Gets the entity that field belongs to. Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public | function |
Gets the field definition. Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public | function |
Gets the langcode of the field values held in the object. Overrides FieldItemInterface:: |
|
FieldItemBase:: |
protected | function | Returns the value of a field setting. | |
FieldItemBase:: |
protected | function | Returns the array of field settings. | |
FieldItemBase:: |
public | function |
Defines custom post-save behavior for field values. Overrides FieldItemInterface:: |
2 |
FieldItemBase:: |
public static | function |
Returns a settings array in the field type's canonical representation. Overrides FieldItemInterface:: |
2 |
FieldItemBase:: |
public static | function |
Returns a settings array that can be stored as a configuration value. Overrides FieldItemInterface:: |
2 |
FieldItemBase:: |
public | function |
Returns a renderable array for a single field item. Overrides FieldItemInterface:: |
|
FieldItemBase:: |
protected | function |
Different to the parent Map class, we avoid creating property objects as
far as possible in order to optimize performance. Thus we just update
$this->values if no property object has been created yet. Overrides Map:: |
|
FieldItemBase:: |
public | function |
Constructs a TypedData object given its definition and context. Overrides TypedData:: |
1 |
FieldItemBase:: |
public | function |
Magic method: Gets a property value. Overrides FieldItemInterface:: |
1 |
FieldItemBase:: |
public | function |
Magic method: Determines whether a property is set. Overrides FieldItemInterface:: |
|
FieldItemBase:: |
public | function |
Magic method: Sets a property value. Overrides FieldItemInterface:: |
1 |
FieldItemBase:: |
public | function |
Magic method: Unsets a property. Overrides FieldItemInterface:: |
|
Map:: |
protected | property |
The data definition. Overrides TypedData:: |
|
Map:: |
protected | property | The array of properties. | |
Map:: |
protected | property | An array of values for the contained properties. | |
Map:: |
public | function |
Applies the default value. Overrides TypedData:: |
4 |
Map:: |
public | function |
Gets a property object. Overrides ComplexDataInterface:: |
|
Map:: |
public | function | ||
Map:: |
public | function |
Gets an array of property objects. Overrides ComplexDataInterface:: |
|
Map:: |
public | function |
Returns a string representation of the data. Overrides TypedData:: |
|
Map:: |
public | function |
Sets a property value. Overrides ComplexDataInterface:: |
|
Map:: |
public | function |
Returns an array of all property values. Overrides ComplexDataInterface:: |
1 |
Map:: |
public | function | Magic method: Implements a deep clone. | |
StringTranslationTrait:: |
protected | property | The string translation service. | |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TypedData:: |
protected | property | The property name. | |
TypedData:: |
protected | property | The parent typed data object. | |
TypedData:: |
public static | function |
Constructs a TypedData object given its definition and context. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Gets the data definition. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Returns the name of a property or item. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Returns the parent data structure; i.e. either complex data or a list. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
TypedData:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
TypedData:: |
public | function |
Returns the property path of the data. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Returns the root of the typed data tree. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Sets the context of a property or item via a context aware parent. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Validates the currently set data value. Overrides TypedDataInterface:: |
|
TypedDataTrait:: |
protected | property | The typed data manager used for creating the data types. | |
TypedDataTrait:: |
public | function | Gets the typed data manager. | 1 |
TypedDataTrait:: |
public | function | Sets the typed data manager. | 1 |