Drupal 8  8.0.2
FieldItemList Class Reference
Inheritance diagram for FieldItemList:

Public Member Functions

 getEntity ()
 
 setLangcode ($langcode)
 
 getLangcode ()
 
 getFieldDefinition ()
 
 getSettings ()
 
 getSetting ($setting_name)
 
 filterEmptyItems ()
 
 getValue ($include_computed=FALSE)
 
 setValue ($values, $notify=TRUE)
 
 __get ($property_name)
 
 __set ($property_name, $value)
 
 __isset ($property_name)
 
 __unset ($property_name)
 
 access ($operation= 'view', AccountInterface $account=NULL, $return_as_object=FALSE)
 
 defaultAccess ($operation= 'view', AccountInterface $account=NULL)
 
 applyDefaultValue ($notify=TRUE)
 
 preSave ()
 
 postSave ($update)
 
 delete ()
 
 deleteRevision ()
 
 view ($display_options=array())
 
 generateSampleItems ($count=1)
 
 getConstraints ()
 
 defaultValuesForm (array &$form, FormStateInterface $form_state)
 
 defaultValuesFormValidate (array $element, array &$form, FormStateInterface $form_state)
 
 defaultValuesFormSubmit (array $element, array &$form, FormStateInterface $form_state)
 
 equals (FieldItemListInterface $list_to_compare)
 
- Public Member Functions inherited from ItemList
 getValue ()
 
 setValue ($values, $notify=TRUE)
 
 getString ()
 
 get ($index)
 
 set ($index, $value)
 
 removeItem ($index)
 
 first ()
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 appendItem ($value=NULL)
 
 getItemDefinition ()
 
 getIterator ()
 
 count ()
 
 isEmpty ()
 
 filter ($callback)
 
 onChange ($delta)
 
 __clone ()
 
- Public Member Functions inherited from TypedData
 __construct ($definition, $name=NULL, TypedDataInterface $parent=NULL)
 
 getPluginId ()
 
 getPluginDefinition ()
 
 getDataDefinition ()
 
 getValue ()
 
 setValue ($value, $notify=TRUE)
 
 getString ()
 
 getConstraints ()
 
 validate ()
 
 applyDefaultValue ($notify=TRUE)
 
 setContext ($name=NULL, TraversableTypedDataInterface $parent=NULL)
 
 getName ()
 
 getRoot ()
 
 getPropertyPath ()
 
 getParent ()
 

Static Public Member Functions

static processDefaultValue ($default_value, FieldableEntityInterface $entity, FieldDefinitionInterface $definition)
 
- Static Public Member Functions inherited from TypedData
static createInstance ($definition, $name=NULL, TraversableTypedDataInterface $parent=NULL)
 

Protected Member Functions

 createItem ($offset=0, $value=NULL)
 
 delegateMethod ($method)
 
 defaultValueWidget (FormStateInterface $form_state)
 
- Protected Member Functions inherited from ItemList
 rekey ($from_index=0)
 
 createItem ($offset=0, $value=NULL)
 

Protected Attributes

 $list = array()
 
 $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED
 
- Protected Attributes inherited from ItemList
 $list = array()
 
- Protected Attributes inherited from TypedData
 $definition
 
 $name
 
 $parent
 

Detailed Description

Represents an entity field; that is, a list of field item objects.

An entity field is a list of field items, each containing a set of properties. Note that even single-valued entity fields are represented as list of field items, however for easy access to the contained item the entity field delegates __get() and __set() calls directly to the first item.

Member Function Documentation

__get (   $property_name)

{Magic method: Gets a property value of to the first field item.

See Also
::__get()
}

Implements FieldItemListInterface.

References ItemList\first().

Here is the call graph for this function:

__isset (   $property_name)

{Magic method: Determines whether a property of the first field item is set.

See Also
::__isset()
}

Implements FieldItemListInterface.

References ItemList\first().

Here is the call graph for this function:

__set (   $property_name,
  $value 
)

{Magic method: Sets a property value of the first field item.

See Also
::__set()
}

Implements FieldItemListInterface.

References ItemList\appendItem(), and ItemList\first().

Here is the call graph for this function:

__unset (   $property_name)

{Magic method: Unsets a property of the first field item.

See Also
::__unset()
}

Implements FieldItemListInterface.

References ItemList\first().

Here is the call graph for this function:

