You are here

public static function SvgImageFieldItem::propertyDefinitions in SVG Image Field 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/SvgImageFieldItem.php \Drupal\svg_image_field\Plugin\Field\FieldType\SvgImageFieldItem::propertyDefinitions()
  2. 2.1.x src/Plugin/Field/FieldType/SvgImageFieldItem.php \Drupal\svg_image_field\Plugin\Field\FieldType\SvgImageFieldItem::propertyDefinitions()

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FileItem::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/SvgImageFieldItem.php, line 122

Class

SvgImageFieldItem
Plugin implementation of the 'svg_image' field type.

Namespace

Drupal\svg_image_field\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties = parent::propertyDefinitions($field_definition);
  unset($properties['display']);
  unset($properties['description']);
  $properties['alt'] = DataDefinition::create('string')
    ->setLabel(t('Alternative text'))
    ->setDescription(t("Alternative image text, for the image's 'alt' attribute."));
  $properties['title'] = DataDefinition::create('string')
    ->setLabel(t('Title'))
    ->setDescription(t("Image title text, for the image's 'title' attribute."));
  return $properties;
}