You are here

class DefaultParagraphsWidget in Default Paragraphs 8

Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Plugin annotation


@FieldWidget(
  id = "default_paragraphs",
  label = @Translation("Default paragraphs widget"),
  description = @Translation("Allows us to select multiple paragraph types as defaults."),
  field_types = {
    "entity_reference_revisions"
  }
)

Hierarchy

Expanded class hierarchy of DefaultParagraphsWidget

File

src/Plugin/Field/FieldWidget/DefaultParagraphsWidget.php, line 34

Namespace

Drupal\default_paragraphs\Plugin\Field\FieldWidget
View source
class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFactoryPluginInterface {

  /**
   * Event dispatcher service.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  protected $eventDispatcher;

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

  /**
   * Token service.
   *
   * @var \Drupal\Core\Utility\Token
   */
  protected $tokenService;

  /**
   * Constructs display 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 \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   *   Event dispatcher service.
   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
   *   The entity display repository.
   * @param \Drupal\Core\Utility\Token $token_service.
   *   Token service.
   */
  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EventDispatcherInterface $event_dispatcher, EntityDisplayRepositoryInterface $entity_display_repository, Token $token_service) {
    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
    $this->eventDispatcher = $event_dispatcher;
    $this->entityDisplayRepository = $entity_display_repository;
    $this->tokenService = $token_service;
  }

  /**
   * {@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('event_dispatcher'), $container
      ->get('entity_display.repository'), $container
      ->get('token'));
  }

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return [
      'title' => t('Paragraph'),
      'title_plural' => t('Paragraphs'),
      'edit_mode' => 'closed',
      'closed_mode' => 'summary',
      'autocollapse' => 'none',
      'add_mode' => 'dropdown',
      'form_display_mode' => 'default',
      'default_paragraph_types' => [],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = [];
    $elements['title'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Paragraph Title'),
      '#description' => $this
        ->t('Label to appear as title on the button as "Add new [title]", this label is translatable'),
      '#default_value' => $this
        ->getSetting('title'),
      '#required' => TRUE,
    ];
    $elements['title_plural'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Plural Paragraph Title'),
      '#description' => $this
        ->t('Title in its plural form.'),
      '#default_value' => $this
        ->getSetting('title_plural'),
      '#required' => TRUE,
    ];
    $elements['closed_mode'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Closed mode'),
      '#description' => $this
        ->t('How to display the paragraphs, when the widget is closed. Preview will render the paragraph in the preview view mode and typically needs a custom admin theme.'),
      '#options' => $this
        ->getSettingOptions('closed_mode'),
      '#default_value' => $this
        ->getSetting('closed_mode'),
      '#required' => TRUE,
    ];
    $elements['autocollapse'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Autocollapse'),
      '#description' => $this
        ->t('When a paragraph is opened for editing, close others.'),
      '#options' => $this
        ->getSettingOptions('autocollapse'),
      '#default_value' => $this
        ->getSetting('autocollapse'),
      '#required' => TRUE,
    ];
    $elements['add_mode'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Add mode'),
      '#description' => $this
        ->t('The way to add new Paragraphs.'),
      '#options' => $this
        ->getSettingOptions('add_mode'),
      '#default_value' => $this
        ->getSetting('add_mode'),
      '#required' => TRUE,
    ];
    $elements['form_display_mode'] = [
      '#type' => 'select',
      '#options' => $this->entityDisplayRepository
        ->getFormModeOptions($this
        ->getFieldSetting('target_type')),
      '#description' => $this
        ->t('The form display mode to use when rendering the paragraph form.'),
      '#title' => $this
        ->t('Form display mode'),
      '#default_value' => $this
        ->getSetting('form_display_mode'),
      '#required' => TRUE,
    ];
    $elements['default_paragraph_types'] = [
      '#type' => 'table',
      '#header' => [
        $this
          ->t('Paragraph type'),
        $this
          ->t('Machine name'),
        $this
          ->t('Use as Default'),
        $this
          ->t('Edit mode'),
        $this
          ->t('Weight'),
      ],
      '#empty' => $this
        ->t('There are no items'),
      '#tabledrag' => [
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => 'table-sort-weight',
        ],
      ],
      '#element_validate' => [
        [
          $this,
          'settingsFormDefaultParagraphsValidate',
        ],
      ],
    ];

    // We iterate over the allowed paragraph types, if nothing is selected yet.
    $defaults = $this
      ->getSetting('default_paragraph_types');
    $allowed = $this
      ->getAllowedTypes();
    if (!empty($defaults)) {

      // Make sure that defaults array contains all the allowed paragraph types
      // and not only the default ones. The allowed one should be shown at the
      // bottom of the list if they do not exist in the default array.
      foreach ($allowed as $key => $data) {
        if (!isset($defaults[$key])) {
          $defaults[$key] = [
            'value' => 0,
            'weight' => 1000,
          ];
        }
      }
    }
    else {
      $defaults = $allowed;
    }
    foreach ($defaults as $key => $bundle) {
      $elements['default_paragraph_types'][$key] = [
        'name' => [
          '#markup' => $allowed[$key]['label'],
        ],
        'machine_name' => [
          '#markup' => $key,
        ],
        'value' => [
          '#type' => 'checkbox',
          '#default_value' => isset($defaults[$key]['value']) ? $defaults[$key]['value'] : 0,
        ],
        'edit_mode' => [
          '#type' => 'select',
          '#options' => [
            'edit' => $this
              ->t('Open'),
            'closed' => $this
              ->t('Closed'),
          ],
          '#default_value' => isset($defaults[$key]['edit_mode']) ? $defaults[$key]['edit_mode'] : 'closed',
        ],
        'weight' => [
          '#type' => 'weight',
          '#title' => $this
            ->t('Weight for @title', [
            '@title' => 'First',
          ]),
          '#title_display' => 'invisible',
          '#attributes' => [
            'class' => [
              'table-sort-weight',
            ],
          ],
        ],
      ];
      $elements['default_paragraph_types'][$key]['#attributes']['class'][] = 'draggable';
      $elements['default_paragraph_types'][$key]['#weight'] = isset($defaults[$key]['weight']) ? $defaults[$key]['weight'] : 1000;
    }
    return $elements;
  }

  /**
   * Custom validate handler to check the default paragraph types.
   */
  public function settingsFormDefaultParagraphsValidate($element, FormStateInterface $form_state) {
    if (isset($element['#value'])) {
      $cardinality = $this->fieldDefinition
        ->getFieldStorageDefinition()
        ->getCardinality();
      $field_label = $this->fieldDefinition
        ->getLabel();
      if ($cardinality !== -1) {
        $default_paragraph_count = 0;
        foreach ($element['#value'] as $key => $data) {
          if (!empty($data['value'])) {
            $default_paragraph_count++;
          }
        }
        if ($default_paragraph_count > $cardinality) {
          $form_state
            ->setErrorByName('default_paragraph_types', t('@field field allows you to select not more than @total paragraph types as default.', [
            '@field' => $field_label,
            '@total' => $cardinality,
          ]));
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    $summary = [];
    $summary[] = $this
      ->t('Title: @title', [
      '@title' => $this
        ->getSetting('title'),
    ]);
    $summary[] = $this
      ->t('Plural title: @title_plural', [
      '@title_plural' => $this
        ->getSetting('title_plural'),
    ]);
    $closed_mode = $this
      ->getSettingOptions('closed_mode')[$this
      ->getSetting('closed_mode')];
    $autocollapse = $this
      ->getSettingOptions('autocollapse')[$this
      ->getSetting('autocollapse')];
    $add_mode = $this
      ->getSettingOptions('add_mode')[$this
      ->getSetting('add_mode')];
    $summary[] = $this
      ->t('Closed mode: @closed_mode', [
      '@closed_mode' => $closed_mode,
    ]);
    $summary[] = $this
      ->t('Autocollapse: @autocollapse', [
      '@autocollapse' => $autocollapse,
    ]);
    $summary[] = $this
      ->t('Add mode: @add_mode', [
      '@add_mode' => $add_mode,
    ]);
    $summary[] = $this
      ->t('Form display mode: @form_display_mode', [
      '@form_display_mode' => $this
        ->getSetting('form_display_mode'),
    ]);
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state) {
    $field_name = $this->fieldDefinition
      ->getName();
    $cardinality = $this->fieldDefinition
      ->getFieldStorageDefinition()
      ->getCardinality();
    $this->fieldParents = $form['#parents'];
    $field_state = static::getWidgetState($this->fieldParents, $field_name, $form_state);
    $max = $field_state['items_count'];

    // Consider adding a default paragraph for new host entities.
    if ($max == 0 && $items
      ->getEntity()
      ->isNew()) {
      $default_types = $this
        ->getDefaultParagraphTypes();
      $target_bundle = $this->fieldDefinition
        ->getTargetBundle();
      foreach ($default_types as $delta => $default_type) {

        // Place the default paragraph.
        $default_type_name = $default_type['name'];
        $paragraphs_entity = Paragraph::create([
          'type' => $default_type_name,
        ]);

        // Allow other modules to set default value for each paragraph entity.
        $this->eventDispatcher
          ->dispatch(DefaultParagraphsEvents::ADDED, new DefaultParagraphsAddEvent($paragraphs_entity, $target_bundle));
        $field_state['selected_bundle'] = $default_type_name;
        $display = EntityFormDisplay::collectRenderDisplay($paragraphs_entity, $this
          ->getSetting('form_display_mode'));
        $field_state['paragraphs'][$delta] = [
          'entity' => $paragraphs_entity,
          'display' => $display,
          'mode' => isset($default_type['edit_mode']) ? $default_type['edit_mode'] : 'closed',
          'original_delta' => 1,
        ];
        $max++;
      }
      $field_state['items_count'] = $max;
    }
    $this->realItemCount = $max;
    $is_multiple = $this->fieldDefinition
      ->getFieldStorageDefinition()
      ->isMultiple();
    $field_title = $this->fieldDefinition
      ->getLabel();
    $description = FieldFilteredMarkup::create($this->tokenService
      ->replace($this->fieldDefinition
      ->getDescription()));
    $elements = [];
    $tabs = '';
    $this->fieldIdPrefix = implode('-', array_merge($this->fieldParents, [
      $field_name,
    ]));
    $this->fieldWrapperId = Html::getUniqueId($this->fieldIdPrefix . '-add-more-wrapper');

    // If the parent entity is paragraph add the nested class if not then add
    // the perspective tabs.
    $field_prefix = strtr($this->fieldIdPrefix, '_', '-');
    if (count($this->fieldParents) == 0) {
      if ($items
        ->getEntity()
        ->getEntityTypeId() != 'paragraph') {
        $tabs = '<ul class="paragraphs-tabs tabs primary clearfix"><li id="content" class="tabs__tab"><a href="#' . $field_prefix . '-values">Content</a></li><li id="behavior" class="tabs__tab"><a href="#' . $field_prefix . '-values">Behavior</a></li></ul>';
      }
    }
    if (count($this->fieldParents) > 0) {
      if ($items
        ->getEntity()
        ->getEntityTypeId() === 'paragraph') {
        $form['#attributes']['class'][] = 'paragraphs-nested';
      }
    }
    $elements['#prefix'] = '<div class="is-horizontal paragraphs-tabs-wrapper" id="' . $this->fieldWrapperId . '">' . $tabs;
    $elements['#suffix'] = '</div>';
    $field_state['ajax_wrapper_id'] = $this->fieldWrapperId;

    // Persist the widget state so formElement() can access it.
    static::setWidgetState($this->fieldParents, $field_name, $form_state, $field_state);
    $header_actions = $this
      ->buildHeaderActions($field_state, $form_state);
    if ($header_actions) {
      $elements['header_actions'] = $header_actions;

      // Add a weight element so we guaranty that header actions will stay in
      // first row. We will use this later in
      // paragraphs_preprocess_field_multiple_value_form().
      $elements['header_actions']['_weight'] = [
        '#type' => 'weight',
        '#default_value' => -100,
      ];
    }
    if (!empty($field_state['dragdrop'])) {
      $elements['#attached']['library'][] = 'paragraphs/paragraphs-dragdrop';
      $elements['dragdrop'] = $this
        ->buildNestedParagraphsFoDragDrop($form_state, NULL, []);
      return $elements;
    }
    if ($max > 0) {
      for ($delta = 0; $delta < $max; $delta++) {

        // Add a new empty item if it doesn't exist yet at this delta.
        if (!isset($items[$delta])) {
          $items
            ->appendItem();
        }

        // For multiple fields, title and description are handled by the
        // wrapping.
        // table.
        $element = [
          '#title' => $is_multiple ? '' : $field_title,
          '#description' => $is_multiple ? '' : $description,
        ];
        $element = $this
          ->formSingleElement($items, $delta, $element, $form, $form_state);
        if ($element) {

          // Input field for the delta (drag-n-drop reordering).
          if ($is_multiple) {

            // We name the element '_weight' to avoid clashing with elements
            // defined by widget.
            $element['_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' => $max,
              '#default_value' => $items[$delta]->_weight ?: $delta,
              '#weight' => 100,
            ];
          }

          // Access for the top element is set to FALSE only when the paragraph
          // was removed. A paragraphs that a user can not edit has access on
          // lower level.
          if (isset($element['#access']) && !$element['#access']) {
            $this->realItemCount--;
          }
          else {
            $elements[$delta] = $element;
          }
        }
      }
    }
    $field_state = static::getWidgetState($this->fieldParents, $field_name, $form_state);
    $field_state['real_item_count'] = $this->realItemCount;
    $field_state['add_mode'] = $this
      ->getSetting('add_mode');
    static::setWidgetState($this->fieldParents, $field_name, $form_state, $field_state);
    $elements += [
      '#element_validate' => [
        [
          $this,
          'multipleElementValidate',
        ],
      ],
      '#required' => $this->fieldDefinition
        ->isRequired(),
      '#field_name' => $field_name,
      '#cardinality' => $cardinality,
      '#max_delta' => $max - 1,
    ];
    if ($this->realItemCount > 0) {
      $elements += [
        '#theme' => 'field_multiple_value_form',
        '#cardinality_multiple' => $is_multiple,
        '#title' => $field_title,
        '#description' => $description,
      ];
    }
    else {
      $classes = $this->fieldDefinition
        ->isRequired() ? [
        'form-required',
      ] : [];
      $elements += [
        '#type' => 'container',
        '#theme_wrappers' => [
          'container',
        ],
        '#cardinality_multiple' => TRUE,
        'title' => [
          '#type' => 'html_tag',
          '#tag' => 'strong',
          '#value' => $field_title,
          '#attributes' => [
            'class' => $classes,
          ],
        ],
        'text' => [
          '#type' => 'container',
          'value' => [
            '#markup' => $this
              ->t('No @title added yet.', [
              '@title' => $this
                ->getSetting('title'),
            ]),
            '#prefix' => '<em>',
            '#suffix' => '</em>',
          ],
        ],
      ];
      if ($description) {
        $elements['description'] = [
          '#type' => 'container',
          'value' => [
            '#markup' => $description,
          ],
          '#attributes' => [
            'class' => [
              'description',
            ],
          ],
        ];
      }
    }
    $host = $items
      ->getEntity();
    $this
      ->initIsTranslating($form_state, $host);
    if (($this->realItemCount < $cardinality || $cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) && !$form_state
      ->isProgrammed() && !$this->isTranslating) {
      $elements['add_more'] = $this
        ->buildAddActions();
    }
    $elements['#attached']['library'][] = 'paragraphs/drupal.paragraphs.widget';
    $elements['#attached']['library'][] = 'default_paragraphs/drupal.default_paragraphs.widget';
    return $elements;
  }

  /**
   * Get the machine names of the default paragraph types.
   */
  protected function getDefaultParagraphTypes() {
    $defaults = [];
    $delta = 0;
    $count = 0;
    foreach ($this
      ->getSetting('default_paragraph_types') as $machine_name => $data) {
      if (!empty($data['value'])) {
        $defaults[$delta]['name'] = $machine_name;
        $defaults[$delta]['edit_mode'] = !empty($data['edit_mode']) ? $data['edit_mode'] : 'closed';
        $delta++;
      }
      $count++;
    }
    return $defaults;
  }

}

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.
DefaultParagraphsWidget::$entityDisplayRepository protected property The entity display repository.
DefaultParagraphsWidget::$eventDispatcher protected property Event dispatcher service.
DefaultParagraphsWidget::$tokenService protected property Token service.
DefaultParagraphsWidget::create public static function Creates an instance of the plugin. Overrides WidgetBase::create
DefaultParagraphsWidget::defaultSettings public static function Defines the default settings for this plugin. Overrides ParagraphsWidget::defaultSettings
DefaultParagraphsWidget::formMultipleElements public function Special handling to create form elements for multiple values. Overrides ParagraphsWidget::formMultipleElements
DefaultParagraphsWidget::getDefaultParagraphTypes protected function Get the machine names of the default paragraph types.
DefaultParagraphsWidget::settingsForm public function Returns a form to configure settings for the widget. Overrides ParagraphsWidget::settingsForm
DefaultParagraphsWidget::settingsFormDefaultParagraphsValidate public function Custom validate handler to check the default paragraph types.
DefaultParagraphsWidget::settingsSummary public function Returns a short summary for the current widget settings. Overrides ParagraphsWidget::settingsSummary
DefaultParagraphsWidget::__construct public function Constructs display plugin. Overrides ParagraphsWidget::__construct
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
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
ParagraphsWidget::$accessOptions protected property Accessible paragraphs types.
ParagraphsWidget::$fieldIdPrefix protected property Id to name ajax buttons that includes field parents and field name.
ParagraphsWidget::$fieldParents protected property Parents for the current paragraph.
ParagraphsWidget::$fieldWrapperId protected property Wrapper id to identify the paragraphs.
ParagraphsWidget::$isTranslating protected property Indicates whether the current widget instance is in translation.
ParagraphsWidget::$realItemCount protected property Number of paragraphs item on form.
ParagraphsWidget::ACTION_POSITION_ACTIONS constant Action position is in the actions section of the widget.
ParagraphsWidget::ACTION_POSITION_BASE constant Action position is in the add paragraphs place.
ParagraphsWidget::ACTION_POSITION_HEADER constant Action position is in the table header section.
ParagraphsWidget::addMoreAjax public static function Ajax callback for the "Add another item" button. Overrides WidgetBase::addMoreAjax
ParagraphsWidget::addMoreSubmit public static function Submission handler for the "Add another item" button. Overrides WidgetBase::addMoreSubmit
ParagraphsWidget::addTranslatabilityClue public static function After-build callback for adding the translatability clue from the widget.
ParagraphsWidget::allActionsAjax public static function Ajax callback for all actions.
ParagraphsWidget::allowReferenceChanges protected function Checks if we can allow reference changes.
ParagraphsWidget::autocollapse public static function Returns a state with all paragraphs closed, if autocollapse is enabled.
ParagraphsWidget::buildAddActions protected function Add 'add more' button, if not working with a programmed form.
ParagraphsWidget::buildButtonsAddMode protected function Builds dropdown button for adding new paragraph.
ParagraphsWidget::buildDropbutton protected function Build drop button.
ParagraphsWidget::buildHeaderActions public function Builds header actions.
ParagraphsWidget::buildModalAddForm protected function Builds an add paragraph button for opening of modal form.
ParagraphsWidget::buildNestedParagraphsFoDragDrop protected function Builds the nested drag and drop structure.
ParagraphsWidget::buildSelectAddMode protected function Builds list of actions based on paragraphs type.
ParagraphsWidget::changeAllEditModeSubmit public static function Loops through all paragraphs and change mode for each paragraph instance.
ParagraphsWidget::createMessage public function Helper to create a paragraph UI message.
ParagraphsWidget::dragDropModeAjax public static function Ajax callback for the dragdrop mode.
ParagraphsWidget::dragDropModeSubmit public static function Sets the form mode accordingly.
ParagraphsWidget::duplicateButtonAccess protected function Check duplicate button access.
ParagraphsWidget::duplicateSubmit public static function Creates a duplicate of the paragraph entity.
ParagraphsWidget::elementValidate public function
ParagraphsWidget::errorElement public function Assigns a field-level validation error to the right widget sub-element. Overrides WidgetBase::errorElement
ParagraphsWidget::expandButton public static function Expand button base array into a paragraph widget action button.
ParagraphsWidget::extractFormValues public function Extracts field values from submitted form values. Overrides WidgetBase::extractFormValues
ParagraphsWidget::flagErrors public function Reports field-level validation errors against actual form elements. Overrides WidgetBase::flagErrors
ParagraphsWidget::form public function Creates a form element for a field. Overrides WidgetBase::form
ParagraphsWidget::formElement public function Uses a similar approach to populate a new translation. Overrides WidgetInterface::formElement
ParagraphsWidget::getAccessibleOptions protected function Returns the available paragraphs type.
ParagraphsWidget::getAllowedTypes public function Returns the sorted allowed types for a entity reference field.
ParagraphsWidget::getChildParagraphs protected function Returns a list of child paragraphs for a given field to loop over.
ParagraphsWidget::getDefaultParagraphTypeLabelName protected function Returns the default paragraph type.
ParagraphsWidget::getDefaultParagraphTypeMachineName protected function Returns the machine name for default paragraph type.
ParagraphsWidget::getNumberOfParagraphsInMode protected function Counts the number of paragraphs in a certain mode in a form substructure.
ParagraphsWidget::getSelectionHandlerSetting protected function Returns the value of a setting for the entity reference selection handler.
ParagraphsWidget::getSettingOptions protected function Returns select options for a plugin setting.
ParagraphsWidget::getSubmitElementInfo public static function Get common submit element information for processing ajax submit handlers.
ParagraphsWidget::initIsTranslating protected function Determine if widget is in translation.
ParagraphsWidget::isApplicable public static function Returns if the widget can be used for the provided field. Overrides WidgetBase::isApplicable
ParagraphsWidget::isFeatureEnabled protected function Checks if a widget feature is enabled or not.
ParagraphsWidget::itemAjax public static function
ParagraphsWidget::massageFormValues public function Massages the form values into the format expected for field values. Overrides WidgetBase::massageFormValues
ParagraphsWidget::multipleElementValidate public function Special handling to validate form elements with multiple values.
ParagraphsWidget::paragraphsItemSubmit public static function
ParagraphsWidget::prepareDeltaPosition protected static function Prepares the widget state to add a new paragraph at a specific position.
ParagraphsWidget::removeButtonAccess protected function Check remove button access.
ParagraphsWidget::reorderParagraphs protected static function Reorder paragraphs.
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::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies 6
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::afterBuild public static function After-build handler for field elements in a form.
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::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