You are here

protected function Bundle::buildLegend in FullCalendar 8.2

Same name and namespace in other branches
  1. 8.5 modules/fullcalendar_legend/src/Plugin/block/Bundle.php \Drupal\fullcalendar_legend\Plugin\Block\Bundle::buildLegend()
  2. 8 fullcalendar_legend/src/Plugin/block/Bundle.php \Drupal\fullcalendar_legend\Plugin\Block\Bundle::buildLegend()
  3. 8.3 fullcalendar_legend/src/Plugin/block/Bundle.php \Drupal\fullcalendar_legend\Plugin\Block\Bundle::buildLegend()
  4. 8.4 modules/fullcalendar_legend/src/Plugin/block/Bundle.php \Drupal\fullcalendar_legend\Plugin\Block\Bundle::buildLegend()

Parameters

\Drupal\Core\Field\FieldDefinitionInterface[] $fields:

Return value

array

Overrides FullcalendarLegendBase::buildLegend

File

modules/fullcalendar_legend/src/Plugin/block/Bundle.php, line 27
Contains \Drupal\fullcalendar_legend\Plugin\Block\Bundle.

Class

Bundle
TODO

Namespace

Drupal\fullcalendar_legend\Plugin\Block

Code

protected function buildLegend(array $fields) {
  $types = [];
  $bundle_info = \Drupal::service('entity_type.bundle.info')
    ->getAllBundleInfo();
  foreach ($fields as $field_name => $field) {
    $entity_type = $field
      ->getTargetEntityTypeId();
    foreach ($field
      ->getBundles() as $bundle) {
      if (!isset($types[$bundle])) {
        $types[$bundle]['entity_type'] = $entity_type;
        $types[$bundle]['field_name'] = $field_name;
        $types[$bundle]['bundle'] = $bundle;
        $types[$bundle]['label'] = $bundle_info[$entity_type][$bundle]['label'];
      }
    }
  }
  return $types;
}