Same name and namespace in other branches
  1. 8.x-2.x src/ExifContent.php \Drupal\exif\ExifContent::handleField() 1 comment

Handle field by delegating to specific type handler.

Parameters

int $index: The index to set the new value.

\Drupal\Core\Field\FieldItemListInterface $field: The field to update.

string $exif_section: The exif section where value has been retrieved.

string $exif_name: The exif label where value has been retrieved.

string $exif_value: The exif value to update.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to ExifContent::handleField()
ExifContent::entity_insert_update in src/ExifContent.php
Main entry of the module.

File

src/ExifContent.php, line 461

Class

ExifContent
Class ExifContent make link between drupal content and file content.

Namespace

Drupal\exif

Code

private function handleField($index, FieldItemListInterface &$field, $exif_section, $exif_name, $exif_value) {
    $value = $this->sanitizeValue($exif_value);
    $field_typename = $field->getFieldDefinition()
        ->getType();
    if (in_array($field_typename, [
        'text',
        'text_long',
        'text_with_summary',
        'string',
        'string_long',
    ])) {
        $this->handleTextField($index, $field, $exif_section, $exif_name, $value);
    }
    else {
        if ($field_typename == 'entity_reference' && $field->getFieldDefinition()
            ->getFieldStorageDefinition()
            ->getSetting('target_type') == 'taxonomy_term') {
            $this->handleTaxonomyField($index, $field, $exif_section, $exif_name, $value);
        }
        else {
            if ($field_typename == 'datetime' || $field_typename == 'date') {
                $this->handleDateField($index, $field, $exif_section, $exif_name, $value);
            }
        }
    }
}