public function ParagraphsBehaviorBase::getFieldNameOptions

Returns list of field names for the given paragraph type and field type.

Parameters

\Drupal\paragraphs\Entity\ParagraphsType $paragraphs_type: The paragraphs type entity.

string $field_type: (optional) Field type to check for existence. If field type is not provided, returns all entity fields.

Return value

string[] The list of field labels keyed by their field name.

Overrides ParagraphsBehaviorInterface::getFieldNameOptions

2 calls to ParagraphsBehaviorBase::getFieldNameOptions()
ParagraphsBackgroundPlugin::buildConfigurationForm in paragraphs_collection/modules/paragraphs_collection_demo/src/Plugin/paragraphs/Behavior/ParagraphsBackgroundPlugin.php
TestFieldsSelectionBehavior::buildConfigurationForm in paragraphs/tests/modules/paragraphs_test/src/Plugin/paragraphs/Behavior/TestFieldsSelectionBehavior.php

File

paragraphs/src/ParagraphsBehaviorBase.php, line 180

Class

ParagraphsBehaviorBase

Namespace

Drupal\paragraphs

Code

public function getFieldNameOptions(ParagraphsType $paragraphs_type, $field_type = NULL) {
  $fields = [];
  $field_definitions = $this->entityFieldManager
    ->getFieldDefinitions('paragraph', $paragraphs_type
    ->id());
  foreach ($field_definitions as $name => $definition) {
    if ($field_definitions[$name] instanceof FieldConfigInterface) {
      if (empty($field_type) || $definition
        ->getType() == $field_type) {
        $fields[$name] = $definition
          ->getLabel();
      }
    }
  }
  return $fields;
}