access (   $operation = 'view',
AccountInterface  $account = NULL,
  $return_as_object = FALSE 
)

{Checks data value access.

Parameters
string$operationThe operation to be performed.
\Drupal\Core\Session\AccountInterface$account(optional) The user for which to check access, or NULL to check access for the current user. Defaults to NULL.
bool$return_as_object(optional) Defaults to FALSE.
Returns
bool| The access result. Returns a boolean if $return_as_object is FALSE (this is the default) and otherwise an AccessResultInterface object. When a boolean is returned, the result of AccessInterface::isAllowed() is returned, i.e. TRUE means access is explicitly allowed, FALSE means access is either explicitly forbidden or "no opinion".
}

Implements AccessibleInterface.

References Drupal\entityManager(), FieldItemList\getEntity(), and FieldItemList\getFieldDefinition().

Here is the call graph for this function:

applyDefaultValue (   $notify = TRUE)

{Applies the default value.

Parameters
bool$notify(optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.
Returns
Returns itself to allow for chaining.
}

Implements TypedDataInterface.

References ItemList\appendItem(), FieldItemList\filterEmptyItems(), ItemList\first(), FieldItemList\getEntity(), FieldItemList\getFieldDefinition(), and FieldItemList\setValue().

Here is the call graph for this function:

createItem (   $offset = 0,
  $value = NULL 
)
protected

{}

defaultAccess (   $operation = 'view',
AccountInterface  $account = NULL 
)

{Contains the default access logic of this field.See ::fieldAccess() for the parameter documentation.

Returns
The access result.
}

Implements FieldItemListInterface.

References AccessResult\allowed().

Here is the call graph for this function:

defaultValuesForm ( array &  $form,
FormStateInterface  $form_state 
)

{Returns a form for the default value input.Invoked from to allow administrators to configure instance-level default value.

Parameters
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.
Returns
array The form definition for the field default value.
}

Implements FieldItemListInterface.

References t().

Here is the call graph for this function:

defaultValuesFormSubmit ( array  $element,
array &  $form,
FormStateInterface  $form_state 
)

{Processes the submitted default value.Invoked from to allow administrators to configure instance-level default value.

Parameters
array$elementThe default value form element.
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.
Returns
array The field default value.
}

Implements FieldItemListInterface.

defaultValuesFormValidate ( array  $element,
array &  $form,
FormStateInterface  $form_state 
)

{Validates the submitted default value.Invoked from to allow administrators to configure instance-level default value.

Parameters
array$elementThe default value form element.
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.
}

Implements FieldItemListInterface.

defaultValueWidget ( FormStateInterface  $form_state)
protected

Returns the widget object used in default value form.

Parameters
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.
Returns
|null A Widget object or NULL if no widget is available.

References FormStateInterface\get(), FormStateInterface\has(), Drupal\service(), and FormStateInterface\set().

Here is the call graph for this function:

delegateMethod (   $method)
protected

Calls a method on each FieldItem.

Any argument passed will be forwarded to the invoked method.

Parameters
string$methodThe name of the method to be invoked.
Returns
array An array of results keyed by delta.

Referenced by FieldItemList\delete(), FieldItemList\deleteRevision(), FieldItemList\postSave(), and FieldItemList\preSave().

Here is the caller graph for this function:

delete ( )

{Defines custom delete behavior for field values.This method is called during the process of deleting an entity, just before values are deleted from storage.}

Implements FieldItemListInterface.

References FieldItemList\delegateMethod().

Here is the call graph for this function:

deleteRevision ( )

{Defines custom revision delete behavior for field values.This method is called from during the process of deleting an entity revision, just before the field values are deleted from storage. It is only called for entity types that support revisioning.}

Implements FieldItemListInterface.

References FieldItemList\delegateMethod().

Here is the call graph for this function:

equals ( FieldItemListInterface  $list_to_compare)

{Determines equality to another object implementing FieldItemListInterface.

Parameters
\Drupal\Core\Field\FieldItemListInterface$list_to_compareThe field item list to compare to.
Returns
bool TRUE if the field item lists are equal, FALSE if not.
}

Implements FieldItemListInterface.

References TypedDataInterface\getValue().

Here is the call graph for this function:

filterEmptyItems ( )

{Filters out empty field items and re-numbers the item deltas.

Returns
$this
}

Implements FieldItemListInterface.

References ItemList\filter().

Referenced by FieldItemList\applyDefaultValue(), and FieldItemList\preSave().

Here is the call graph for this function:

Here is the caller graph for this function:

generateSampleItems (   $count = 1)

{}

Implements FieldItemListInterface.

References Drupal\service().

Here is the call graph for this function:

getConstraints ( )

{Gets a list of validation constraints.

Returns
array Array of constraints, each being an instance of .
}

Implements TypedDataInterface.

References FieldStorageDefinitionInterface\CARDINALITY_UNLIMITED, and t().

Here is the call graph for this function:

getEntity ( )

{Gets the entity that field belongs to.

Returns
The entity object.
}

Implements FieldItemListInterface.

References TypedData\getParent().

Referenced by FieldItemList\access(), FieldItemList\applyDefaultValue(), and CommentFieldItemList\get().

Here is the call graph for this function:

Here is the caller graph for this function:

getFieldDefinition ( )

{Gets the field definition.

Returns
The field definition.
}

Implements FieldItemListInterface.

Referenced by FieldItemList\access(), FieldItemList\applyDefaultValue(), DateTimeFieldItemList\defaultValuesForm(), CommentFieldItemList\get(), and EntityReferenceFieldItemList\referencedEntities().

Here is the caller graph for this function:

getLangcode ( )

{Gets the langcode of the field values held in the object.

Returns
$langcode The langcode.
}

Implements FieldItemListInterface.

getSetting (   $setting_name)

{Returns the value of a given field setting.

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

Implements FieldItemListInterface.

Referenced by EntityReferenceFieldItemList\defaultValuesFormSubmit().

Here is the caller graph for this function:

getSettings ( )

{Returns the array of field settings.

Returns
array An array of key/value pairs.
}

Implements FieldItemListInterface.

getValue (   $include_computed = FALSE)

{}

Todo:
Revisit the need when all entity types are converted to NG entities.
postSave (   $update)

{Defines custom post-save behavior for field values.This method is called during the process of saving an entity, just after item values are written into storage.

Parameters
bool$updateSpecifies whether the entity is being updated or created.
Returns
bool Whether field items should be rewritten to the storage as a consequence of the logic implemented by the custom behavior.
See Also
::postSave()
}

Implements FieldItemListInterface.

References FieldItemList\delegateMethod().

Here is the call graph for this function:

preSave ( )

{Defines custom presave behavior for field values.This method is called during the process of saving an entity, just before item values are written into storage.

See Also
::preSave()
}

Implements FieldItemListInterface.

References FieldItemList\delegateMethod(), and FieldItemList\filterEmptyItems().

Here is the call graph for this function:

static processDefaultValue (   $default_value,
FieldableEntityInterface  $entity,
FieldDefinitionInterface  $definition 
)
static

{Processes the default value before being applied.Defined or configured default values of a field might need some processing in order to be a valid runtime value for the field type; e.g., a date field could process the defined value of 'NOW' to a valid date.

Parameters
arrayThe unprocessed default value defined for the field, as a numerically indexed array of items, each item being an array of property/value pairs.
\Drupal\Core\Entity\FieldableEntityInterface$entityThe entity for which the default value is generated.
\Drupal\Core\Field\FieldDefinitionInterface$definitionThe definition of the field.
Returns
array The return default value for the field.
}

Implements FieldItemListInterface.

setLangcode (   $langcode)

{Sets the langcode of the field values held in the object.

Parameters
string$langcodeThe langcode.
}

Implements FieldItemListInterface.

setValue (   $values,
  $notify = TRUE 
)

{Sets the data value.

Parameters
mixed | null$valueThe value to set in the format as documented for the data type or NULL to unset the data value.
bool$notify(optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.
Exceptions
\InvalidArgumentExceptionIf the value input is inappropriate.
\Drupal\Core\TypedData\Exception\ReadOnlyExceptionIf the data is read-only.
}

Implements TypedDataInterface.

Referenced by FieldItemList\applyDefaultValue().

Here is the caller graph for this function:

view (   $display_options = array())

{Returns a renderable array for the field items.

Parameters
array$display_optionsCan be either the name of a view mode, or an array of display settings. See EntityViewBuilderInterface::viewField() for more information.
Returns
array A renderable array for the field values.
See Also
::viewField()
::view()
}

Implements FieldItemListInterface.

References Drupal\entityManager().

Here is the call graph for this function:


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