Drupal 8  8.0.2
ImageItem Class Reference
Inheritance diagram for ImageItem:

Public Member Functions

 storageSettingsForm (array &$form, FormStateInterface $form_state, $has_data)
 
 fieldSettingsForm (array $form, FormStateInterface $form_state)
 
 preSave ()
 
 isDisplayed ()
 
- Public Member Functions inherited from FileItem
 storageSettingsForm (array &$form, FormStateInterface $form_state, $has_data)
 
 fieldSettingsForm (array $form, FormStateInterface $form_state)
 
 getUploadLocation ($data=array())
 
 getUploadValidators ()
 
 isDisplayed ()
 
- Public Member Functions inherited from EntityReferenceItem
 getConstraints ()
 
 setValue ($values, $notify=TRUE)
 
 getValue ()
 
 onChange ($property_name, $notify=TRUE)
 
 isEmpty ()
 
 preSave ()
 
 storageSettingsForm (array &$form, FormStateInterface $form_state, $has_data)
 
 fieldSettingsForm (array $form, FormStateInterface $form_state)
 
 hasNewEntity ()
 
 getPossibleValues (AccountInterface $account=NULL)
 
 getPossibleOptions (AccountInterface $account=NULL)
 
 getSettableValues (AccountInterface $account=NULL)
 
 getSettableOptions (AccountInterface $account=NULL)
 
- Public Member Functions inherited from FieldItemBase
 __construct (DataDefinitionInterface $definition, $name=NULL, TypedDataInterface $parent=NULL)
 
 getEntity ()
 
 getLangcode ()
 
 getFieldDefinition ()
 
 setValue ($values, $notify=TRUE)
 
 __get ($name)
 
 __set ($name, $value)
 
 __isset ($name)
 
 __unset ($name)
 
 view ($display_options=array())
 
 preSave ()
 
 postSave ($update)
 
 delete ()
 
 deleteRevision ()
 
 storageSettingsForm (array &$form, FormStateInterface $form_state, $has_data)
 
 fieldSettingsForm (array $form, FormStateInterface $form_state)
 
- Public Member Functions inherited from Map
 getValue ()
 
 setValue ($values, $notify=TRUE)
 
 getString ()
 
 get ($property_name)
 
 set ($property_name, $value, $notify=TRUE)
 
 getProperties ($include_computed=FALSE)
 
 toArray ()
 
 getIterator ()
 
 isEmpty ()
 
 __clone ()
 
 onChange ($property_name, $notify=TRUE)
 
 applyDefaultValue ($notify=TRUE)
 
- 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 ()
 
- Public Member Functions inherited from TraversableTypedDataInterface
 onChange ($name)
 

Static Public Member Functions

static defaultStorageSettings ()
 
static defaultFieldSettings ()
 
static schema (FieldStorageDefinitionInterface $field_definition)
 
static propertyDefinitions (FieldStorageDefinitionInterface $field_definition)
 
static generateSampleValue (FieldDefinitionInterface $field_definition)
 
static validateResolution ($element, FormStateInterface $form_state)
 
static validateDefaultImageForm (array &$element, FormStateInterface $form_state)
 
- Static Public Member Functions inherited from FileItem
static defaultStorageSettings ()
 
static defaultFieldSettings ()
 
static schema (FieldStorageDefinitionInterface $field_definition)
 
static propertyDefinitions (FieldStorageDefinitionInterface $field_definition)
 
static validateDirectory ($element, FormStateInterface $form_state)
 
static validateExtensions ($element, FormStateInterface $form_state)
 
static validateMaxFilesize ($element, FormStateInterface $form_state)
 
static generateSampleValue (FieldDefinitionInterface $field_definition)
 
static getPreconfiguredOptions ()
 
- Static Public Member Functions inherited from EntityReferenceItem
static defaultStorageSettings ()
 
static defaultFieldSettings ()
 
static propertyDefinitions (FieldStorageDefinitionInterface $field_definition)
 
static mainPropertyName ()
 
static schema (FieldStorageDefinitionInterface $field_definition)
 
static generateSampleValue (FieldDefinitionInterface $field_definition)
 
