Drupal 8  8.0.2
DataDefinition Class Reference
Inheritance diagram for DataDefinition:

Public Member Functions

 __construct (array $values=array())
 
 getDataType ()
 
 setDataType ($type)
 
 getLabel ()
 
 setLabel ($label)
 
 getDescription ()
 
 setDescription ($description)
 
 isList ()
 
 isReadOnly ()
 
 setReadOnly ($read_only)
 
 isComputed ()
 
 setComputed ($computed)
 
 isRequired ()
 
 setRequired ($required)
 
 getClass ()
 
 setClass ($class)
 
 getSettings ()
 
 setSettings (array $settings)
 
 getSetting ($setting_name)
 
 setSetting ($setting_name, $value)
 
 getConstraints ()
 
 getConstraint ($constraint_name)
 
 setConstraints (array $constraints)
 
 addConstraint ($constraint_name, $options=NULL)
 
 offsetExists ($offset)
 
offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 toArray ()
 

Static Public Member Functions

static create ($type)
 
static createFromDataType ($type)
 

Protected Attributes

 $definition = array()
 

Detailed Description

A typed data definition class for defining data based on defined data types.

Constructor & Destructor Documentation

__construct ( array  $values = array())

Constructs a new data definition object.

Parameters
array$values(optional) If given, an array of initial values to set on the definition.

Member Function Documentation

addConstraint (   $constraint_name,
  $options = NULL 
)

{Adds a validation constraint.See ::getConstraints() for details.

Parameters
string$constraint_nameThe name of the constraint to add, i.e. its plugin id.
array | null$optionsThe constraint options as required by the constraint plugin, or NULL.
Returns
static The object itself for chaining.
}

Implements DataDefinitionInterface.

Referenced by EntityDataDefinition\setBundles(), and EntityDataDefinition\setEntityTypeId().

Here is the caller graph for this function:

static create (   $type)
static

Creates a new data definition.

Parameters
string$typeThe data type of the data; e.g., 'string', 'integer' or 'any'.
Returns
static A new DataDefinition object.

Referenced by BundleConstraintValidatorTest\assertValidation(), ListDataDefinition\createFromDataType(), TypedDataTest\createTypedData(), TextItemBase\propertyDefinitions(), ListFloatItem\propertyDefinitions(), ListIntegerItem\propertyDefinitions(), PasswordItem\propertyDefinitions(), ListStringItem\propertyDefinitions(), StringItemBase\propertyDefinitions(), FloatItem\propertyDefinitions(), EmailItem\propertyDefinitions(), PathItem\propertyDefinitions(), ShapeItem\propertyDefinitions(), FieldTestItem\propertyDefinitions(), TextWithSummaryItem\propertyDefinitions(), TimestampItem\propertyDefinitions(), DecimalItem\propertyDefinitions(), LanguageItem\propertyDefinitions(), BooleanItem\propertyDefinitions(), TelephoneItem\propertyDefinitions(), LinkItem\propertyDefinitions(), UriItem\propertyDefinitions(), DateTimeItem\propertyDefinitions(), TestItem\propertyDefinitions(), IntegerItem\propertyDefinitions(), CommentItem\propertyDefinitions(), EntityReferenceItem\propertyDefinitions(), FileItem\propertyDefinitions(), ImageItem\propertyDefinitions(), ContextHandlerTest\testApplyContextMapping(), ContextHandlerTest\testApplyContextMappingConfigurableAssigned(), RecursiveContextualValidatorTest\testBasicValidateWithConstraint(), RecursiveContextualValidatorTest\testBasicValidateWithMultipleConstraints(), RecursiveContextualValidatorTest\testBasicValidateWithoutConstraints(), ContextTypedDataTest\testGetContextValue(), TypedDataDefinitionTest\testMaps(), FilterAPITest\testTypedDataAPI(), TypedDataTest\testTypedDataMaps(), TypedDataTest\testTypedDataValidation(), AllowedValuesConstraintValidatorTest\testValidation(), EntityTypeConstraintValidatorTest\testValidation(), and ComplexDataConstraintValidatorTest\testValidation().

Here is the caller graph for this function:

static createFromDataType (   $type)
static

{Creates a new data definition object.This method is typically used by ::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.:

Parameters
string$data_typeThe data type, for which a data definition should be created.
Returns
static
Exceptions
\InvalidArgumentExceptionIf an unsupported data type gets passed to the class; e.g., 'string' to a definition class handling 'entity:* data types.
}

Implements DataDefinitionInterface.

getClass ( )

{Returns the class used for creating the typed data object.If not specified, the default class of the data type will be returned.

Returns
string The class used for creating the typed data object.
}

Implements DataDefinitionInterface.

References DataDefinition\getDataType(), and Drupal\typedDataManager().

Here is the call graph for this function:

getConstraint (   $constraint_name)

{Returns a validation constraint.See ::getConstraints() for details.

Parameters
string$constraint_nameThe name of the constraint, i.e. its plugin id.
Returns
array A validation constraint definition which can be used for instantiating a object.
See Also
}

