You are here

class EntityFormField in Views Entity Form Field 8

Defines a views form element for an entity field widget.

Plugin annotation

@ViewsField("entity_form_field");

Hierarchy

Expanded class hierarchy of EntityFormField

File

src/Plugin/views/field/EntityFormField.php, line 29

Namespace

Drupal\views_entity_form_field\Plugin\views\field
View source
class EntityFormField extends FieldPluginBase implements CacheableDependencyInterface, DependentWithRemovalPluginInterface {
  use EntityTranslationRenderTrait;
  use PluginDependencyTrait;
  use UncacheableFieldHandlerTrait;

  /**
   * The entity field manager.
   *
   * @var \Drupal\Core\Entity\EntityFieldManagerInterface
   */
  protected $entityFieldManager;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The entity type ID.
   *
   * @var string
   */
  protected $entityTypeId;

  /**
   * The field type manager.
   *
   * @var \Drupal\Core\Field\FieldTypePluginManagerInterface
   */
  protected $fieldTypeManager;

  /**
   * The field widget plugin manager.
   *
   * @var \Drupal\Core\Field\WidgetPluginManager
   */
  protected $fieldWidgetManager;

  /**
   * The loaded field widgets.
   *
   * @var \Drupal\Core\Field\WidgetInterface[]
   */
  protected $fieldWidgets;

  /**
   * The language manager.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

  /**
   * Constructs a new EditQuantity object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin ID for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
   *   The entity field manager.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Field\WidgetPluginManager $field_widget_manager
   *   The field widget plugin manager.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityFieldManagerInterface $entity_field_manager, EntityTypeManagerInterface $entity_type_manager, WidgetPluginManager $field_widget_manager, LanguageManagerInterface $language_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityFieldManager = $entity_field_manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->fieldWidgetManager = $field_widget_manager;
    $this->languageManager = $language_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_field.manager'), $container
      ->get('entity_type.manager'), $container
      ->get('plugin.manager.field.widget'), $container
      ->get('language_manager'));
  }

  /**
   * Returns the entity type manager.
   *
   * @return \Drupal\Core\Entity\EntityTypeManagerInterface
   *   The entity type manager service.
   */
  protected function getEntityTypeManager() {
    return $this->entityTypeManager;
  }

  /**
   * The field type plugin manager.
   *
   * This is loaded on-demand, since it's only needed during configuration.
   *
   * @return \Drupal\Core\Field\FieldTypePluginManagerInterface
   *   The field type plugin manager.
   */
  protected function getFieldTypeManager() {
    if (is_null($this->fieldTypeManager)) {
      $this->fieldTypeManager = \Drupal::service('plugin.manager.field.field_type');
    }
    return $this->fieldTypeManager;
  }

  /**
   * Get the entity type ID for this views field instance.
   *
   * @return string
   *   The entity type ID.
   */
  protected function getEntityTypeId() {
    if (is_null($this->entityTypeId)) {
      $this->entityTypeId = $this
        ->getEntityType();
    }
    return $this->entityTypeId;
  }

  /**
   * Collects the definition of field.
   *
   * @param string $bundle
   *   The bundle to load the field definition for.
   *
   * @return \Drupal\Core\Field\FieldDefinitionInterface|null
   *   The field definition. Null if not set.
   */
  protected function getBundleFieldDefinition($bundle = NULL) {
    $bundle = !is_null($bundle) ? $bundle : reset($this->definition['bundles']);
    $field_definitions = $this->entityFieldManager
      ->getFieldDefinitions($this
      ->getEntityTypeId(), $bundle);
    return array_key_exists($this->definition['field_name'], $field_definitions) ? $field_definitions[$this->definition['field_name']] : NULL;
  }

  /**
   * Returns an array of applicable widget options for a field.
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   The field definition.
   *
   * @return string[]
   *   An array of applicable widget options.
   */
  protected function getPluginApplicableOptions(FieldDefinitionInterface $field_definition) {
    $options = $this->fieldWidgetManager
      ->getOptions($field_definition
      ->getType());
    $applicable_options = [];
    foreach ($options as $option => $label) {
      $plugin_class = DefaultFactory::getPluginClass($option, $this->fieldWidgetManager
        ->getDefinition($option));
      if ($plugin_class::isApplicable($field_definition)) {
        $applicable_options[$option] = $label;
      }
    }
    return $applicable_options;
  }

