You are here

public function BlockFieldSelectionManager::getWidgetOptions in Block field 8

Returns an key => value array based on allowed referenceable blocks.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field: The 'block_field' field definition.

Return value

array Array of options from definitions.

Throws

\Drupal\Component\Plugin\Exception\PluginException

File

src/BlockFieldSelectionManager.php, line 75

Class

BlockFieldSelectionManager
Provides the Block field selection plugin manager.

Namespace

Drupal\block_field

Code

public function getWidgetOptions(FieldDefinitionInterface $field) {
  $handler = $this
    ->getSelectionHandler($field);
  $options = [];
  foreach ($handler
    ->getReferenceableBlockDefinitions() as $plugin_id => $definition) {
    $category = (string) $definition['category'];
    $options[$category][$plugin_id] = $definition['admin_label'];
  }
  return $options;
}