static fieldSettingsFormValidate (array $form, FormStateInterface $form_state)
 
static calculateDependencies (FieldDefinitionInterface $field_definition)
 
static calculateStorageDependencies (FieldStorageDefinitionInterface $field_definition)
 
static onDependencyRemoval (FieldDefinitionInterface $field_definition, array $dependencies)
 
static fieldSettingsAjaxProcess ($form, FormStateInterface $form_state)
 
static fieldSettingsAjaxProcessElement (&$element, $main_form)
 
static formProcessMergeParent ($element)
 
static settingsAjax ($form, FormStateInterface $form_state)
 
static settingsAjaxSubmit ($form, FormStateInterface $form_state)
 
- Static Public Member Functions inherited from FieldItemBase
static defaultStorageSettings ()
 
static defaultFieldSettings ()
 
static mainPropertyName ()
 
static generateSampleValue (FieldDefinitionInterface $field_definition)
 
static storageSettingsToConfigData (array $settings)
 
static storageSettingsFromConfigData (array $settings)
 
static fieldSettingsToConfigData (array $settings)
 
static fieldSettingsFromConfigData (array $settings)
 
static calculateDependencies (FieldDefinitionInterface $field_definition)
 
static calculateStorageDependencies (FieldStorageDefinitionInterface $field_definition)
 
static onDependencyRemoval (FieldDefinitionInterface $field_definition, array $dependencies)
 
- Static Public Member Functions inherited from TypedData
static createInstance ($definition, $name=NULL, TraversableTypedDataInterface $parent=NULL)
 

Protected Member Functions

 defaultImageForm (array &$element, array $settings)
 
 getEntityManager ()
 
- Protected Member Functions inherited from FieldItemBase
 getSettings ()
 
 getSetting ($setting_name)
 
 writePropertyValue ($property_name, $value)
 
- Protected Member Functions inherited from Map
 writePropertyValue ($property_name, $value)
 

Protected Attributes

 $entityManager
 
- Protected Attributes inherited from Map
 $definition
 
 $values = array()
 
 $properties = array()
 
- Protected Attributes inherited from TypedData
 $definition
 
 $name
 
 $parent
 

Additional Inherited Members

- Static Protected Member Functions inherited from FileItem
static doGetUploadLocation (array $settings, $data=[])
 

Detailed Description

Plugin implementation of the 'image' field type.