  /**
   * Returns the default field widget ID for a specific field type.
   *
   * @param string $field_type
   *   The field type ID.
   *
   * @return null|string
   *   The default field widget ID. Null otherwise.
   */
  protected function getPluginDefaultOption($field_type) {
    $definition = $this
      ->getFieldTypeManager()
      ->getDefinition($field_type, FALSE);
    return $definition && isset($definition['default_widget']) ? $definition['default_widget'] : NULL;
  }

  /**
   * Gets a bundle-specific field widget instance.
   *
   * @param null|string $bundle
   *   The bundle to load the plugin for.
   *
   * @return null|\Drupal\Core\Field\WidgetInterface
   *   The field widget plugin if it is set. Null otherwise.
   */
  protected function getPluginInstance($bundle = NULL) {

    // Cache the created instance per bundle.
    $bundle = !is_null($bundle) ? $bundle : reset($this->definition['bundles']);
    if (!isset($this->fieldWidgets[$bundle]) && ($field_definition = $this
      ->getBundleFieldDefinition($bundle))) {

      // Compile options.
      $options = [
        'field_definition' => $field_definition,
        'form_mode' => 'views_view',
        'prepare' => FALSE,
        'configuration' => $this->options['plugin'],
      ];

      // Unset type if improperly set and set to prepare with default config.
      if (isset($options['configuration']['type']) && empty($options['configuration']['type'])) {
        unset($options['configuration']['type']);
        $options['prepare'] = TRUE;
      }

      // Load field widget.
      $this->fieldWidgets[$bundle] = $this->fieldWidgetManager
        ->getInstance($options);
    }
    return $this->fieldWidgets[$bundle];
  }

  /**
   * {@inheritdoc}
   */
  protected function getLanguageManager() {
    return $this->languageManager;
  }

