You are here

public function FieldHandlerPluginManager::getHandlerOptions in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Plugin/Type/FieldHandlerPluginManager.php \Drupal\cms_content_sync\Plugin\Type\FieldHandlerPluginManager::getHandlerOptions()
  2. 2.0.x src/Plugin/Type/FieldHandlerPluginManager.php \Drupal\cms_content_sync\Plugin\Type\FieldHandlerPluginManager::getHandlerOptions()

Parameters

string $entity_type: The entity type of the processed entity

string $bundle: The bundle of the processed entity

string $field_name: The name of the processed field

\Drupal\Core\Field\FieldDefinitionInterface $field: The definition of the processed field

bool $labels_only: Whether to return labels instead of the whole definition

Return value

array An associative array $id=>$label|$handlerDefinition to display options

File

src/Plugin/Type/FieldHandlerPluginManager.php, line 74

Class

FieldHandlerPluginManager
Manages discovery and instantiation of field handler plugins.

Namespace

Drupal\cms_content_sync\Plugin\Type

Code

public function getHandlerOptions($entity_type, $bundle, $field_name, FieldDefinitionInterface $field, $labels_only = false) {
  $options = [];
  foreach ($this
    ->getDefinitions() as $id => $definition) {
    if (!$definition['class']::supports($entity_type, $bundle, $field_name, $field)) {
      continue;
    }
    $options[$id] = $labels_only ? $definition['label']
      ->render() : $definition;
  }
  return $options;
}