TypedConfigManagerInterface
interface TypedConfigManagerInterface implements TypedDataManagerInterface (View source)
Defines an interface for managing config schema type plugins.
Methods
Gets a specific plugin definition.
Indicates if a specific plugin definition exists.
Creates a pre-configured instance of a plugin.
Gets a preconfigured instance of a plugin.
Clears static and persistent plugin definition caches.
Creates a new typed data object instance.
Creates a new data definition object.
Creates a new list data definition for items of the given data type.
Get a typed data instance for a property of a given typed data object.
Gets the validator for validating typed data.
Sets the validator for validating typed data.
Gets the validation constraint manager.
Sets the validation constraint manager.
Gets default constraints for the given data definition.
Gets the canonical representation of a TypedData object.
Gets typed configuration data.
Creates a new data definition object from a type definition array and actual configuration data. Since type definitions may contain variables to be replaced, we need the configuration value to create it.
Checks if the configuration schema with the given config name exists.
Gets typed data for a given configuration name and its values.
Details
mixed
getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)
Gets a specific plugin definition.
array
getDefinitions()
Gets the definition of all plugins for this type.
bool
hasDefinition(string $plugin_id)
Indicates if a specific plugin definition exists.
object
createInstance(string $plugin_id, array $configuration = [])
Creates a pre-configured instance of a plugin.
object|false
getInstance(array $options)
Gets a preconfigured instance of a plugin.
clearCachedDefinitions()
Clears static and persistent plugin definition caches.
Don't resort to calling \Drupal::cache()->delete() and friends to make Drupal detect new or updated plugin definitions. Always use this method on the appropriate plugin type's plugin manager!
useCaches(bool $use_caches = FALSE)
Disable the use of caches.
Can be used to ensure that uncached plugin definitions are returned, without invalidating all cached information.
This will also remove all local/static caches.
TypedDataInterface
create(DataDefinitionInterface $definition, mixed $value = NULL, string $name = NULL, mixed $parent = NULL)
Creates a new typed data object instance.
DataDefinitionInterface
createDataDefinition(string $data_type)
Creates a new data definition object.
While data definitions objects may be created directly if the definition class used by a data type is known, this method allows the creation of data definitions for any given data type.
For example, if a definition for a map is to be created, the following code could be used instead of calling this method with the argument 'map':
ListDataDefinitionInterface
createListDataDefinition(string $item_type)
Creates a new list data definition for items of the given data type.
TypedDataInterface
getPropertyInstance(TypedDataInterface $object, string $property_name, mixed $value = NULL)
Get a typed data instance for a property of a given typed data object.
This method will use prototyping for fast and efficient instantiation of many property objects with the same property path; for example, when multiple comments are used comment_body.0.value needs to be instantiated very often.
Prototyping is done by the root object's data type and the given property path, i.e. all property instances having the same property path and inheriting from the same data type are prototyped.
ValidatorInterface
getValidator()
Gets the validator for validating typed data.
setValidator(ValidatorInterface $validator)
Sets the validator for validating typed data.
ConstraintManager
getValidationConstraintManager()
Gets the validation constraint manager.
setValidationConstraintManager(ConstraintManager $constraintManager)
Sets the validation constraint manager.
The validation constraint manager is used to instantiate validation constraint plugins.
array
getDefaultConstraints(DataDefinitionInterface $definition)
Gets default constraints for the given data definition.
This generates default constraint definitions based on the data definition; for example, a NotNull constraint is generated if the data is defined as required. Besides that, any constraints defined for the data type (that is, below the 'constraint' key of the type's plugin definition) are taken into account.
mixed
getCanonicalRepresentation(TypedDataInterface $data)
Gets the canonical representation of a TypedData object.
The canonical representation is typically used when data is passed on to other code components. In many use cases, the TypedData object is mostly unified adapter wrapping a primary value (a string, an entity, etc.) which is the canonical representation that consuming code like constraint validators are really interested in. For some APIs, though, the domain object (for example, Field API's FieldItem and FieldItemList) directly implements TypedDataInterface, and the canonical representation is thus the data object itself.
When a TypedData object gets validated, for example, its canonical representation is passed on to constraint validators, which thus receive an Entity unwrapped, but a FieldItem as is.
Data types specify whether their data objects need unwrapping by using the 'unwrap_for_canonical_representation' property in the data definition (defaults to TRUE).
TraversableTypedDataInterface
get(string $name)
Gets typed configuration data.
DataDefinitionInterface
buildDataDefinition(array $definition, $value, string $name = NULL, object $parent = NULL)
Creates a new data definition object from a type definition array and actual configuration data. Since type definitions may contain variables to be replaced, we need the configuration value to create it.
bool
hasConfigSchema(string $name)
Checks if the configuration schema with the given config name exists.
TraversableTypedDataInterface
createFromNameAndData(string $config_name, array $config_data)
Gets typed data for a given configuration name and its values.