  /**
   * {@inheritdoc}
   */
  protected function getView() {
    return $this->view;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return Cache::mergeContexts($this
      ->getEntityTranslationRenderer()
      ->getCacheContexts(), [
      'user',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $field_definition = $this
      ->getBundleFieldDefinition();
    $field_storage_definition = $field_definition
      ->getFieldStorageDefinition();
    return Cache::mergeTags($field_definition instanceof CacheableDependencyInterface ? $field_definition
      ->getCacheTags() : [], $field_storage_definition instanceof CacheableDependencyInterface ? $field_storage_definition
      ->getCacheTags() : []);
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    $this->dependencies = parent::calculateDependencies();

    // Add the module providing the configured field storage as a dependency.
    if (($field_definition = $this
      ->getBundleFieldDefinition()) && $field_definition instanceof EntityInterface) {
      $this->dependencies['config'][] = $field_definition
        ->getConfigDependencyName();
    }
    if (!empty($this->options['type'])) {

      // Add the module providing the formatter.
      $this->dependencies['module'][] = $this->fieldWidgetManager
        ->getDefinition($this->options['type'])['provider'];

      // Add the formatter's dependencies.
      if (($formatter = $this
        ->getPluginInstance()) && $formatter instanceof DependentPluginInterface) {
        $this
          ->calculatePluginDependencies($formatter);
      }
    }
    return $this->dependencies;
  }

  /**
   * {@inheritdoc}
   */
  public function onDependencyRemoval(array $dependencies) {

    // See if this handler is responsible for any of the dependencies being
    // removed. If this is the case, indicate that this handler needs to be
    // removed from the View.
    $remove = FALSE;

    // Get all the current dependencies for this handler.
    $current_dependencies = $this
      ->calculateDependencies();
    foreach ($current_dependencies as $group => $dependency_list) {

      // Check if any of the handler dependencies match the dependencies being
      // removed.
      foreach ($dependency_list as $config_key) {
        if (isset($dependencies[$group]) && array_key_exists($config_key, $dependencies[$group])) {

          // This handlers dependency matches a dependency being removed,
          // indicate that this handler needs to be removed.
          $remove = TRUE;
          break 2;
        }
      }
    }
    return $remove;
  }

  /**
   * {@inheritdoc}
   */
  public function clickSortable() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['plugin']['contains']['hide_title']['default'] = TRUE;
    $options['plugin']['contains']['hide_description']['default'] = TRUE;
    $options['plugin']['contains']['type']['default'] = [];
    $options['plugin']['contains']['settings']['default'] = [];
    $options['plugin']['contains']['third_party_settings']['default'] = [];
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $field_definition = $this
      ->getBundleFieldDefinition();
    $form['plugin'] = [
      'type' => [
        '#type' => 'select',
        '#title' => $this
          ->t('Widget type'),
        '#options' => $this
          ->getPluginApplicableOptions($field_definition),
        '#default_value' => $this->options['plugin']['type'],
        '#attributes' => [
          'class' => [
            'field-plugin-type',
          ],
        ],
        '#ajax' => [
          'url' => views_ui_build_form_url($form_state),
        ],
        '#submit' => [
          [
            $this,
            'submitTemporaryForm',
          ],
        ],
        '#executes_submit_callback' => TRUE,
      ],
      'hide_title' => [
        '#type' => 'checkbox',
        '#title' => $this
          ->t('Hide widget title'),
        '#default_value' => $this->options['plugin']['hide_title'],
      ],
      'hide_description' => [
        '#type' => 'checkbox',
        '#title' => $this
          ->t('Hide widget description'),
        '#default_value' => $this->options['plugin']['hide_description'],
      ],
      'settings_edit_form' => [],
    ];

    // Generate the settings form and allow other modules to alter it.
    if ($plugin = $this
      ->getPluginInstance()) {
      $settings_form = $plugin
        ->settingsForm($form, $form_state);

      // Adds the widget third party settings forms.
      $third_party_settings_form = [];
      foreach ($this->moduleHandler
        ->getImplementations('field_widget_third_party_settings_form') as $module) {
        $third_party_settings_form[$module] = $this->moduleHandler
          ->invoke($module, 'field_widget_third_party_settings_form', [
          $plugin,
          $field_definition,
          'views_view',
          $form,
          $form_state,
        ]);
      }
      if ($settings_form || $third_party_settings_form) {
        $form['plugin']['#cell_attributes'] = [
          'colspan' => 3,
        ];
        $form['plugin']['settings_edit_form'] = [
          '#type' => 'fieldset',
          '#title' => $this
            ->t('Widget settings'),
          '#attributes' => [
            'class' => [
              'field-plugin-settings-edit-form',
            ],
          ],
          'settings' => $settings_form,
          'third_party_settings' => $third_party_settings_form,
        ];
        $form['#attributes']['class'][] = 'field-plugin-settings-editing';
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function submitFormCalculateOptions(array $options, array $form_state_options) {

    // When we change the formatter type we don't want to keep any of the
    // previous configured formatter settings, as there might be schema
    // conflict.
    unset($options['settings']);
    $options = $form_state_options + $options;
    if (!isset($options['settings'])) {
      $options['settings'] = [];
    }
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form, $form_state);
    $options =& $form_state
      ->getValue('options');
    $options['plugin']['settings'] = isset($options['plugin']['settings_edit_form']['settings']) ? array_intersect_key($options['plugin']['settings_edit_form']['settings'], $this->fieldWidgetManager
      ->getDefaultSettings($options['plugin']['type'])) : [];
    $options['plugin']['third_party_settings'] = isset($options['plugin']['settings_edit_form']['third_party_settings']) ? $options['plugin']['settings_edit_form']['third_party_settings'] : [];
    unset($options['plugin']['settings_edit_form']);
  }

  /**
   * {@inheritdoc}
   */
  public function getValue(ResultRow $row, $field = NULL) {
    return '<!--form-item-' . $this->options['id'] . '--' . $row->index . '-->';
  }

  /**
   * Form constructor for the views form.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   */
  public function viewsForm(array &$form, FormStateInterface $form_state) {
    $field_name = $this->definition['field_name'];

    // Initialize form values.
    $form['#cache']['max-age'] = 0;
    $form['#attached']['library'][] = 'views_entity_form_field/views_form';
    $form['#attributes']['class'][] = 'views-entity-form';
    $form['#process'][] = [
      $this,
      'viewsFormProcess',
    ];
    $form['#tree'] = TRUE;
    $form += [
      '#parents' => [],
    ];

    // Only add the buttons if there are results.
    if (!empty($this
      ->getView()->result)) {
      $form[$this->options['id']]['#tree'] = TRUE;
      $form[$this->options['id']]['#entity_form_field'] = TRUE;
      foreach ($this
        ->getView()->result as $row_index => $row) {

        // Initialize this row and column.
        $form[$this->options['id']][$row_index]['#parents'] = [
          $this->options['id'],
          $row_index,
        ];
        $form[$this->options['id']][$row_index]['#tree'] = TRUE;

        // Make sure there's an entity for this row (relationships can be null).
        if ($this
          ->getEntity($row)) {

          // Load field definition based on current entity bundle.
          $entity = $this
            ->getEntityTranslation($this
            ->getEntity($row), $row);
          if ($entity
            ->hasField($field_name) && $this
            ->getBundleFieldDefinition($entity
            ->bundle())
            ->isDisplayConfigurable('form')) {
            $items = $entity
              ->get($field_name)
              ->filterEmptyItems();

            // Add widget to form and add field overrides.
            $form[$this->options['id']][$row_index][$field_name] = $this
              ->getPluginInstance()
              ->form($items, $form[$this->options['id']][$row_index], $form_state);
            $form[$this->options['id']][$row_index][$field_name]['#access'] = $entity
              ->access('update') && $items
              ->access('edit');
            $form[$this->options['id']][$row_index][$field_name]['#cache']['contexts'] = $entity
              ->getCacheContexts();
            $form[$this->options['id']][$row_index][$field_name]['#cache']['tags'] = $entity
              ->getCacheTags();
            $form[$this->options['id']][$row_index][$field_name]['#parents'] = [
              $this->options['id'],
              $row_index,
              $field_name,
            ];

            // Hide field widget title.
            if ($this->options['plugin']['hide_title']) {
              $form[$this->options['id']][$row_index][$field_name]['#attributes']['class'][] = 'views-entity-form-field-field-label-hidden';
            }

            // Hide field widget description.
            if ($this->options['plugin']['hide_description']) {
              $form[$this->options['id']][$row_index][$field_name]['#attributes']['class'][] = 'views-entity-form-field-field-description-hidden';
            }
          }
        }
      }
    }
  }

  /**
   * Processes the form, adding the submission handler to save the entities.
   *
   * @param array $element
   *   A nested array form elements comprising the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return array
   *   The processed form element.
   */
  public function viewsFormProcess(array $element, FormStateInterface $form_state) {
    $element['#submit'][] = [
      $this,
      'saveEntities',
    ];
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function viewsFormValidate(array &$form, FormStateInterface $form_state) {
    $form_state
      ->cleanValues();
    $this
      ->buildEntities($form, $form_state, TRUE);
  }

  /**
   * {@inheritdoc}
   */
  public function viewsFormSubmit(array &$form, FormStateInterface $form_state) {
    $form_state
      ->cleanValues();
    $this
      ->buildEntities($form, $form_state);
  }

  /**
   * Update entity objects based upon the submitted form values.
   *
   * @param array $form
   *   A nested array form elements comprising the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   * @param bool $validate
   *   Validate the entity after extracting form values.
   */
  protected function buildEntities(array &$form, FormStateInterface $form_state, $validate = FALSE) {
    $field_name = $this->definition['field_name'];

    // Set this value back to it's relevant entity from each row.
    foreach ($this
      ->getView()->result as $row_index => $row) {

      // Check to make sure that this entity has a relevant field.
      $entity = $this
        ->getEntity($row);
      if ($entity && $entity
        ->hasField($field_name) && $this
        ->getBundleFieldDefinition($entity
        ->bundle())
        ->isDisplayConfigurable('form')) {

        // Get current entity field values.
        $items = $entity
          ->get($field_name)
          ->filterEmptyItems();

        // Extract values.
        $this
          ->getPluginInstance($entity
          ->bundle())
          ->extractFormValues($items, $form[$this->options['id']][$row_index], $form_state);

        // Validate entity and add violations to field widget.
        if ($validate) {
          $violations = $items
            ->validate();
          if ($violations
            ->count() > 0) {
            $this
              ->getPluginInstance($entity
              ->bundle())
              ->flagErrors($items, $violations, $form[$this->options['id']][$row_index], $form_state);
          }
        }
      }
    }
  }

  /**
   * Save the view's entities.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   */
  public function saveEntities(array &$form, FormStateInterface $form_state) {

    // We only want to save the entity once per relationship.
    if (is_null($form_state
      ->getTemporaryValue([
      'saved_relationships',
      $this->relationship,
    ]))) {
      $storage = $this
        ->getEntityTypeManager()
        ->getStorage($this
        ->getEntityTypeId());
      $rows_saved = [];
      $rows_failed = [];
      foreach ($this
        ->getView()->result as $row_index => $row) {
        $entity = $this
          ->getEntity($row);
        if ($entity) {
          $entity = $this
            ->getEntityTranslation($entity, $row);
          $original_entity = $this
            ->getEntityTranslation($storage
            ->loadUnchanged($entity
            ->id()), $row);
          try {
            if ($this
              ->entityShouldBeSaved($entity, $original_entity)) {
              $storage
                ->save($entity);
              $rows_saved[$row_index] = $entity
                ->label();
            }
          } catch (\Exception $exception) {
            $rows_failed[$row_index] = $entity
              ->label();
          }
        }
      }

      // Let the user know how many entities were saved.
      $messenger = \Drupal::messenger();
      $entity_type_definition = $this->entityTypeManager
        ->getDefinition($this
        ->getEntityTypeId());
      $messenger
        ->addStatus($this
        ->formatPlural(count($rows_saved), '@count @singular_label saved.', '@count @plural_label saved.', [
        '@count' => count($rows_saved),
        '@singular_label' => $entity_type_definition
          ->getSingularLabel(),
        '@plural_label' => $entity_type_definition
          ->getPluralLabel(),
      ]));

      // Let the user know which entities couldn't be saved.
      if (count($rows_failed) > 0) {
        $messenger
          ->addWarning($this
          ->formatPlural(count($rows_failed), '@count @singular_label failed to save: @labels', '@count @plural_label failed to save: @labels', [
          '@count' => count($rows_failed),
          '@singular_label' => $entity_type_definition
            ->getSingularLabel(),
          '@plural_label' => $entity_type_definition
            ->getPluralLabel(),
          '@labels' => implode(', ', $rows_failed),
        ]));
      }

      // Track that this relationship has been saved.
      $form_state
        ->setTemporaryValue([
        'saved_relationships',
        $this->relationship,
      ], TRUE);
    }
  }

  /**
   * Determines if an entity should be saved.
   *
   * @param EntityInterface $entity
   *   The possibly modified entity in question.
   * @param EntityInterface $original_entity
   *   The original unmodified entity.
   *
   * @return bool
   *   TRUE if the entity should be saved; FALSE otherwise.
   */
  protected function entityShouldBeSaved(EntityInterface $entity, EntityInterface $original_entity) {
    $save_entity = FALSE;
    foreach ($entity as $field_name => $new_field) {
      $original_field = $original_entity
        ->get($field_name);
      if (!$new_field
        ->equals($original_field)) {
        $save_entity = TRUE;
        break;
      }
    }
    return $save_entity;
  }

  /**
   * {@inheritdoc}
   */
  public function query() {

    // Do nothing.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency.
EntityFormField::$entityFieldManager protected property The entity field manager.
EntityFormField::$entityTypeId protected property The entity type ID.
EntityFormField::$entityTypeManager protected property The entity type manager.
EntityFormField::$fieldTypeManager protected property The field type manager.
EntityFormField::$fieldWidgetManager protected property The field widget plugin manager.
EntityFormField::$fieldWidgets protected property The loaded field widgets.
EntityFormField::$languageManager protected property The language manager.
EntityFormField::buildEntities protected function Update entity objects based upon the submitted form values.
EntityFormField::buildOptionsForm public function Default options form that provides the label widget that all fields should have. Overrides FieldPluginBase::buildOptionsForm
EntityFormField::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides HandlerBase::calculateDependencies
EntityFormField::clickSortable public function Determines if this field is click sortable. Overrides FieldPluginBase::clickSortable
EntityFormField::create public static function Creates an instance of the plugin. Overrides PluginBase::create
EntityFormField::defineOptions protected function Information about options for all kinds of purposes will be held here. Overrides FieldPluginBase::defineOptions
EntityFormField::entityShouldBeSaved protected function Determines if an entity should be saved.
EntityFormField::getBundleFieldDefinition protected function Collects the definition of field.
EntityFormField::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
EntityFormField::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge
EntityFormField::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyInterface::getCacheTags
EntityFormField::getEntityTypeId protected function Get the entity type ID for this views field instance. Overrides EntityTranslationRenderTrait::getEntityTypeId
EntityFormField::getEntityTypeManager protected function Returns the entity type manager. Overrides EntityTranslationRenderTrait::getEntityTypeManager
EntityFormField::getFieldTypeManager protected function The field type plugin manager.
EntityFormField::getLanguageManager protected function Returns the language manager. Overrides EntityTranslationRenderTrait::getLanguageManager
EntityFormField::getPluginApplicableOptions protected function Returns an array of applicable widget options for a field.
EntityFormField::getPluginDefaultOption protected function Returns the default field widget ID for a specific field type.
EntityFormField::getPluginInstance protected function Gets a bundle-specific field widget instance.
EntityFormField::getValue public function Gets the value that's supposed to be rendered. Overrides UncacheableFieldHandlerTrait::getValue
EntityFormField::getView protected function Returns the top object of a view. Overrides EntityTranslationRenderTrait::getView
EntityFormField::onDependencyRemoval public function Allows a plugin to define whether it should be removed. Overrides DependentWithRemovalPluginInterface::onDependencyRemoval
EntityFormField::query public function Called to add the field to a query. Overrides FieldPluginBase::query
EntityFormField::saveEntities public function Save the view's entities.
EntityFormField::submitFormCalculateOptions public function Calculates options stored on the handler Overrides HandlerBase::submitFormCalculateOptions
EntityFormField::submitOptionsForm public function Performs some cleanup tasks on the options array before saving it. Overrides FieldPluginBase::submitOptionsForm
EntityFormField::viewsForm public function Form constructor for the views form.
EntityFormField::viewsFormProcess public function Processes the form, adding the submission handler to save the entities.
EntityFormField::viewsFormSubmit public function
EntityFormField::viewsFormValidate public function
EntityFormField::__construct public function Constructs a new EditQuantity object. Overrides HandlerBase::__construct
EntityTranslationRenderTrait::$entityTranslationRenderer protected property The renderer to be used to render the entity row.
EntityTranslationRenderTrait::getEntityRepository protected function Returns the entity repository. 7
EntityTranslationRenderTrait::getEntityTranslation public function Returns the entity translation matching the configured row language.
EntityTranslationRenderTrait::getEntityTranslationRenderer protected function Returns the current renderer.
FieldPluginBase::$additional_fields public property Stores additional fields which get added to the query.
FieldPluginBase::$aliases public property
FieldPluginBase::$field_alias public property
FieldPluginBase::$lastRenderIndex protected property Keeps track of the last render index.
FieldPluginBase::$linkGenerator protected property The link generator.
FieldPluginBase::$original_value public property The field value prior to any rewriting.
FieldPluginBase::$renderer protected property Stores the render API renderer. Overrides PluginBase::$renderer 1
FieldPluginBase::addAdditionalFields protected function Add 'additional' fields to the query.
FieldPluginBase::addSelfTokens protected function Add any special tokens this field might use for itself. 4
FieldPluginBase::adminLabel public function Return a string representing this handler's name in the UI. Overrides HandlerBase::adminLabel
FieldPluginBase::adminSummary public function Provide extra data to the administration form Overrides HandlerBase::adminSummary
FieldPluginBase::advancedRender public function Renders a field using advanced settings. Overrides FieldHandlerInterface::advancedRender
FieldPluginBase::allowAdvancedRender protected function Determine if this field can allow advanced rendering.
FieldPluginBase::clickSort public function Adds an ORDER BY clause to the query for click sort columns. Overrides FieldHandlerInterface::clickSort 1
FieldPluginBase::documentSelfTokens protected function Document any special tokens this field might use for itself. 3
FieldPluginBase::elementClasses public function Returns the class of the field. Overrides FieldHandlerInterface::elementClasses
FieldPluginBase::elementLabelClasses public function Returns the class of the field's label. Overrides FieldHandlerInterface::elementLabelClasses
FieldPluginBase::elementLabelType public function Returns an HTML element for the label based upon the field's element type. Overrides FieldHandlerInterface::elementLabelType
FieldPluginBase::elementType public function Returns an HTML element based upon the field's element type. Overrides FieldHandlerInterface::elementType 1
FieldPluginBase::elementWrapperClasses public function Returns the class of the field's wrapper. Overrides FieldHandlerInterface::elementWrapperClasses
FieldPluginBase::elementWrapperType public function Returns an HTML element for the wrapper based upon the field's element type. Overrides FieldHandlerInterface::elementWrapperType
FieldPluginBase::getElements public function Provides a list of elements valid for field HTML. Overrides FieldHandlerInterface::getElements
FieldPluginBase::getEntity public function Gets the entity matching the current row and relationship. Overrides FieldHandlerInterface::getEntity
FieldPluginBase::getPreviousFieldLabels protected function Returns all field labels of fields before this field.
FieldPluginBase::getRenderer protected function Returns the render API renderer. Overrides PluginBase::getRenderer
FieldPluginBase::getRenderTokens public function Gets the 'render' tokens to use for advanced rendering. Overrides FieldHandlerInterface::getRenderTokens
FieldPluginBase::getTokenValuesRecursive protected function Recursive function to add replacements for nested query string parameters.
FieldPluginBase::init public function Initialize the plugin. Overrides HandlerBase::init 14
FieldPluginBase::isValueEmpty public function Checks if a field value is empty. Overrides FieldHandlerInterface::isValueEmpty
FieldPluginBase::label public function Gets this field's label. Overrides FieldHandlerInterface::label
FieldPluginBase::linkGenerator protected function Gets the link generator.
FieldPluginBase::preRender public function Runs before any fields are rendered. Overrides FieldHandlerInterface::preRender 10
FieldPluginBase::renderAltered protected function Render this field as user-defined altered text.
FieldPluginBase::renderAsLink protected function Render this field as a link, with the info from a fieldset set by the user.
FieldPluginBase::renderText public function Performs an advanced text render for the item. Overrides FieldHandlerInterface::renderText
FieldPluginBase::renderTrimText protected function Trims the field down to the specified length.
FieldPluginBase::RENDER_TEXT_PHASE_COMPLETELY constant Indicator of the renderText() method for rendering the whole element. (if no render_item() method is available).
FieldPluginBase::RENDER_TEXT_PHASE_EMPTY constant Indicator of the renderText() method for rendering the empty text.
FieldPluginBase::RENDER_TEXT_PHASE_SINGLE_ITEM constant Indicator of the renderText() method for rendering a single item. (If no render_item() is present).
FieldPluginBase::theme public function Passes values to drupal_render() using $this->themeFunctions() as #theme. Overrides FieldHandlerInterface::theme
FieldPluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. Overrides PluginBase::themeFunctions
FieldPluginBase::tokenizeValue public function Replaces a value with tokens from the last field. Overrides FieldHandlerInterface::tokenizeValue
FieldPluginBase::trimText public static function Trims the field down to the specified length.
FieldPluginBase::useStringGroupBy public function Determines if this field will be available as an option to group the result by in the style settings. Overrides FieldHandlerInterface::useStringGroupBy
HandlerBase::$field public property With field you can override the realField if the real field is not set.
HandlerBase::$moduleHandler protected property The module handler. 3
HandlerBase::$query public property Where the $query object will reside: 7
HandlerBase::$realField public property The actual field in the database table, maybe different on other kind of query plugins/special handlers.
HandlerBase::$relationship public property The relationship used for this field.
HandlerBase::$table public property The table this handler is attached to.
HandlerBase::$tableAlias public property The alias of the table of this handler which is used in the query.
HandlerBase::$viewsData protected property The views data service.
HandlerBase::acceptExposedInput public function Take input from exposed handlers and assign to this handler, if necessary. 1
HandlerBase::access public function Check whether given user has access to this handler. Overrides ViewsHandlerInterface::access 4
HandlerBase::breakString public static function Breaks x,y,z and x+y+z into an array. Overrides ViewsHandlerInterface::breakString
HandlerBase::broken public function Determines if the handler is considered 'broken', meaning it's a placeholder used when a handler can't be found. Overrides ViewsHandlerInterface::broken
HandlerBase::buildExposedForm public function Render our chunk of the exposed handler form when selecting 1
HandlerBase::buildExposeForm public function Form for exposed handler options. 2
HandlerBase::buildExtraOptionsForm public function Provide a form for setting options. 1
HandlerBase::buildGroupByForm public function Provide a form for aggregation settings. 1
HandlerBase::canExpose public function Determine if a handler can be exposed. 2
HandlerBase::caseTransform protected function Transform a string by a certain method.
HandlerBase::defaultExposeOptions public function Set new exposed option defaults when exposed setting is flipped on. 2
HandlerBase::defineExtraOptions public function Provide defaults for the handler.
HandlerBase::displayExposedForm public function Displays the Expose form.
HandlerBase::ensureMyTable public function Ensure the main table for this handler is in the query. This is used a lot. Overrides ViewsHandlerInterface::ensureMyTable 2
HandlerBase::exposedInfo public function Get information about the exposed form for the form renderer. 1
HandlerBase::getDateField public function Creates cross-database SQL dates. 2
HandlerBase::getDateFormat public function Creates cross-database SQL date formatting. 2
HandlerBase::getEntityType public function Determines the entity type used by this handler. Overrides ViewsHandlerInterface::getEntityType
HandlerBase::getField public function Shortcut to get a handler's raw field value. Overrides ViewsHandlerInterface::getField
HandlerBase::getJoin public function Get the join object that should be used for this handler. Overrides ViewsHandlerInterface::getJoin
HandlerBase::getModuleHandler protected function Gets the module handler.
HandlerBase::getTableJoin public static function Fetches a handler to join one table to a primary table from the data cache. Overrides ViewsHandlerInterface::getTableJoin
HandlerBase::getViewsData protected function Gets views data service.
HandlerBase::hasExtraOptions public function If a handler has 'extra options' it will get a little settings widget and another form called extra_options. 1
HandlerBase::isAGroup public function Returns TRUE if the exposed filter works like a grouped filter. 1
HandlerBase::isExposed public function Determine if this item is 'exposed', meaning it provides form elements to let users modify the view.
HandlerBase::multipleExposedInput public function Define if the exposed input has to be submitted multiple times. This is TRUE when exposed filters grouped are using checkboxes as widgets. 1
HandlerBase::placeholder protected function Provides a unique placeholders for handlers.
HandlerBase::postExecute public function Run after the view is executed, before the result is cached. Overrides ViewsHandlerInterface::postExecute
HandlerBase::preQuery public function Run before the view is built. Overrides ViewsHandlerInterface::preQuery 2
HandlerBase::sanitizeValue public function Sanitize the value for output. Overrides ViewsHandlerInterface::sanitizeValue
HandlerBase::setModuleHandler public function Sets the module handler.
HandlerBase::setRelationship public function Called just prior to query(), this lets a handler set up any relationship it needs. Overrides ViewsHandlerInterface::setRelationship
HandlerBase::setViewsData public function
HandlerBase::showExposeButton public function Shortcut to display the expose/hide button. 2
HandlerBase::showExposeForm public function Shortcut to display the exposed options form. Overrides ViewsHandlerInterface::showExposeForm
HandlerBase::storeExposedInput public function If set to remember exposed input in the session, store it there. 1
HandlerBase::submitExposed public function Submit the exposed handler form
HandlerBase::submitExposeForm public function Perform any necessary changes to the form exposes prior to storage. There is no need for this function to actually store the data.
HandlerBase::submitExtraOptionsForm public function Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.
HandlerBase::submitGroupByForm public function Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data. 1
HandlerBase::submitTemporaryForm public function A submit handler that is used for storing temporary items when using multi-step changes, such as ajax requests.
HandlerBase::usesGroupBy public function Provides the handler some groupby. 13
HandlerBase::validate public function Validate that the plugin is correct and can be saved. Overrides PluginBase::validate 2
HandlerBase::validateExposed public function Validate the exposed handler form 4
HandlerBase::validateExposeForm public function Validate the options form. 1
HandlerBase::validateExtraOptionsForm public function Validate the options form.
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::$definition public property Plugins's definition
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::$usesOptions protected property Denotes whether the plugin has an additional options form. 8
PluginBase::$view public property The top object of a view. 1
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::destroy public function Clears a plugin. Overrides ViewsPluginInterface::destroy 2
PluginBase::doFilterByDefinedOptions protected function Do the work to filter out stored options depending on the defined options.
PluginBase::filterByDefinedOptions public function Filter out stored options depending on the defined options. Overrides ViewsPluginInterface::filterByDefinedOptions
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements. Overrides ViewsPluginInterface::getAvailableGlobalTokens
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::getProvider public function Returns the plugin provider. Overrides ViewsPluginInterface::getProvider
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form. Overrides ViewsPluginInterface::globalTokenForm
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced. Overrides ViewsPluginInterface::globalTokenReplace
PluginBase::INCLUDE_ENTITY constant Include entity row languages when listing languages.
PluginBase::INCLUDE_NEGOTIATED constant Include negotiated languages when listing languages.
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::listLanguages protected function Makes an array of languages, optionally including special languages.
PluginBase::pluginTitle public function Return the human readable name of the display. Overrides ViewsPluginInterface::pluginTitle
PluginBase::preRenderAddFieldsetMarkup public static function Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface::preRenderAddFieldsetMarkup
PluginBase::preRenderFlattenData public static function Flattens the structure of form elements. Overrides ViewsPluginInterface::preRenderFlattenData
PluginBase::queryLanguageSubstitutions public static function Returns substitutions for Views queries for languages.
PluginBase::setOptionDefaults protected function Fills up the options of the plugin with defaults.
PluginBase::summaryTitle public function Returns the summary of the settings in the display. Overrides ViewsPluginInterface::summaryTitle 6
PluginBase::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks 6
PluginBase::unpackOptions public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. Overrides ViewsPluginInterface::unpackOptions
PluginBase::usesOptions public function Returns the usesOptions property. Overrides ViewsPluginInterface::usesOptions 8
PluginBase::validateOptionsForm public function Validate the options form. Overrides ViewsPluginInterface::validateOptionsForm 15
PluginBase::viewsTokenReplace protected function Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin. 1
PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT constant Query string to indicate the site default language.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
PluginDependencyTrait::getPluginDependencies protected function Calculates and returns dependencies of a specific plugin instance.
PluginDependencyTrait::moduleHandler protected function Wraps the module handler. 1
PluginDependencyTrait::themeHandler protected function Wraps the theme handler. 1
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.
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.
UncacheableFieldHandlerTrait::doRender protected function Actually renders the field markup.
UncacheableFieldHandlerTrait::getFieldTokenPlaceholder abstract protected function
UncacheableFieldHandlerTrait::postRender public function
UncacheableFieldHandlerTrait::render public function