You are here

class FileBrowserWidget in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/FileBrowserWidget.php \Drupal\entity_browser\Plugin\Field\FieldWidget\FileBrowserWidget

Entity browser file widget.

Plugin annotation


@FieldWidget(
  id = "entity_browser_file",
  label = @Translation("Entity browser"),
  provider = "entity_browser",
  multiple_values = TRUE,
  field_types = {
    "file",
    "image"
  }
)

Hierarchy

Expanded class hierarchy of FileBrowserWidget

File

src/Plugin/Field/FieldWidget/FileBrowserWidget.php, line 37

Namespace

Drupal\entity_browser\Plugin\Field\FieldWidget
View source
class FileBrowserWidget extends EntityReferenceBrowserWidget {

  /**
   * Due to the table structure, this widget has a different depth.
   *
   * @var int
   */
  protected static $deleteDepth = 3;

  /**
   * A list of currently edited items. Used to determine alt/title values.
   *
   * @var \Drupal\Core\Field\FieldItemListInterface
   */
  protected $items;

  /**
   * The config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The display repository service.
   *
   * @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
   */
  protected $displayRepository;

  /**
   * The mime type guesser service.
   *
   * @var \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface
   */
  protected $mimeTypeGuesser;

  /**
   * Constructs widget plugin.
   *
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @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
   *   Entity type manager service.
   * @param \Drupal\entity_browser\FieldWidgetDisplayManager $field_display_manager
   *   Field widget display plugin manager.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository
   *   The entity display repository service.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler service.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param \Drupal\Core\Messenger\MessengerInterface $messenger
   *   The messenger.
   * @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser
   *   The mime type guesser service.
   */
  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager, FieldWidgetDisplayManager $field_display_manager, ConfigFactoryInterface $config_factory, EntityDisplayRepositoryInterface $display_repository, ModuleHandlerInterface $module_handler, AccountInterface $current_user, MimeTypeGuesserInterface $mime_type_guesser, MessengerInterface $messenger) {
    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings, $entity_type_manager, $field_display_manager, $module_handler, $current_user, $messenger);
    $this->entityTypeManager = $entity_type_manager;
    $this->fieldDisplayManager = $field_display_manager;
    $this->configFactory = $config_factory;
    $this->displayRepository = $display_repository;
    $this->mimeTypeGuesser = $mime_type_guesser;
  }

  /**
   * {@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'), $container
      ->get('plugin.manager.entity_browser.field_widget_display'), $container
      ->get('config.factory'), $container
      ->get('entity_display.repository'), $container
      ->get('module_handler'), $container
      ->get('current_user'), $container
      ->get('file.mime_type.guesser'), $container
      ->get('messenger'));
  }

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    $settings = parent::defaultSettings();

    // These settings are hidden.
    unset($settings['field_widget_display']);
    unset($settings['field_widget_display_settings']);
    $settings['view_mode'] = 'default';
    $settings['preview_image_style'] = 'thumbnail';
    return $settings;
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $element = parent::settingsForm($form, $form_state);
    $has_file_entity = $this->moduleHandler
      ->moduleExists('file_entity');
    $element['field_widget_display']['#access'] = FALSE;
    $element['field_widget_display_settings']['#access'] = FALSE;
    $element['view_mode'] = [
      '#title' => $this
        ->t('File view mode'),
      '#type' => 'select',
      '#default_value' => $this
        ->getSetting('view_mode'),
      '#options' => $this->displayRepository
        ->getViewModeOptions('file'),
      '#access' => $has_file_entity,
    ];
    $element['preview_image_style'] = [
      '#title' => $this
        ->t('Preview image style'),
      '#type' => 'select',
      '#options' => image_style_options(FALSE),
      '#default_value' => $this
        ->getSetting('preview_image_style'),
      '#description' => $this
        ->t('The preview image will be shown while editing the content. Only relevant if using the default file view mode.'),
      '#weight' => 15,
      '#access' => !$has_file_entity && $this->fieldDefinition
        ->getType() == 'image',
    ];
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    $summary = $this
      ->summaryBase();
    $view_mode = $this
      ->getSetting('view_mode');
    $image_style_setting = $this
      ->getSetting('preview_image_style');
    if ($this->moduleHandler
      ->moduleExists('file_entity')) {
      $preview_image_style = $this
        ->t('Preview with @view_mode', [
        '@view_mode' => $view_mode,
      ]);
    }
    elseif ($this->fieldDefinition
      ->getType() == 'image' && ($image_style = ImageStyle::load($image_style_setting))) {
      $preview_image_style = $this
        ->t('Preview image style: @style', [
        '@style' => $image_style
          ->label(),
      ]);
    }
    else {
      $preview_image_style = $this
        ->t('No preview image');
    }
    array_unshift($summary, $preview_image_style);
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $this->items = $items;
    return parent::formElement($items, $delta, $element, $form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  protected function displayCurrentSelection($details_id, array $field_parents, array $entities) {
    $field_type = $this->fieldDefinition
      ->getType();
    $field_settings = $this->fieldDefinition
      ->getSettings();
    $field_machine_name = $this->fieldDefinition
      ->getName();
    $file_settings = $this->configFactory
      ->get('file.settings');
    $widget_settings = $this
      ->getSettings();
    $view_mode = $widget_settings['view_mode'];
    $can_edit = (bool) $widget_settings['field_widget_edit'];
    $has_file_entity = $this->moduleHandler
      ->moduleExists('file_entity');
    $delta = 0;
    $order_class = $field_machine_name . '-delta-order';
    $current = [
      '#type' => 'table',
      '#empty' => $this
        ->t('No files yet'),
      '#attributes' => [
        'class' => [
          'entities-list',
        ],
      ],
      '#tabledrag' => [
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => $order_class,
        ],
      ],
    ];
    if ($has_file_entity || $field_type == 'image' && !empty($widget_settings['preview_image_style'])) {

      // Had the preview column if we have one.
      $current['#header'][] = $this
        ->t('Preview');
    }

    // Add the filename if there is no view builder.
    if (!$has_file_entity) {
      $current['#header'][] = $this
        ->t('Filename');
    }

    // Add the remaining columns.
    $current['#header'][] = $this
      ->t('Metadata');
    $current['#header'][] = [
      'data' => $this
        ->t('Operations'),
      'colspan' => 3,
    ];
    $current['#header'][] = $this
      ->t('Order', [], [
      'context' => 'Sort order',
    ]);

    /** @var \Drupal\file\FileInterface[] $entities */
    foreach ($entities as $entity) {

      // Check to see if this entity has an edit form. If not, the edit button
      // will only throw an exception.
      if (!$entity
        ->getEntityType()
        ->getFormClass('edit')) {
        $edit_button_access = FALSE;
      }
      elseif ($has_file_entity) {
        $edit_button_access = $can_edit && $entity
          ->access('update', $this->currentUser);
      }

      // The "Replace" button will only be shown if this setting is enabled in
      // the widget, and there is only one entity in the current selection.
      $replace_button_access = $this
        ->getSetting('field_widget_replace') && count($entities) === 1;
      $entity_id = $entity
        ->id();

      // Find the default description.
      $description = '';
      $display_field = $field_settings['display_default'];
      $alt = '';
      $title = '';
      $weight = $delta;
      $width = NULL;
      $height = NULL;
      foreach ($this->items as $item) {
        if ($item->target_id == $entity_id) {
          if ($field_type == 'file') {
            $description = $item->description;
            $display_field = $item->display;
          }
          elseif ($field_type == 'image') {
            $alt = $item->alt;
            $title = $item->title;
            $width = $item->width;
            $height = $item->height;
          }
          $weight = $item->_weight ?: $delta;
        }
      }
      $current[$entity_id] = [
        '#attributes' => [
          'class' => [
            'draggable',
          ],
          'data-entity-id' => $entity
            ->getEntityTypeId() . ':' . $entity_id,
          'data-row-id' => $delta,
        ],
      ];

      // Provide a rendered entity if a view builder is available.
      if ($has_file_entity) {
        $current[$entity_id]['display'] = $this->entityTypeManager
          ->getViewBuilder('file')
          ->view($entity, $view_mode);
      }
      elseif ($field_type == 'image' && !empty($widget_settings['preview_image_style'])) {
        $uri = $entity
          ->getFileUri();
        $current[$entity_id]['display'] = [
          '#weight' => -10,
          '#theme' => 'image_style',
          '#width' => $width,
          '#height' => $height,
          '#style_name' => $widget_settings['preview_image_style'],
          '#uri' => $uri,
        ];
      }

      // Assume that the file name is part of the preview output if
      // file entity is installed, do not show this column in that case.
      if (!$has_file_entity) {
        $current[$entity_id]['filename'] = [
          '#markup' => $entity
            ->label(),
        ];
      }
      $current[$entity_id] += [
        'meta' => [
          'display_field' => [
            '#type' => 'checkbox',
            '#title' => $this
              ->t('Include file in display'),
            '#default_value' => (bool) $display_field,
            '#access' => $field_type == 'file' && $field_settings['display_field'],
          ],
          'description' => [
            '#type' => $file_settings
              ->get('description.type'),
            '#title' => $this
              ->t('Description'),
            '#default_value' => $description,
            '#size' => 45,
            '#maxlength' => $file_settings
              ->get('description.length'),
            '#description' => $this
              ->t('The description may be used as the label of the link to the file.'),
            '#access' => $field_type == 'file' && $field_settings['description_field'],
          ],
          'alt' => [
            '#type' => 'textfield',
            '#title' => $this
              ->t('Alternative text'),
            '#default_value' => $alt,
            '#size' => 45,
            '#maxlength' => 512,
            '#description' => $this
              ->t('This text will be used by screen readers, search engines, or when the image cannot be loaded.'),
            '#access' => $field_type == 'image' && $field_settings['alt_field'],
            '#required' => $field_type == 'image' && $field_settings['alt_field_required'],
          ],
          'title' => [
            '#type' => 'textfield',
            '#title' => $this
              ->t('Title'),
            '#default_value' => $title,
            '#size' => 45,
            '#maxlength' => 1024,
            '#description' => $this
              ->t('The title is used as a tool tip when the user hovers the mouse over the image.'),
            '#access' => $field_type == 'image' && $field_settings['title_field'],
            '#required' => $field_type == 'image' && $field_settings['title_field_required'],
          ],
        ],
        'edit_button' => [
          '#type' => 'submit',
          '#value' => $this
            ->t('Edit'),
          '#ajax' => [
            'url' => Url::fromRoute('entity_browser.edit_form', [
              'entity_type' => $entity
                ->getEntityTypeId(),
              'entity' => $entity_id,
            ]),
            'options' => [
              'query' => [
                'details_id' => $details_id,
              ],
            ],
          ],
          '#attributes' => [
            'data-entity-id' => $entity
              ->getEntityTypeId() . ':' . $entity
              ->id(),
            'data-row-id' => $delta,
            'class' => [
              'edit-button',
            ],
          ],
          '#access' => $edit_button_access,
        ],
        'replace_button' => [
          '#type' => 'submit',
          '#value' => $this
            ->t('Replace'),
          '#ajax' => [
            'callback' => [
              get_class($this),
              'updateWidgetCallback',
            ],
            'wrapper' => $details_id,
          ],
          '#submit' => [
            [
              get_class($this),
              'removeItemSubmit',
            ],
          ],
          '#name' => $field_machine_name . '_replace_' . $entity_id . '_' . md5(json_encode($field_parents)),
          '#limit_validation_errors' => [
            array_merge($field_parents, [
              $field_machine_name,
              'target_id',
            ]),
          ],
          '#attributes' => [
            'data-entity-id' => $entity
              ->getEntityTypeId() . ':' . $entity
              ->id(),
            'data-row-id' => $delta,
            'class' => [
              'replace-button',
            ],
          ],
          '#access' => $replace_button_access,
        ],
        'remove_button' => [
          '#type' => 'submit',
          '#value' => $this
            ->t('Remove'),
          '#ajax' => [
            'callback' => [
              get_class($this),
              'updateWidgetCallback',
            ],
            'wrapper' => $details_id,
          ],
          '#submit' => [
            [
              get_class($this),
              'removeItemSubmit',
            ],
          ],
          '#name' => $field_machine_name . '_remove_' . $entity_id . '_' . md5(json_encode($field_parents)),
          '#limit_validation_errors' => [
            array_merge($field_parents, [
              $field_machine_name,
              'target_id',
            ]),
          ],
          '#attributes' => [
            'data-entity-id' => $entity
              ->getEntityTypeId() . ':' . $entity
              ->id(),
            'data-row-id' => $delta,
            'class' => [
              'remove-button',
            ],
          ],
          '#access' => (bool) $widget_settings['field_widget_remove'],
        ],
        '_weight' => [
          '#type' => 'weight',
          '#title' => $this
            ->t('Weight for row @number', [
            '@number' => $delta + 1,
          ]),
          '#title_display' => 'invisible',
          // Note: this 'delta' is the FAPI #type 'weight' element's property.
          '#delta' => count($entities),
          '#default_value' => $weight,
          '#attributes' => [
            'class' => [
              $order_class,
            ],
          ],
        ],
      ];
      $current['#attached']['library'][] = 'entity_browser/file_browser';
      $delta++;
    }
    return $current;
  }

  /**
   * {@inheritdoc}
   */
  public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
    $ids = empty($values['target_id']) ? [] : explode(' ', trim($values['target_id']));
    $return = [];
    foreach ($ids as $id) {
      $id = explode(':', $id)[1];
      if (is_array($values['current']) && isset($values['current'][$id])) {
        $item_values = [
          'target_id' => $id,
          '_weight' => $values['current'][$id]['_weight'],
        ];
        if ($this->fieldDefinition
          ->getType() == 'file') {
          if (isset($values['current'][$id]['meta']['description'])) {
            $item_values['description'] = $values['current'][$id]['meta']['description'];
          }
          if ($this->fieldDefinition
            ->getSetting('display_field') && isset($values['current'][$id]['meta']['display_field'])) {
            $item_values['display'] = $values['current'][$id]['meta']['display_field'];
          }
        }
        if ($this->fieldDefinition
          ->getType() == 'image') {
          if (isset($values['current'][$id]['meta']['alt'])) {
            $item_values['alt'] = $values['current'][$id]['meta']['alt'];
          }
          if (isset($values['current'][$id]['meta']['title'])) {
            $item_values['title'] = $values['current'][$id]['meta']['title'];
          }
        }
        $return[] = $item_values;
      }
    }

    // Return ourself as the structure doesn't match the default.
    usort($return, function ($a, $b) {
      return SortArray::sortByKeyInt($a, $b, '_weight');
    });
    return array_values($return);
  }

  /**
   * Retrieves the upload validators for a file field.
   *
   * This is a combination of logic shared between the File and Image widgets.
   *
   * @param bool $upload
   *   Whether or not upload-specific validators should be returned.
   *
   * @return array
   *   An array suitable for passing to file_save_upload() or the file field
   *   element's '#upload_validators' property.
   */
  public function getFileValidators($upload = FALSE) {
    $validators = [];
    $settings = $this->fieldDefinition
      ->getSettings();
    if ($upload) {

      // Cap the upload size according to the PHP limit.
      $max_filesize = Bytes::toInt(Environment::getUploadMaxSize());
      if (!empty($settings['max_filesize'])) {
        $max_filesize = min($max_filesize, Bytes::toInt($settings['max_filesize']));
      }

      // There is always a file size limit due to the PHP server limit.
      $validators['file_validate_size'] = [
        $max_filesize,
      ];
    }

    // Images have expected defaults for file extensions.
    // See \Drupal\image\Plugin\Field\FieldWidget::formElement() for details.
    if ($this->fieldDefinition
      ->getType() == 'image') {

      // If not using custom extension validation, ensure this is an image.
      $supported_extensions = [
        'png',
        'gif',
        'jpg',
        'jpeg',
      ];
      $extensions = isset($settings['file_extensions']) ? $settings['file_extensions'] : implode(' ', $supported_extensions);
      $extensions = array_intersect(explode(' ', $extensions), $supported_extensions);
      $validators['file_validate_extensions'] = [
        implode(' ', $extensions),
      ];

      // Add resolution validation.
      if (!empty($settings['max_resolution']) || !empty($settings['min_resolution'])) {
        $validators['entity_browser_file_validate_image_resolution'] = [
          $settings['max_resolution'],
          $settings['min_resolution'],
        ];
      }
    }
    elseif (!empty($settings['file_extensions'])) {
      $validators['file_validate_extensions'] = [
        $settings['file_extensions'],
      ];
    }
    return $validators;
  }

  /**
   * {@inheritdoc}
   */
  protected function getPersistentData() {
    $data = parent::getPersistentData();
    $settings = $this->fieldDefinition
      ->getSettings();

    // Add validators based on our current settings.
    $data['validators']['file'] = [
      'validators' => $this
        ->getFileValidators(),
    ];

    // Provide context for widgets to enhance their configuration.
    $data['widget_context']['upload_location'] = $settings['uri_scheme'] . '://' . $settings['file_directory'];
    $data['widget_context']['upload_validators'] = $this
      ->getFileValidators(TRUE);

    // Assemble valid mime types for filtering. This is required if we want to
    // contextually filter allowed extensions in views, as views arguments can
    // only filter on exact values. Otherwise we would pass %png or use REGEXP.
    $mimetypes = [];
    foreach (explode(' ', $settings['file_extensions']) as $extension) {
      if ($guess = $this->mimeTypeGuesser
        ->guess('file.' . $extension)) {
        $mimetypes[] = $guess;
      }
    }
    $data['widget_context']['target_file_mimetypes'] = $mimetypes;
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AllowedTagsXssTrait::allowedTags public function Returns a list of tags allowed by AllowedTagsXssTrait::fieldFilterXss().
AllowedTagsXssTrait::displayAllowedTags public function Returns a human-readable list of allowed tags for display in help texts.
AllowedTagsXssTrait::fieldFilterXss public function Filters an HTML string to prevent XSS vulnerabilities.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityReferenceBrowserWidget::$currentUser protected property The current user.
EntityReferenceBrowserWidget::$entityTypeManager protected property Entity type manager service.
EntityReferenceBrowserWidget::$fieldDisplayManager protected property Field widget display plugin manager.
EntityReferenceBrowserWidget::$moduleHandler protected property The module handler interface.
EntityReferenceBrowserWidget::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides PluginSettingsBase::calculateDependencies
EntityReferenceBrowserWidget::errorElement public function Assigns a field-level validation error to the right widget sub-element. Overrides WidgetBase::errorElement
EntityReferenceBrowserWidget::flagErrors public function Reports field-level validation errors against actual form elements. Overrides WidgetBase::flagErrors
EntityReferenceBrowserWidget::formElementEntities protected function Determines the entities used for the form element.
EntityReferenceBrowserWidget::getCardinalityMessage protected function Generates a message informing the user how many more items they can choose.
EntityReferenceBrowserWidget::getEntitiesByTargetId protected function Get selected elements from target_id element on form.
EntityReferenceBrowserWidget::getFormStateKey protected function Returns a key used to store the previously loaded entity.
EntityReferenceBrowserWidget::processEntityBrowser public static function Render API callback: Processes the entity browser element.
EntityReferenceBrowserWidget::removeItemSubmit public static function Submit callback for remove buttons.
EntityReferenceBrowserWidget::selectionModeOptions protected function Gets options that define where newly added entities are inserted.
EntityReferenceBrowserWidget::summaryBase protected function Provides base for settings summary shared by all EB widgets.
EntityReferenceBrowserWidget::updateFieldWidgetDisplaySettings public static function Ajax callback that updates field widget display settings fieldset.
EntityReferenceBrowserWidget::updateWidgetCallback public static function AJAX form callback.
EntityReferenceBrowserWidget::validateSettingsForm public static function Validate the settings form.
FileBrowserWidget::$configFactory protected property The config factory service.
FileBrowserWidget::$deleteDepth protected static property Due to the table structure, this widget has a different depth. Overrides EntityReferenceBrowserWidget::$deleteDepth
FileBrowserWidget::$displayRepository protected property The display repository service.
FileBrowserWidget::$items protected property A list of currently edited items. Used to determine alt/title values.
FileBrowserWidget::$mimeTypeGuesser protected property The mime type guesser service.
FileBrowserWidget::create public static function Creates an instance of the plugin. Overrides EntityReferenceBrowserWidget::create
FileBrowserWidget::defaultSettings public static function Defines the default settings for this plugin. Overrides EntityReferenceBrowserWidget::defaultSettings
FileBrowserWidget::displayCurrentSelection protected function Builds the render array for displaying the current results. Overrides EntityReferenceBrowserWidget::displayCurrentSelection
FileBrowserWidget::formElement public function Returns the form for a single field widget. Overrides EntityReferenceBrowserWidget::formElement
FileBrowserWidget::getFileValidators public function Retrieves the upload validators for a file field.
FileBrowserWidget::getPersistentData protected function Gets data that should persist across Entity Browser renders. Overrides EntityReferenceBrowserWidget::getPersistentData
FileBrowserWidget::massageFormValues public function Massages the form values into the format expected for field values. Overrides EntityReferenceBrowserWidget::massageFormValues
FileBrowserWidget::settingsForm public function Returns a form to configure settings for the widget. Overrides EntityReferenceBrowserWidget::settingsForm
FileBrowserWidget::settingsSummary public function Returns a short summary for the current widget settings. Overrides EntityReferenceBrowserWidget::settingsSummary
FileBrowserWidget::__construct public function Constructs widget plugin. Overrides EntityReferenceBrowserWidget::__construct
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginSettingsBase::$defaultSettingsMerged protected property Whether default settings have been merged into the current $settings.
PluginSettingsBase::$thirdPartySettings protected property The plugin settings injected by third party modules.
PluginSettingsBase::getSetting public function Returns the value of a setting, or its default value if absent. Overrides PluginSettingsInterface::getSetting
PluginSettingsBase::getSettings public function Returns the array of settings, including defaults for missing settings. Overrides PluginSettingsInterface::getSettings
PluginSettingsBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
PluginSettingsBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
PluginSettingsBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
PluginSettingsBase::mergeDefaults protected function Merges default settings values into $settings.
PluginSettingsBase::onDependencyRemoval public function Informs the plugin that some configuration it depends on will be deleted. Overrides PluginSettingsInterface::onDependencyRemoval 3
PluginSettingsBase::setSetting public function Sets the value of a setting for the plugin. Overrides PluginSettingsInterface::setSetting
PluginSettingsBase::setSettings public function Sets the settings for the plugin. Overrides PluginSettingsInterface::setSettings
PluginSettingsBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
PluginSettingsBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
WidgetBase::$fieldDefinition protected property The field definition.
WidgetBase::$settings protected property The widget settings. Overrides PluginSettingsBase::$settings
WidgetBase::addMoreAjax public static function Ajax callback for the "Add another item" button.
WidgetBase::addMoreSubmit public static function Submission handler for the "Add another item" button.
WidgetBase::afterBuild public static function After-build handler for field elements in a form.
WidgetBase::extractFormValues public function Extracts field values from submitted form values. Overrides WidgetBaseInterface::extractFormValues 2
WidgetBase::form public function Creates a form element for a field. Overrides WidgetBaseInterface::form 3
WidgetBase::formMultipleElements protected function Special handling to create form elements for multiple values. 1
WidgetBase::formSingleElement protected function Generates the form element for a single copy of the widget.
WidgetBase::getFieldSetting protected function Returns the value of a field setting.
WidgetBase::getFieldSettings protected function Returns the array of field settings.
WidgetBase::getFilteredDescription protected function Returns the filtered field description.
WidgetBase::getWidgetState public static function Retrieves processing information about the widget from $form_state. Overrides WidgetBaseInterface::getWidgetState
WidgetBase::getWidgetStateParents protected static function Returns the location of processing information within $form_state.
WidgetBase::handlesMultipleValues protected function Returns whether the widget handles multiple values.
WidgetBase::isApplicable public static function Returns if the widget can be used for the provided field. Overrides WidgetInterface::isApplicable 4
WidgetBase::isDefaultValueWidget protected function Returns whether the widget used for default value form.
WidgetBase::setWidgetState public static function Stores processing information about the widget in $form_state. Overrides WidgetBaseInterface::setWidgetState