Drupal 8  8.0.2
FileItem Class Reference
Inheritance diagram for FileItem:

Public Member Functions

 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 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)
 

Static Protected Member Functions

static doGetUploadLocation (array $settings, $data=[])
 

Additional Inherited Members

- 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 inherited from Map
 $definition
 
 $values = array()
 
 $properties = array()
 
- Protected Attributes inherited from TypedData
 $definition
 
 $name
 
 $parent
 

Detailed Description

Plugin implementation of the 'file' field type.

( id = "file", label = ("File"), description = ("This field stores the ID of a file as an integer value."), category = ("Reference"), default_widget = "file_generic", default_formatter = "file_default", 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.

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.

References file_default_scheme().

Here is the call graph for this function:

static doGetUploadLocation ( array  $settings,
  $data = [] 
)
staticprotected

Determines the URI for a file field.

Parameters
array$settingsThe array of field settings.
array$dataAn array of token objects to pass to token_replace().
Returns
string An unsanitized file directory URI with tokens replaced. The result of the token replacement is then converted to plain text and returned.

References PlainTextOutput\renderFromHtml(), and Drupal\token().

Here is the call graph for this function:

fieldSettingsForm ( array  $form,
FormStateInterface  $form_state 
)

{}

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

Here is the call graph for this function:

static generateSampleValue ( FieldDefinitionInterface  $field_definition)
static

{}

References FILE_CREATE_DIRECTORY, FILE_EXISTS_ERROR, and file_prepare_directory().

Here is the call graph for this function:

static getPreconfiguredOptions ( )
static

{Returns preconfigured field options for a field type.

Returns
mixed[][] A multi-dimensional array with string keys and the following structure:
  • label: The label to show in the field type selection list.
  • category: (optional) The category in which to put the field label. Defaults to the category of the field type.
  • field_storage_config: An array with the following supported keys:
    • cardinality: The field cardinality.
    • settings: Field-type specific storage settings.
  • field_config: An array with the following supported keys:
    • required: Indicates whether the field is required.
    • settings: Field-type specific settings.
  • entity_form_display: An array with the following supported keys:
    • type: The widget to be used in the 'default' form mode.
  • entity_view_display: An array with the following supported keys:
    • type: The formatter to be used in the 'default' view mode.
See Also
::setComponent()
}

Implements PreconfiguredFieldUiOptionsInterface.

getUploadLocation (   $data = array())

Determines the URI for a file field.

Parameters
array$dataAn array of token objects to pass to token_replace().
Returns
string An unsanitized file directory URI with tokens replaced. The result of the token replacement is then converted to plain text and returned.
See Also
token_replace()

References FieldItemBase\getSettings().

Here is the call graph for this function:

getUploadValidators ( )

Retrieves the upload validators for a file field.

Returns
array An array suitable for passing to file_save_upload() or the file field element's '#upload_validators' property.

References file_upload_max_size(), FieldItemBase\getSettings(), and Bytes\toInt().

Referenced by ImageItem\defaultImageForm().

Here is the call graph for this function:

Here is the caller graph for this function:

isDisplayed ( )

Determines whether an item should be displayed when rendering the field.

Returns
bool TRUE if the item should be displayed, FALSE if not.

References FieldItemBase\getSetting().

Here is the call graph for this function:

static propertyDefinitions ( FieldStorageDefinitionInterface  $field_definition)
static

{}

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

Here is the call graph for this function:

static schema ( FieldStorageDefinitionInterface  $field_definition)
static

{}

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

{}

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

Here is the call graph for this function:

static validateDirectory (   $element,
FormStateInterface  $form_state 
)
static

Form API callback

Removes slashes from the beginning and end of the destination value and ensures that the file directory path is not included at the beginning of the value.

This function is assigned as an #element_validate callback in fieldSettingsForm().

static validateExtensions (   $element,
FormStateInterface  $form_state 
)
static

Form API callback.

This function is assigned as an #element_validate callback in fieldSettingsForm().

This doubles as a convenience clean-up function and a validation routine. Commas are allowed by the end-user, but ultimately the value will be stored as a space-separated list for compatibility with file_validate_extensions().

References t().

Here is the call graph for this function:

static validateMaxFilesize (   $element,
FormStateInterface  $form_state 
)
static

Form API callback.

Ensures that a size has been entered and that it can be parsed by ::toInt().

This function is assigned as an #element_validate callback in fieldSettingsForm().

References t(), and Bytes\toInt().

Here is the call graph for this function:


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