-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Placeholder PR for updating ical package. For some reason it is not w…
…orking, will have to revisit.
- Loading branch information
1 parent
ec6dd98
commit bc42334
Showing
3 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,15 @@ | |
use Illuminate\Http\UploadedFile; | ||
use Illuminate\Support\Facades\Route; | ||
use Symfony\Component\HttpFoundation\BinaryFileResponse; | ||
use Eluceo\iCal\Component\Calendar; | ||
use Eluceo\iCal\Component\Event as iCalEvent; | ||
use Eluceo\iCal\Domain\Entity\Calendar; | ||
use Eluceo\iCal\Domain\Entity\Event as iCalEvent; | ||
use Eluceo\iCal\Domain\ValueObject\Organizer; | ||
use Eluceo\iCal\Domain\ValueObject\Uri; | ||
use Eluceo\iCal\Domain\ValueObject\EmailAddress; | ||
use Eluceo\iCal\Domain\ValueObject\DateTime; | ||
use Eluceo\iCal\Domain\ValueObject\Location; | ||
use Eluceo\iCal\Domain\ValueObject\UniqueIdentifier; | ||
use Eluceo\iCal\Presentation\Factory\CalendarFactory; | ||
|
||
class EventsController extends Controller | ||
{ | ||
|
@@ -193,7 +200,7 @@ public function index( | |
|
||
|
||
/** | ||
* Return all future events in iCal format. | ||
* Return all future events in iCal format, used for calendar subscriptions. | ||
*/ | ||
public function indexIcal( | ||
Request $request, | ||
|
@@ -241,24 +248,53 @@ public function indexIcal( | |
define('ICAL_FORMAT', 'Ymd\THis\Z'); | ||
|
||
// create a calendar object | ||
$vCalendar = new Calendar('Arcane City Calendar'); | ||
$vCalendar = new Calendar([]); | ||
|
||
// loop over events | ||
foreach ($events as $event) { | ||
// get the name for the venue or set to empty | ||
$venue = $event->venue ? $event->venue->name : ''; | ||
|
||
// use the route for the event as the unique id | ||
$uniqueId = route('events.show', ['event' => $event]); | ||
|
||
$vEvent = new iCalEvent(); | ||
$vEvent | ||
->setDtStart($event->start_at) | ||
->setDtEnd($event->end_at) | ||
->setDtStamp($event->created_at) | ||
->setSummary($event->name) | ||
->setDescription($event->description) | ||
->setUniqueId($event->id) | ||
->setUniqueId($uniqueId) | ||
->setLocation($venue) | ||
->setModified($event->updated_at) | ||
->setStatus('CONFIRMED') | ||
->setUrl($event->primary_link); | ||
->setUrl($event->primary_link ? $event->primary_link : $uniqueId); | ||
|
||
// get the promoter to set organizer | ||
|
||
if ($event->promoter) { | ||
// check for contacts on the promoter | ||
if ($event->promoter->contacts->count() > 0) { | ||
|
||
// cycle through all contacts to find one with an email address | ||
foreach ($event->promoter->contacts as $contact) { | ||
if ($contact->email) { | ||
|
||
$organizer = new Organizer( | ||
new EmailAddress('[email protected]'), | ||
$event->promoter->name, | ||
new Uri('ldap://example.com:6666/o=ABC%20Industries,c=US???(cn=Jim%20Dolittle)'), | ||
new EmailAddress('[email protected]') | ||
); | ||
|
||
$vEvent->setOrganizer($organizer); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
$vCalendar->addComponent($vEvent); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.