You are here

public function ICalendar::generateDownload in Opigno calendar event 8

Same name and namespace in other branches
  1. 3.x src/iCal/ICalendar.php \Drupal\opigno_calendar_event\iCal\ICalendar::generateDownload()

Call this function to download the invite.

File

src/iCal/ICalendar.php, line 30

Class

ICalendar
Class ICalendar.

Namespace

Drupal\opigno_calendar_event\iCal

Code

public function generateDownload() {
  $generated = $this
    ->generateString();

  // Date in the past.
  header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');

  // Tell it we just updated.
  header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

  // Force revaidation.
  header('Cache-Control: no-store, no-cache, must-revalidate');
  header('Cache-Control: post-check=0, pre-check=0', FALSE);
  header('Pragma: no-cache');
  header('Content-type: text/calendar; charset=utf-8');
  header('Content-Disposition: inline; filename="calendar.ics"');
  header("Content-Description: File Transfer");
  header("Content-Transfer-Encoding: binary");
  header("Content-Length: " . strlen($generated));
  print $generated;
}