Same name and namespace in other branches
- 8.x-2.x src/Plugin/Field/FieldWidget/ExifReadonlyWidget.php \Drupal\exif\Plugin\Field\FieldWidget\ExifReadonlyWidget 1 comment
Plugin implementation of the 'exif_readonly' widget.
Plugin annotation
@FieldWidget(
id = "exif_readonly",
label = @Translation("metadata from image (viewable in forms)"),
description = @Translation("field content is calculated from image field
in the same content type (field are viewable but readonly in forms)"),
multiple_values = true, field_types = {
"string",
"string_long",
"text",
"text_with_summary",
"text_long",
"entity_reference",
"date",
"datetime",
"datestamp"
}
)
Hierarchy
- class \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase extends \Drupal\Core\Field\WidgetBase
- class \Drupal\exif\Plugin\Field\FieldWidget\ExifFieldWidgetBase extends \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase
- class \Drupal\exif\Plugin\Field\FieldWidget\ExifReadonlyWidget extends \Drupal\exif\Plugin\Field\FieldWidget\ExifFieldWidgetBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\exif\Plugin\Field\FieldWidget\ExifFieldWidgetBase extends \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase
Expanded class hierarchy of ExifReadonlyWidget
File
-
src/
Plugin/ Field/ FieldWidget/ ExifReadonlyWidget.php, line 33
Namespace
Drupal\exif\Plugin\Field\FieldWidgetView source
class ExifReadonlyWidget extends ExifFieldWidgetBase implements ContainerFactoryPluginInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a ExifReadonlyWidget object.
*
* @param string $plugin_id
* The plugin_id for the widget.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The definition of the field to which the widget is associated.
* @param array $settings
* The widget settings.
* @param array $third_party_settings
* Any third party settings.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = $items->getValue();
$entity_type = $items->getFieldDefinition()
->getTargetEntityTypeId();
$access = $this->entityTypeManager
->getAccessControlHandler($entity_type)
->fieldAccess('view', $items->getFieldDefinition());
if (!$access) {
$element += [
'#type' => '#hidden',
'#value' => '',
];
}
$element += $items->view();
$element += [
'#value' => $value,
'#default_value' => $value,
];
return $element;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
ExifFieldWidgetBase::defaultSettings | public static | function | Overrides ExifWidgetBase::defaultSettings | |
ExifFieldWidgetBase::retrieveExifFieldDefaultSeparatorValue | private | function | Get separator value from settings. | |
ExifFieldWidgetBase::retrieveExifFieldDefaultValue | private | function | Get exif field name associated to this drupal field. | |
ExifFieldWidgetBase::retrieveExifFields | private | function | List of possible fields. | |
ExifFieldWidgetBase::settingsForm | public | function | Overrides ExifWidgetBase::settingsForm | |
ExifFieldWidgetBase::settingsSummary | public | function | Overrides ExifWidgetBase::settingsSummary | |
ExifFieldWidgetBase::validateExifField | public static | function | Ensure field is correctly configured. | |
ExifFieldWidgetBase::validateExifFieldSeparator | public static | function | Ensure field separator is correctly configured. | |
ExifReadonlyWidget::$entityTypeManager | protected | property | The entity type manager. | |
ExifReadonlyWidget::create | public static | function | ||
ExifReadonlyWidget::formElement | public | function | ||
ExifReadonlyWidget::__construct | public | function | Constructs a ExifReadonlyWidget object. | |
ExifWidgetBase::EXIF_BASE_DEFAULT_SETTINGS | constant | |||
ExifWidgetBase::retrieveImageFieldDefaultValue | protected | function | Calculate default value for settings form. | |
ExifWidgetBase::retrieveImageFieldFromBundle | protected | function | Retrieve list of image field labels by key of image field. | |
ExifWidgetBase::validateImageField | public static | function | Validate field to ensure it is linked to a image field. |