You are here

function opigno_calendar_preprocess_block__opigno_calendar in Opigno calendar 8

Same name and namespace in other branches
  1. 3.x opigno_calendar.module \opigno_calendar_preprocess_block__opigno_calendar()

Implements hook_preprocess_HOOK().

File

./opigno_calendar.module, line 161
Contains opigno_calendar.module.

Code

function opigno_calendar_preprocess_block__opigno_calendar(&$variables) {
  $user = \Drupal::currentUser();
  if (isset($variables['elements']['content']['#view_id'])) {
    if ($variables['elements']['content']['#view_id'] == 'opigno_calendar' && $user
      ->hasPermission('create opigno_calendar_event')) {

      // Add to calendar block 'add event' button.
      $url = Url::fromRoute('entity.opigno_calendar_event.add_form', [
        'opigno_calendar_event_type' => 'opigno_calendar_event',
      ]);
      if ($url
        ->access()) {
        $variables['add_event_link'] = Markup::create("<div class='next-link d-flex justify-content-end mb-4 text-uppercase'><a class='btn btn-success color-white add_event_link' href='" . $url
          ->toString() . "'><i class='icon-pencil mr-2'></i>" . t('add event') . "</a></div>");
      }
    }
  }
  return $variables;
}