CommentFieldItemList
class CommentFieldItemList extends FieldItemList (View source)
Defines an item list class for comment fields.
Traits
Provides dependency injection friendly methods for serialization.
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Wrapper methods for classes that needs typed data manager object.
Properties
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected TypedDataManagerInterface | $typedDataManager | The typed data manager used for creating the data types. |
from TypedDataTrait |
| protected DataDefinitionInterface | $definition | The data definition. |
from TypedData |
| protected string | $name | The property name. |
from TypedData |
| protected TraversableTypedDataInterface|null | $parent | The parent typed data object. |
from TypedData |
| protected FieldItemInterface[] | $list | Numerically indexed array of field items. |
from FieldItemList |
| protected string | $langcode | The langcode of the field values held in the object. |
from FieldItemList |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Constructs a TypedData object given its definition and context.
Constructs a TypedData object given its definition and context.
Overrides \Drupal\Core\TypedData\TypedData::setValue().
Sets the context of a property or item via a context aware parent.
Returns the item at the specified position in this list.
Sets the value of the item at a given position in the list.
{@inheritdoc}
Helper for creating a list item object.
Filters the items in the list using a custom callback.
Sets the langcode of the field values held in the object.
Returns the value of a given field setting.
Filters out empty field items and re-numbers the item deltas.
Magic method: Gets a property value of to the first field item.
Magic method: Sets a property value of the first field item.
Magic method: Determines whether a property of the first field item is set.
Checks data value access.
Contains the default access logic of this field.
Returns a renderable array for the field items.
Populates a specified number of field items with valid sample data.
Returns a form for the default value input.
Validates the submitted default value.
Processes the submitted default value.
Processes the default value before being applied.
Returns the widget object used in default value form.
Determines equality to another object implementing FieldItemListInterface.
Determines whether the field has relevant changes.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
$this
setTypedDataManager(TypedDataManagerInterface $typed_data_manager)
Sets the typed data manager.
TypedDataManagerInterface
getTypedDataManager()
Gets the typed data manager.
static
createInstance(DataDefinitionInterface $definition, string|null $name = NULL, TraversableTypedDataInterface $parent = NULL)
Constructs a TypedData object given its definition and context.
__construct(DataDefinitionInterface $definition, string $name = NULL, TypedDataInterface $parent = NULL)
Constructs a TypedData object given its definition and context.
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
DataDefinitionInterface
getDataDefinition()
Gets the data definition.
mixed
getValue()
Gets the data value.
setValue(array|null $values, bool $notify = TRUE)
Overrides \Drupal\Core\TypedData\TypedData::setValue().
string
getString()
Returns a string representation of the data.
array
getConstraints()
Gets a list of validation constraints.
ConstraintViolationListInterface
validate()
Validates the currently set data value.
$this
applyDefaultValue(bool $notify = TRUE)
Applies the default value.
setContext(string|null $name = NULL, TraversableTypedDataInterface $parent = NULL)
Sets the context of a property or item via a context aware parent.
This method is supposed to be called by the factory only.
string|int|null
getName()
Returns the name of a property or item.
TraversableTypedDataInterface
getRoot()
Returns the root of the typed data tree.
Returns the root data for a tree of typed data objects; e.g. for an entity field item the root of the tree is its parent entity object.
string
getPropertyPath()
Returns the property path of the data.
The trail of property names relative to the root of the typed data tree, separated by dots; e.g. 'field_text.0.format'.
TraversableTypedDataInterface|null
getParent()
Returns the parent data structure; i.e. either complex data or a list.
TypedDataInterface|null
get(int $index)
Returns the item at the specified position in this list.
$this
set(int $index, mixed $value)
Sets the value of the item at a given position in the list.
$this
removeItem(int $index)
Removes the item at the specified position.
protected
rekey(int $from_index = 0)
Renumbers the items in the list.
TypedDataInterface|null
first()
Returns the first item in this list.
offsetExists($offset)
{@inheritdoc}
offsetUnset($offset)
{@inheritdoc}
offsetGet($offset)
{@inheritdoc}
offsetSet($offset, $value)
{@inheritdoc}
TypedDataInterface
appendItem(mixed $value = NULL)
Appends a new item to the list.
protected TypedDataInterface
createItem($offset = 0, $value = NULL)
Helper for creating a list item object.
DataDefinitionInterface
getItemDefinition()
Gets the definition of a contained item.
getIterator()
{@inheritdoc}
count()
{@inheritdoc}
bool
isEmpty()
Determines whether the list contains any non-empty items.
$this
filter(callable $callback)
Filters the items in the list using a custom callback.
onChange($delta)
React to changes to a child property or item.
Note that this is invoked after any changes have been applied.
__clone()
Magic method: Implements a deep clone.
FieldableEntityInterface
getEntity()
Gets the entity that field belongs to.
setLangcode(string $langcode)
Sets the langcode of the field values held in the object.
string
getLangcode()
Gets the langcode of the field values held in the object.
FieldDefinitionInterface
getFieldDefinition()
Gets the field definition.
array
getSettings()
Returns the array of field settings.
mixed
getSetting(string $setting_name)
Returns the value of a given field setting.
$this
filterEmptyItems()
Filters out empty field items and re-numbers the item deltas.
__get($property_name)
Magic method: Gets a property value of to the first field item.
__set($property_name, $value)
Magic method: Sets a property value of the first field item.
__isset($property_name)
Magic method: Determines whether a property of the first field item is set.
__unset($property_name)
Magic method: Unsets a property of the first field item.
bool|AccessResultInterface
access(string $operation = 'view', AccountInterface $account = NULL, bool $return_as_object = FALSE)
Checks data value access.
AccessResultInterface
defaultAccess($operation = 'view', AccountInterface $account = NULL)
Contains the default access logic of this field.
See \Drupal\Core\Entity\EntityAccessControlHandlerInterface::fieldAccess() for the parameter documentation.
preSave()
Defines custom presave behavior for field values.
This method is called during the process of saving an entity, just before item values are written into storage.
bool
postSave(bool $update)
Defines custom post-save behavior for field values.
This method is called during the process of saving an entity, just after item values are written into storage.
delete()
Defines custom delete behavior for field values.
This method is called during the process of deleting an entity, just before values are deleted from storage.
deleteRevision()
Defines custom revision delete behavior for field values.
This method is called from during the process of deleting an entity revision, just before the field values are deleted from storage. It is only called for entity types that support revisioning.
protected array
delegateMethod(string $method)
Calls a method on each FieldItem.
Any argument passed will be forwarded to the invoked method.
array
view(string|array $display_options = [])
Returns a renderable array for the field items.
generateSampleItems(int $count = 1)
Populates a specified number of field items with valid sample data.
array
defaultValuesForm(array $form, FormStateInterface $form_state)
Returns a form for the default value input.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure instance-level default value.
defaultValuesFormValidate(array $element, array $form, FormStateInterface $form_state)
Validates the submitted default value.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure instance-level default value.
array
defaultValuesFormSubmit(array $element, array $form, FormStateInterface $form_state)
Processes the submitted default value.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure instance-level default value.
static array
processDefaultValue(array $default_value, FieldableEntityInterface $entity, FieldDefinitionInterface $definition)
Processes the default value before being applied.
Defined or configured default values of a field might need some processing in order to be a valid runtime value for the field type; e.g., a date field could process the defined value of 'NOW' to a valid date.
protected WidgetInterface|null
defaultValueWidget(FormStateInterface $form_state)
Returns the widget object used in default value form.
bool
equals(FieldItemListInterface $list_to_compare)
Determines equality to another object implementing FieldItemListInterface.
This method is usually used by the storage to check for not computed value changes, which will be saved into the storage.
bool
hasAffectingChanges(FieldItemListInterface $original_items, string $langcode)
Determines whether the field has relevant changes.
This is for example used to determine if a revision of an entity has changes in a given translation. Unlike \Drupal\Core\Field\FieldItemListInterface::equals(), this can report that for example an untranslatable field, despite being changed and therefore technically affecting all translations, is only internal metadata or only affects a single translation.