Implements DataDefinitionInterface.

References DataDefinition\getConstraints().

Here is the call graph for this function:

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 ::getDefaultConstraints().Constraints are defined via an array, having constraint plugin IDs as key and constraint options as values, e.g.

$constraints = array(
'Range' => array('min' => 5, 'max' => 10),
'NotBlank' => array(),
);

Options have to be specified using another array if the constraint has more than one or zero options. If it has exactly one option, the value should be specified without nesting it into another array:

$constraints = array(
'EntityType' => 'node',
'Bundle' => 'article',
);
Note that the specified constraints must be compatible with the data type, e.g. for data of type 'entity' the 'EntityType' and 'Bundle' constraints may be specified.
See Also
Returns
array[] An array of validation constraint definitions, keyed by constraint name. Each constraint definition can be used for instantiating objects.
See Also
}

Implements DataDefinitionInterface.

References Drupal\typedDataManager().

Referenced by DataDefinition\getConstraint().

Here is the call graph for this function:

Here is the caller graph for this function:

getDataType ( )

{Returns the data type of the data.

Returns
string The data type.
}

Implements DataDefinitionInterface.

Referenced by DataDefinition\getClass().

Here is the caller graph for this function:

getDescription ( )

{Returns a human readable description.Descriptions are usually used on user interfaces where the data is edited or displayed.

Returns
string|null The description, or NULL if no description is available.
}

Implements DataDefinitionInterface.

getLabel ( )

{Returns a human readable label.

Returns
string| The label. A string or an instance of TranslatableMarkup will be returned based on the way the label translation is handled.
}

Implements DataDefinitionInterface.

getSetting (   $setting_name)

{Returns the value of a given setting.

Parameters
string$setting_nameThe setting name.
Returns
mixed The setting value.
}

Implements DataDefinitionInterface.

getSettings ( )

{Returns the array of settings, as required by the used class.See the documentation of the class for supported or required settings.

Returns
array The array of settings.
}

Implements DataDefinitionInterface.

isComputed ( )

{Determines whether the data value is computed.For example, data could be computed depending on some other values.

Returns
bool Whether the data value is computed.
}

Implements DataDefinitionInterface.

Referenced by BaseFieldDefinition\hasCustomStorage(), BaseFieldDefinition\isQueryable(), DataDefinition\isReadOnly(), and BaseFieldDefinition\setCustomStorage().

Here is the caller graph for this function:

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 interface.

Returns
bool Whether the data is multi-valued.
}

Implements DataDefinitionInterface.

isReadOnly ( )

{Determines whether the data is read-only.

Returns
bool Whether the data is read-only.
}

Implements DataDefinitionInterface.

References DataDefinition\isComputed().

Here is the call graph for this function:

isRequired ( )

{Determines whether a data value is required.For required data a non-NULL value is mandatory.

Returns
bool Whether a data value is required.
}

Implements DataDefinitionInterface.

offsetExists (   $offset)

{}

This is for BC support only.

Todo:
: Remove in https://www.drupal.org/node/1928868.
& offsetGet (   $offset)

{}

This is for BC support only.

Todo:
: Remove in https://www.drupal.org/node/1928868.
offsetSet (   $offset,
  $value 
)

{}

This is for BC support only.

Todo:
: Remove in https://www.drupal.org/node/1928868.
offsetUnset (   $offset)

{}

This is for BC support only.

Todo:
: Remove in https://www.drupal.org/node/1928868.
setClass (   $class)

Sets the class used for creating the typed data object.

Parameters
string | null$classThe class to use.
Returns
static The object itself for chaining.
setComputed (   $computed)

Sets whether the data is computed.

Parameters
bool$computedWhether the data is computed.
Returns
static The object itself for chaining.
setConstraints ( array  $constraints)

{}

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setDataType (   $type)

Sets the data type.

Parameters
string$typeThe data type to set.
Returns
static The object itself for chaining.
setDescription (   $description)

Sets the human-readable description.

Parameters
string$descriptionThe description to set.
Returns
static The object itself for chaining.

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setLabel (   $label)

Sets the human-readable label.

Parameters
string$labelThe label to set.
Returns
static The object itself for chaining.

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setReadOnly (   $read_only)

Sets whether the data is read-only.

Parameters
bool$read_onlyWhether the data is read-only.
Returns
static The object itself for chaining.
setRequired (   $required)

Sets whether the data is required.

Parameters
bool$requiredWhether the data is required.
Returns
static The object itself for chaining.
setSetting (   $setting_name,
  $value 
)

Sets a definition setting.

Parameters
string$setting_nameThe definition setting to set.
mixed$valueThe value to set.
Returns
static The object itself for chaining.
setSettings ( array  $settings)

Sets the array of settings, as required by the used class.

Parameters
array$settingsThe array of settings.
Returns
static The object itself for chaining.
toArray ( )

Returns all definition values as array.

Returns
array

Referenced by BaseFieldOverride\createFromBaseFieldDefinition().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: