Skip to content

Commit

Permalink
Placeholder PR for updating ical package. For some reason it is not w…
Browse files Browse the repository at this point in the history
…orking, will have to revisit.
  • Loading branch information
geoff-maddock committed Dec 20, 2024
1 parent ec6dd98 commit bc42334
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
48 changes: 42 additions & 6 deletions app/Http/Controllers/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"laravel/socialite": "~5.0",
"suin/php-rss-writer": "^1.5",
"pusher/pusher-php-server": "^7.0",
"eluceo/ical": "^0.16.0",
"eluceo/ical": "^2.14.0",
"bepsvpt/secure-headers": "^7.1",
"facebook/php-business-sdk": "^12.0",
"fakerphp/faker": "^1.18",
Expand Down Expand Up @@ -100,4 +100,4 @@
}
},
"minimum-stability": "stable"
}
}
35 changes: 22 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc42334

Please sign in to comment.