8.4.2: using concrete5 calendar programmatically

Permalink
Does anyone know and have examples how to use the concrete5 calendar programmatically?

linuxoid
 
hutman replied on at Permalink Reply
hutman
What exactly are you trying to do?
linuxoid replied on at Permalink Reply
linuxoid
I want to make and show a calendar with scheduled tasks which I can add/edit/update/delete programmatically. For example, a hotel room booking calendar.
hutman replied on at Permalink Reply
hutman
We have done this a little bit, I'm not sure if this code will be helpful to you, but this is how we create an event

use Concrete\Core\Calendar\Calendar;
use Concrete\Core\Calendar\Event\EventRepetition;
use Concrete\Core\Calendar\Event\EditResponse;
use Concrete\Core\Calendar\Event\EventOccurrenceList;
use Concrete\Core\Calendar\Event\EventService;
use Concrete\Core\Entity\Calendar\CalendarEvent;
use Concrete\Core\Entity\Calendar\CalendarEventVersionRepetition;
use Concrete\Core\Entity\Calendar\CalendarEventRepetition;
use Concrete\Core\User\User;
use Concrete\Core\Workflow\Request\ApproveCalendarEventRequest;
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$calendar = Calendar::getByName($calendarName);
$eventService = $app->make(EventService::class);
$u = User::getByUserID(1);
$timezone = $calendar->getSite()->getConfigRepository()->get('timezone');


I can't really assist in the other parts, unfortunately this is not documented well at all, I just read through the core code and figured it out
JeffPaetkau replied on at Permalink Reply
JeffPaetkau
Did you ever find any documentation on this? I'm also looking to interact with calendars programmatically. Ideally I'd be able to associate a calendar with an Express entity ...
linuxoid replied on at Permalink Reply
linuxoid
Well, if it's not documented, it's just too hard... you have to dig into the core code and figure it all out yourself.

No, I haven't looked into this any further. I guess I'll have to some time in the future.
JeffPaetkau replied on at Permalink Reply
JeffPaetkau
Ha ha. ya that's what I'm doing. Still easier than building it all from scratch!