( id = "image", label = ("Image"), description = ("This field stores the ID of an image file as an integer value."), category = ("Reference"), default_widget = "image_image", default_formatter = "image", column_groups = { "file" = { "label" = ("File"), "columns" = { "target_id", "width", "height" } }, "alt" = { "label" = ("Alt"), "translatable" = TRUE }, "title" = { "label" = ("Title"), "translatable" = TRUE }, }, list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList", constraints = {"ReferenceAccess" = {}, "FileValidation" = {}} )

Member Function Documentation

static defaultFieldSettings ( )
static

{Defines the field-level settings for this plugin.

Returns
array A list of default settings, keyed by the setting name.
}

Implements FieldItemInterface.

defaultImageForm ( array &  $element,
array  $settings 
)
protected

Builds the default_image details element.

Parameters
array$elementThe form associative array passed by reference.
array$settingsThe field settings array.

References ImageItem\getEntityManager(), FileItem\getUploadValidators(), and t().

Here is the call graph for this function:

static defaultStorageSettings ( )
static

{Defines the storage-level settings for this plugin.

Returns
array A list of default settings, keyed by the setting name.
}

Implements FieldItemInterface.

fieldSettingsForm ( array  $form,
FormStateInterface  $form_state 
)

{Returns a form for the field-level settings.Invoked from to allow administrators to configure field-level settings.

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 settings.
}

Implements FieldItemInterface.

References FieldItemBase\getSettings(), and t().

Here is the call graph for this function:

static generateSampleValue ( FieldDefinitionInterface  $field_definition)
static

{Generates placeholder field values.Useful when populating site with placeholder content during site building or profiling.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe field definition.
Returns
array An associative array of values.
}

Implements FieldItemInterface.

References Entity\create(), Drupal\currentUser(), drupal_basename(), drupal_realpath(), drupal_tempnam(), FILE_CREATE_DIRECTORY, file_prepare_directory(), file_unmanaged_move(), and DataDefinitionInterface\getSettings().

Here is the call graph for this function:

getEntityManager ( )
protected

Gets the entity manager.

Returns
.

References Drupal\entityManager().

Referenced by ImageItem\defaultImageForm().

Here is the call graph for this function:

Here is the caller graph for this function:

isDisplayed ( )

{}

preSave ( )

{Defines custom presave behavior for field values.This method is called during the process of saving an entity, just before values are written into storage. When storing a new entity, its identifier will not be available yet. This should be used to massage item property values or perform any other operation that needs to happen before values are stored. For instance this is the proper phase to auto-create a new entity for an entity reference field item, because this way it will be possible to store the referenced entity identifier.}

Implements FieldItemInterface.

References Drupal\service().

Here is the call graph for this function:

static propertyDefinitions ( FieldStorageDefinitionInterface  $field_definition)
static

{Defines field item properties.Properties that are required to constitute a valid, non-empty item should be denoted with ::setRequired().

Returns
[] An array of property definitions of contained properties, keyed by property name.
See Also
}

Implements FieldItemInterface.

References DataDefinition\create(), and t().

Here is the call graph for this function:

static schema ( FieldStorageDefinitionInterface  $field_definition)
static

{Returns the schema for the field.This method is static because the field schema information is needed on creation of the field. FieldItemInterface objects instantiated at that time are not reliable as field settings might be missing.Computed fields having no schema should return an empty array.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$field_definitionThe field definition.
Returns
array An empty array if there is no schema, or an associative array with the following key/value pairs:
  • columns: An array of Schema API column specifications, keyed by column name. The columns need to be a subset of the properties defined in propertyDefinitions(). The 'not null' property is ignored if present, as it is determined automatically by the storage controller depending on the table layout and the property definitions. It is recommended to avoid having the column definitions depend on field settings when possible. No assumptions should be made on how storage engines internally use the original column name to structure their storage.
  • unique keys: (optional) An array of Schema API unique key definitions. Only columns that appear in the 'columns' array are allowed.
  • indexes: (optional) An array of Schema API index definitions. Only columns that appear in the 'columns' array are allowed. Those indexes will be used as default indexes. Field definitions can specify additional indexes or, at their own risk, modify the default indexes specified by the field-type module. Some storage engines might not support indexes.
  • foreign keys: (optional) An array of Schema API foreign key definitions. Note, however, that the field data is not necessarily stored in SQL. Also, the possible usage is limited, as you cannot specify another field as related, only existing SQL tables, such as {taxonomy_term_data}.
}

Implements FieldItemInterface.

storageSettingsForm ( array &  $form,
FormStateInterface  $form_state,
  $has_data 
)

{Returns a form for the storage-level settings.Invoked from to allow administrators to configure storage-level settings.Field storage might reject settings changes that affect the field storage schema if the storage already has data. When the $has_data parameter is TRUE, the form should not allow changing the settings that take part in the schema() method. It is recommended to set #access to FALSE on the corresponding elements.

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.
bool$has_dataTRUE if the field already has data, FALSE if not.
Returns
The form definition for the field settings.
}

Implements FieldItemInterface.

References FieldItemBase\getFieldDefinition(), Drupal\service(), t(), and StreamWrapperInterface\WRITE_VISIBLE.

Here is the call graph for this function:

static validateDefaultImageForm ( array &  $element,
FormStateInterface  $form_state 
)
static

Validates the managed_file element for the default Image form.

This function ensures the fid is a scalar value and not an array. It is assigned as a #element_validate callback in ::defaultImageForm().

Parameters
array$elementThe form element to process.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state.

References Drupal\entityManager(), and FormStateInterface\setValueForElement().

Here is the call graph for this function:

static validateResolution (   $element,
FormStateInterface  $form_state 
)
static

Element validate function for resolution fields.

References FormStateInterface\setError(), FormStateInterface\setValueForElement(), and t().

Here is the call graph for this function:


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