class TestFieldsSelectionBehavior

Test plugin with field selection.

Plugin annotation


@ParagraphsBehavior(
  id = "test_field_selection",
  label = @Translation("Test field selection for behavior plugin"),
  description = @Translation("Test field selection for behavior plugin"),
  weight = 0
)

Hierarchy

Expanded class hierarchy of TestFieldsSelectionBehavior

File

paragraphs/tests/modules/paragraphs_test/src/Plugin/paragraphs/Behavior/TestFieldsSelectionBehavior.php, line 19

Namespace

Drupal\paragraphs_test\Plugin\paragraphs\Behavior
View source
class TestFieldsSelectionBehavior extends ParagraphsBehaviorBase {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['field_selection_filter'] = [
      '#type' => 'select',
      '#options' => $this
        ->getFieldNameOptions($form_state
        ->getFormObject()
        ->getEntity(), 'image'),
      '#title' => $this
        ->t('Paragraph fields'),
      '#default_value' => $this->configuration['field_selection_filter'],
      '#description' => $this
        ->t("Choose filtered paragraph field to be applied."),
    ];
    $form['field_selection'] = [
      '#type' => 'select',
      '#options' => $this
        ->getFieldNameOptions($form_state
        ->getFormObject()
        ->getEntity()),
      '#title' => $this
        ->t('Paragraph fields'),
      '#default_value' => $this->configuration['field_selection'],
      '#description' => $this
        ->t("Choose paragraph field to be applied."),
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'field_selection' => '',
      'field_selection_filter' => '',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function view(array &$build, Paragraph $paragraphs_entity, EntityViewDisplayInterface $display, $view_mode) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParagraphsBehaviorBase::$entityFieldManager protected property The entity field manager.
ParagraphsBehaviorBase::buildBehaviorForm public function Builds a behavior perspective for each paragraph based on its type. Overrides ParagraphsBehaviorInterface::buildBehaviorForm 9
ParagraphsBehaviorBase::calculateDependencies public function
ParagraphsBehaviorBase::create public static function 6
ParagraphsBehaviorBase::filterBehaviorFormSubmitValues protected function Removes default behavior form values before storing the user-set ones.
ParagraphsBehaviorBase::getConfiguration public function
ParagraphsBehaviorBase::getFieldNameOptions public function Returns list of field names for the given paragraph type and field type. Overrides ParagraphsBehaviorInterface::getFieldNameOptions
ParagraphsBehaviorBase::isApplicable public static function Returns if the plugin can be used for the provided Paragraphs type. Overrides ParagraphsBehaviorInterface::isApplicable 1
ParagraphsBehaviorBase::preprocess public function Adds a default set of helper variables for preprocessors and templates. Overrides ParagraphsBehaviorInterface::preprocess 1
ParagraphsBehaviorBase::setConfiguration public function
ParagraphsBehaviorBase::settingsIcon public function Returns a short info icon for the current behavior settings. Overrides ParagraphsBehaviorInterface::settingsIcon 1
ParagraphsBehaviorBase::settingsSummary public function Returns a short summary for the current behavior settings. Overrides ParagraphsBehaviorInterface::settingsSummary 8
ParagraphsBehaviorBase::submitBehaviorForm public function Submit the values taken from the form to store the values. Overrides ParagraphsBehaviorInterface::submitBehaviorForm 3
ParagraphsBehaviorBase::submitConfigurationForm public function 6
ParagraphsBehaviorBase::validateBehaviorForm public function Validates the behavior fields form. Overrides ParagraphsBehaviorInterface::validateBehaviorForm 1
ParagraphsBehaviorBase::validateConfigurationForm public function 6
ParagraphsBehaviorBase::__construct public function Constructs a ParagraphsBehaviorBase object. 6
TestFieldsSelectionBehavior::buildConfigurationForm public function Overrides ParagraphsBehaviorBase::buildConfigurationForm
TestFieldsSelectionBehavior::defaultConfiguration public function Overrides ParagraphsBehaviorBase::defaultConfiguration
TestFieldsSelectionBehavior::view public function Extends the paragraph render array with behavior. Overrides ParagraphsBehaviorInterface::view