You are here

public function TwigExtension::getCalendarStripe in Calendar 8

Adds a striped background to the passed event.

Parameters

\Drupal\calendar\CalendarEvent $event:

Return value

string A HTML output string.

File

src/Template/TwigExtension.php, line 34

Class

TwigExtension
A class providing Calendar Twig extensions.

Namespace

Drupal\calendar\Template

Code

public function getCalendarStripe($event) {
  if (empty($event
    ->getStripeHexes()) || !count($event
    ->getStripeHexes())) {
    return;
  }
  $output = '';
  foreach ($event
    ->getStripeLabels() as $k => $stripe_label) {
    if (!empty($event
      ->getStripeHexes()[$k]) && !empty($stripe_label)) {
      $output .= '<div style="background-color:' . $event
        ->getStripeHexes()[$k] . ';color:' . $event
        ->getStripeHexes()[$k] . '" class="stripe" title="Key: ' . $event
        ->getStripeLabels()[$k] . '">&nbsp;</div>' . "\n";
    }
  }
  return $output;
}