You are here

protected function EntityReferenceBrowserWidget::getPersistentData in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php \Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::getPersistentData()

Gets data that should persist across Entity Browser renders.

Return value

array Data that should persist after the Entity Browser is rendered.

2 calls to EntityReferenceBrowserWidget::getPersistentData()
EntityReferenceBrowserWidget::formElement in src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php
Returns the form for a single field widget.
FileBrowserWidget::getPersistentData in src/Plugin/Field/FieldWidget/FileBrowserWidget.php
Gets data that should persist across Entity Browser renders.
1 method overrides EntityReferenceBrowserWidget::getPersistentData()
FileBrowserWidget::getPersistentData in src/Plugin/Field/FieldWidget/FileBrowserWidget.php
Gets data that should persist across Entity Browser renders.

File

src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php, line 721

Class

EntityReferenceBrowserWidget
Plugin implementation of the 'entity_reference' widget for entity browser.

Namespace

Drupal\entity_browser\Plugin\Field\FieldWidget

Code

protected function getPersistentData() {
  $settings = $this->fieldDefinition
    ->getSettings();
  $handler = $settings['handler_settings'];
  return [
    'validators' => [
      'entity_type' => [
        'type' => $settings['target_type'],
      ],
    ],
    'widget_context' => [
      'target_bundles' => !empty($handler['target_bundles']) ? $handler['target_bundles'] : [],
      'target_entity_type' => $settings['target_type'],
      'cardinality' => $this->fieldDefinition
        ->getFieldStorageDefinition()
        ->getCardinality(),
    ],
  ];
}