You are here

protected function Bundle::buildLegend in FullCalendar 8.3

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.2 modules/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

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

Class

Bundle
TODO

Namespace

Drupal\fullcalendar_legend\Plugin\Block

Code

protected function buildLegend(array $fields) {
  $types = [];
  foreach ($fields as $field_name => $field) {
    foreach ($field['bundles'] as $entity_type => $bundles) {
      $bundle_info = entity_get_bundles($entity_type);
      foreach ($bundles 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[$bundle]['label'];
        }
      }
    }
  }
  return $types;
}