public function Calendar::nodeTypeStripe in Calendar 8
Create a stripe base on node type.
Parameters
\Drupal\calendar\CalendarEvent $event: The event result object.
1 call to Calendar::nodeTypeStripe()
- Calendar::render in src/
Plugin/ views/ row/ Calendar.php - Render a row object. This usually passes through to a theme template of some form, but not always.
File
- src/
Plugin/ views/ row/ Calendar.php, line 655
Class
- Calendar
- Plugin which creates a view on the resulting object and formats it as a Calendar entity.
Namespace
Drupal\calendar\Plugin\views\rowCode
public function nodeTypeStripe(CalendarEvent &$event) {
$colors = isset($this->options['colors']['calendar_colors_type']) ? $this->options['colors']['calendar_colors_type'] : [];
if (empty($colors)) {
return;
}
$type_names = node_type_get_names();
$bundle = $event
->getBundle();
$label = '';
$stripeHex = '';
if (array_key_exists($bundle, $type_names) || $colors[$bundle] == CALENDAR_EMPTY_STRIPE) {
$label = $type_names[$bundle];
}
if (array_key_exists($bundle, $colors)) {
$stripeHex = $colors[$bundle];
}
$event
->addStripeLabel($label);
$event
->addStripeHex($stripeHex);
}