You are here

protected function ExtraFieldBlockPlugin::getBlockTypeOptions in Entity Extra Field 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/ExtraFieldType/ExtraFieldBlockPlugin.php \Drupal\entity_extra_field\Plugin\ExtraFieldType\ExtraFieldBlockPlugin::getBlockTypeOptions()

Get block type options.

Parameters

array $excluded_ids: An array of block ids to exclude.

Return value

array An array of block type options.

1 call to ExtraFieldBlockPlugin::getBlockTypeOptions()
ExtraFieldBlockPlugin::buildConfigurationForm in src/Plugin/ExtraFieldType/ExtraFieldBlockPlugin.php
Form constructor.

File

src/Plugin/ExtraFieldType/ExtraFieldBlockPlugin.php, line 305

Class

ExtraFieldBlockPlugin
Define extra field block type.

Namespace

Drupal\entity_extra_field\Plugin\ExtraFieldType

Code

protected function getBlockTypeOptions($excluded_ids = []) {
  $options = [];

  // There are a couple block ids that are excluded by default as either
  // they're not really needed, or they are causing problems when selected.
  $excluded_ids = [
    'broken',
    'system_branding_block',
  ] + $excluded_ids;
  foreach ($this->blockManager
    ->getDefinitions() as $block_id => $definition) {
    if (!isset($definition['admin_label']) || in_array($block_id, $excluded_ids)) {
      continue;
    }
    $category = isset($definition['category']) ? $definition['category'] : $this
      ->t('Undefined');
    $options[(string) $category][$block_id] = $definition['admin_label'];
  }
  return $options;
}