protected function Term::buildLegend in FullCalendar 8.3
Same name and namespace in other branches
- 8.5 modules/fullcalendar_legend/src/Plugin/block/Term.php \Drupal\fullcalendar_legend\Plugin\Block\Term::buildLegend()
- 8 fullcalendar_legend/src/Plugin/block/Term.php \Drupal\fullcalendar_legend\Plugin\Block\Term::buildLegend()
- 8.2 modules/fullcalendar_legend/src/Plugin/block/Term.php \Drupal\fullcalendar_legend\Plugin\Block\Term::buildLegend()
- 8.4 modules/fullcalendar_legend/src/Plugin/block/Term.php \Drupal\fullcalendar_legend\Plugin\Block\Term::buildLegend()
Parameters
\Drupal\Core\Field\FieldDefinitionInterface[] $fields:
Return value
array
Overrides FullcalendarLegendBase::buildLegend
File
- fullcalendar_legend/
src/ Plugin/ block/ Term.php, line 71 - Contains \Drupal\fullcalendar_legend\Plugin\Block\Term.
Class
- Term
- TODO
Namespace
Drupal\fullcalendar_legend\Plugin\BlockCode
protected function buildLegend(array $fields) {
$types = [];
/** @var \Drupal\Core\Field\FieldDefinitionInterface[] $fields */
foreach ($fields as $field_name => $field) {
// Then by entity type.
foreach ($field
->getBundles() as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
foreach ($this->entityManager
->getFieldDefinitions($entity_type, $bundle) as $taxonomy_field_name => $taxonomy_field) {
if ($taxonomy_field
->getType() != 'taxonomy_term_reference') {
continue;
}
foreach ($taxonomy_field
->getSetting('allowed_values') as $vocab) {
$term_ids = $this->entityQuery
->get('taxonomy_term')
->condition('vid', $vocab['vocabulary'])
->execute();
foreach ($this->termStorage
->load($term_ids) as $term) {
$types[$term
->id()] = [
'entity_type' => $entity_type,
'field_name' => $field_name,
'bundle' => $bundle,
'label' => $term
->label(),
'taxonomy_field' => $taxonomy_field_name,
'tid' => $term
->id(),
];
}
}
}
}
}
}
return $types;
}