class MapDataDefinition
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/TypedData/MapDataDefinition.php \Drupal\Core\TypedData\MapDataDefinition
- 10 core/lib/Drupal/Core/TypedData/MapDataDefinition.php \Drupal\Core\TypedData\MapDataDefinition
- 9 core/lib/Drupal/Core/TypedData/MapDataDefinition.php \Drupal\Core\TypedData\MapDataDefinition
- 8.9.x core/lib/Drupal/Core/TypedData/MapDataDefinition.php \Drupal\Core\TypedData\MapDataDefinition
A typed data definition class for defining maps.
Hierarchy
- class \Drupal\Core\TypedData\DataDefinition implements \Drupal\Core\TypedData\DataDefinitionInterface, \Drupal\Core\TypedData\ArrayAccess uses \Drupal\Core\TypedData\TypedDataTrait
- class \Drupal\Core\TypedData\ComplexDataDefinitionBase implements \Drupal\Core\TypedData\ComplexDataDefinitionInterface extends \Drupal\Core\TypedData\DataDefinition
- class \Drupal\Core\TypedData\MapDataDefinition extends \Drupal\Core\TypedData\ComplexDataDefinitionBase
- class \Drupal\Core\TypedData\ComplexDataDefinitionBase implements \Drupal\Core\TypedData\ComplexDataDefinitionInterface extends \Drupal\Core\TypedData\DataDefinition
Expanded class hierarchy of MapDataDefinition
13 files declare their use of MapDataDefinition
- ComplexDataConstraintValidatorTest.php in core/
tests/ Drupal/ KernelTests/ Core/ TypedData/ ComplexDataConstraintValidatorTest.php - EntityBundleExistsConstraintValidatorTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityBundleExistsConstraintValidatorTest.php - LinkItem.php in core/
modules/ link/ src/ Plugin/ Field/ FieldType/ LinkItem.php - Map.php in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ Map.php - MapDataNormalizerTest.php in core/
modules/ serialization/ tests/ src/ Kernel/ MapDataNormalizerTest.php
1 string reference to 'MapDataDefinition'
- core.data_types.schema.yml in core/
config/ schema/ core.data_types.schema.yml - core/config/schema/core.data_types.schema.yml
File
-
core/
lib/ Drupal/ Core/ TypedData/ MapDataDefinition.php, line 8
Namespace
Drupal\Core\TypedDataView source
class MapDataDefinition extends ComplexDataDefinitionBase {
/**
* The name of the main property, or NULL if there is none.
*
* @var string
*/
protected $mainPropertyName = NULL;
/**
* Creates a new map definition.
*
* @param string $type
* (optional) The data type of the map. Defaults to 'map'.
*
* @return static
*/
public static function create($type = 'map') {
$definition['type'] = $type;
return new static($definition);
}
/**
* {@inheritdoc}
*/
public static function createFromDataType($data_type) {
return static::create($data_type);
}
/**
* {@inheritdoc}
*/
public function getPropertyDefinitions() {
if (!isset($this->propertyDefinitions)) {
$this->propertyDefinitions = [];
}
return $this->propertyDefinitions;
}
/**
* Sets the definition of a map property.
*
* @param string $name
* The name of the property to define.
* @param \Drupal\Core\TypedData\DataDefinitionInterface|null $definition
* (optional) The property definition to set, or NULL to unset it.
*
* @return $this
*/
public function setPropertyDefinition($name, ?DataDefinitionInterface $definition = NULL) {
if (isset($definition)) {
$this->propertyDefinitions[$name] = $definition;
}
else {
unset($this->propertyDefinitions[$name]);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function getMainPropertyName() {
return $this->mainPropertyName;
}
/**
* Sets the main property name.
*
* @param string|null $name
* The name of the main property, or NULL if there is none.
*
* @return $this
*/
public function setMainPropertyName($name) {
$this->mainPropertyName = $name;
return $this;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.