You are here

protected function EntityField::getEntityBundleFieldOptions in Entity Field Condition 2.0.x

Get the entity field options.

Parameters

string $bundle: The node type machine name.

Return value

array An array of entity field options.

Throws

\Drupal\Component\Plugin\Exception\PluginException

1 call to EntityField::getEntityBundleFieldOptions()
EntityField::buildConfigurationForm in src/Plugin/Condition/EntityField.php
Form constructor.

File

src/Plugin/Condition/EntityField.php, line 305

Class

EntityField
Define the entity field condition base class.

Namespace

Drupal\entity_field_condition\Plugin\Condition

Code

protected function getEntityBundleFieldOptions(string $bundle) : array {
  if (empty($bundle)) {
    return [];
  }
  $options = [];
  $field_types = $this->fieldTypePluginManager
    ->getDefinitions();
  foreach ($this
    ->getEntityContextDataEntityFieldDefinitions($bundle) as $definition) {
    $type = $definition
      ->getType();
    if (!isset($field_types[$type])) {
      continue;
    }

    /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $category */
    $category = $field_types[$type]['label'];
    $options[$category
      ->render()][$definition
      ->getName()] = $definition
      ->getLabel();
  }
  return $options;
}