MapDataDefinition
class MapDataDefinition extends ComplexDataDefinitionBase (View source)
A typed data definition class for defining maps.
Traits
Wrapper methods for classes that needs typed data manager object.
Properties
| protected TypedDataManagerInterface | $typedDataManager | The typed data manager used for creating the data types. |
from TypedDataTrait |
| protected array | $definition | The array holding values for all definition keys. |
from DataDefinition |
| protected DataDefinitionInterface[] | $propertyDefinitions | An array of data definitions. |
from ComplexDataDefinitionBase |
| protected string | $mainPropertyName | The name of the main property, or NULL if there is none. |
Methods
Creates a new map definition.
Creates a new data definition object.
Sets the human-readable description.
Returns whether the data is multi-valued, i.e. a list of data items.
Sets the class used for creating the typed data object.
Returns the array of settings, as required by the used class.
Sets the array of settings, as required by the used class.
Sets a definition setting.
Sets an array of validation constraints.
Adds a validation constraint.
Sets the whether the data value should be internal.
Gets an array of property definitions of contained properties.
Gets the definition of a contained property.
Returns the name of the main property, if any.
Sets the definition of a map property.
Sets the main property name.
Details
$this
setTypedDataManager(TypedDataManagerInterface $typed_data_manager)
Sets the typed data manager.
TypedDataManagerInterface
getTypedDataManager()
Gets the typed data manager.
static DataDefinition
create(string $type = 'map')
Creates a new map definition.
static DataDefinitionInterface
createFromDataType($data_type)
Creates a new data definition object.
This method is typically used by \Drupal\Core\TypedData\TypedDataManager::createDataDefinition() to build a definition object for an arbitrary data type. When the definition class is known, it is recommended to directly use the static create() method on that class instead; e.g.:
__construct(array $values = [])
Constructs a new data definition object.
string
getDataType()
Returns the data type of the data.
DataDefinition
setDataType(string $type)
Sets the data type.
string|TranslatableMarkup
getLabel()
Returns a human readable label.
DataDefinition
setLabel(string $label)
Sets the human-readable label.
string|null
getDescription()
Returns a human readable description.
Descriptions are usually used on user interfaces where the data is edited or displayed.
DataDefinition
setDescription(string $description)
Sets the human-readable description.
bool
isList()
Returns whether the data is multi-valued, i.e. a list of data items.
This is equivalent to checking whether the data definition implements the \Drupal\Core\TypedData\ListDefinitionInterface interface.
bool
isReadOnly()
Determines whether the data is read-only.
DataDefinition
setReadOnly(bool $read_only)
Sets whether the data is read-only.
bool
isComputed()
Determines whether the data value is computed.
For example, data could be computed depending on some other values.
DataDefinition
setComputed(bool $computed)
Sets whether the data is computed.
bool
isRequired()
Determines whether a data value is required.
For required data a non-NULL value is mandatory.
DataDefinition
setRequired(bool $required)
Sets whether the data is required.
string
getClass()
Returns the class used for creating the typed data object.
If not specified, the default class of the data type will be returned.
DataDefinition
setClass(string|null $class)
Sets the class used for creating the typed data object.
array
getSettings()
Returns the array of settings, as required by the used class.
See the documentation of the class for supported or required settings.
DataDefinition
setSettings(array $settings)
Sets the array of settings, as required by the used class.
mixed
getSetting(string $setting_name)
Returns the value of a given setting.
DataDefinition
setSetting(string $setting_name, mixed $value)
Sets a definition setting.
array[]
getConstraints()
Returns an array of validation constraints.
The validation constraints of a definition consist of any for it defined constraints and default constraints, which are generated based on the definition and its data type. See \Drupal\Core\TypedData\TypedDataManager::getDefaultConstraints().
Constraints are defined via an array, having constraint plugin IDs as key and constraint options as values, e.g.
array
getConstraint(string $constraint_name)
Returns a validation constraint.
See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for details.
$this
setConstraints(array $constraints)
Sets an array of validation constraints.
DataDefinitionInterface
addConstraint(string $constraint_name, array|null $options = NULL)
Adds a validation constraint.
See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for details.
offsetExists($offset)
{@inheritdoc}
This is for BC support only.
offsetGet($offset)
{@inheritdoc}
This is for BC support only.
offsetSet($offset, $value)
{@inheritdoc}
This is for BC support only.
offsetUnset($offset)
{@inheritdoc}
This is for BC support only.
array
toArray()
Returns all definition values as array.
__sleep()
{@inheritdoc}
bool
isInternal()
Determines whether the data value is internal.
This can be used in a scenario when it is not desirable to expose this data value to an external system.
$this
setInternal(bool $internal)
Sets the whether the data value should be internal.
DataDefinitionInterface[]
getPropertyDefinitions()
Gets an array of property definitions of contained properties.
DataDefinitionInterface|null
getPropertyDefinition(string $name)
Gets the definition of a contained property.
string|null
getMainPropertyName()
Returns the name of the main property, if any.
Some field items consist mainly of one main property, e.g. the value of a text field or the @code target_id @endcode of an entity reference. If the field item has no main property, the method returns NULL.
$this
setPropertyDefinition(string $name, DataDefinitionInterface $definition = NULL)
Sets the definition of a map property.
$this
setMainPropertyName(string|null $name)
Sets the main property name.