ArrayElement
abstract class ArrayElement extends Element implements IteratorAggregate, TypedConfigInterface, ComplexDataInterface (View source)
Defines a generic configuration element that contains multiple properties.
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 mixed | $value | The configuration value. |
from Element |
| protected | $elements | Parsed elements. |
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.
Sets the context of a property or item via a context aware parent.
Gets valid configuration data keys.
Builds an array of contained elements.
Gets data definition object for contained element.
Gets a contained typed configuration element.
Gets an array of contained elements.
Determines whether the data structure is empty.
Returns an array of all property values.
React to changes to a child property or item.
{@inheritdoc}
Creates a contained typed configuration object.
Creates a new data definition object from a type definition array and actual configuration data.
Determines if this element allows NULL as a value.
Sets a property value.
Gets an array of property objects.
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(mixed|null $value, bool $notify = TRUE)
Sets the data value.
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.
protected array
getAllKeys()
Gets valid configuration data keys.
protected TypedDataInterface[]
parse()
Builds an array of contained elements.
abstract protected DataDefinitionInterface
getElementDefinition(int|string $key)
Gets data definition object for contained element.
TypedDataInterface
get($name)
Gets a contained typed configuration element.
array
getElements()
Gets an array of contained elements.
bool
isEmpty()
Determines whether the data structure is empty.
array
toArray()
Returns an array of all property values.
onChange($name)
React to changes to a child property or item.
Note that this is invoked after any changes have been applied.
getIterator()
{@inheritdoc}
protected TypedDataInterface
createElement(DataDefinitionInterface $definition, mixed $value, string $key)
Creates a contained typed configuration object.
protected DataDefinitionInterface
buildDataDefinition(array $definition, $value, string $key)
Creates a new data definition object from a type definition array and actual configuration data.
bool
isNullable()
Determines if this element allows NULL as a value.
$this
set($property_name, $value, bool $notify = TRUE)
Sets a property value.
TypedDataInterface[]
getProperties(bool $include_computed = FALSE)
Gets an array of property objects.