Installation:
composer require oro/calendar-bundle
Ensure your AppKernel.php includes the bundle:
$bundles[] = new Oro\Bundle\CalendarBundle\OroCalendarBundle();
Database Migrations: Run migrations to create required tables:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
First Use Case:
/calendar (default route)./calendar/system-calendar/create).| Route | Path | Purpose |
|---|---|---|
| Calendar Dashboard | /calendar |
User calendar view |
| System Calendar Management | /calendar/system-calendar |
Admin system calendar CRUD |
| Event Management | /calendar/event |
Create/edit events |
oro_calendar_view, oro_calendar_edit) are pre-configured.// Create a one-time event
$event = new CalendarEvent();
$event->setTitle('Team Meeting')
->setStartDate(new \DateTime('2023-12-25 10:00:00'))
->setEndDate(new \DateTime('2023-12-25 11:00:00'))
->setDescription('Weekly sync')
->setCalendar($user->getDefaultCalendar()); // User calendar
$em->persist($event);
$em->flush();
// Create a recurring event (weekly)
$event->setRecurrenceRule('FREQ=WEEKLY;BYDAY=MO,WE,FR');
// Assign a system calendar to an event
$systemCalendar = $em->getRepository(SystemCalendar::class)->findOneBy(['name' => 'Holidays']);
$event->setCalendar($systemCalendar);
Extend CalendarEvent via inheritance:
class CustomEvent extends CalendarEvent
{
private $customField;
// Add getters/setters for custom fields
public function getCustomField(): ?string
{
return $this->customField;
}
}
Update config.yml:
oro_calendar:
entities:
calendar_event:
custom_event:
class: App\Entity\CustomEvent
label: 'Custom Event'
Use iCal-style rules (e.g., FREQ=MONTHLY;BYDAY=1FR for "first Friday of the month"):
$event->setRecurrenceRule('FREQ=MONTHLY;BYDAY=1FR');
Customize event lists via YAML:
# config/oro/datagrids/calendar_event.yml
oro_calendar_event:
source:
type: orm
query:
select: [e.id, e.title, e.startDate, e.endDate]
from: [Oro\Bundle\CalendarBundle\Entity\CalendarEvent e]
columns:
title:
label: oro.calendar.entity_event.field_title
startDate:
type: datetime
oro_calendar Twig functions for rendering:
{{ oro_calendar.render_event(event) }}
#[Route('/api/events', methods: ['GET'])]
public function getEvents(CalendarEventRepository $repo): JsonResponse
{
return new JsonResponse($repo->findAll());
}
Oro\Bundle\CalendarBundle\Model\CalendarSyncInterface for custom sync logic.ACL Misconfigurations:
oro_calendar_view, oro_calendar_edit) must be granted to roles.oro_calendar_system_manage capability.php bin/console oro:security:check to validate ACLs.Recurrence Rule Parsing:
FREQ=DAILY;INTERVAL=0) break event generation.Oro\Bundle\CalendarBundle\Provider\RecurrenceRuleParser.Time Zone Issues:
config.yml:
oro_calendar:
timezone: 'America/New_York'
Search Indexing:
php bin/console oro:search:reindex --class="Oro\Bundle\CalendarBundle\Entity\CalendarEvent"
Deprecated Services:
oro_calendar.twig.dateformat (private in v2.1.0+). Use Twig filters directly:
{{ event.startDate|date('Y-m-d H:i') }}
$parser = $this->container->get('oro_calendar.provider.recurrence_rule_parser');
$parser->parse('FREQ=WEEKLY;BYDAY=MO');
calendar_event and calendar tables exist. Run migrations if missing.php bin/console cache:clear
Custom Event Fields:
CalendarEvent and update oro_calendar.entities.calendar_event config.priority field and filter events in DataGrid:
columns:
priority:
type: twig
template: OroCalendarBundle:Event:priority.html.twig
Event Validation:
Oro\Bundle\CalendarBundle\Validator\Constraints\Event for custom rules:
use Oro\Bundle\CalendarBundle\Validator\Constraints as OroCalendarAssert;
/**
* @OroCalendarAssert\Event(
* customMessage = "Event must be at least 30 minutes long."
* )
*/
Calendar Sync:
CalendarSyncInterface for external sync (e.g., Google Calendar):
class GoogleCalendarSync implements CalendarSyncInterface
{
public function syncEvents(Calendar $calendar): void
{
// Fetch from Google API and update local events
}
}
services:
app.google_calendar_sync:
class: App\Service\GoogleCalendarSync
tags:
- { name: oro_calendar.sync_provider }
Custom Views:
templates/OroCalendarBundle/ (e.g., event/list.html.twig).class CustomCalendarSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
CalendarEvents::EVENT_PRE_CREATE => 'onPreCreate',
];
}
public function onPreCreate(CreateEvent $event): void
{
$event->getEntity()->setCustomField('default_value');
}
}
$user->setDefaultCalendar($user->getCalendars()->first());
untilDate for finite recurrences:
$event->setRecurrenceRule('FREQ=DAILY;UNTIL=20231231T235959Z');
$validator = $this->container->get('validator');
$errors = $validator->validate($event, [
new EventOverlap(['calendar' => $event->getCalendar()]),
]);
How can I help you explore Laravel packages today?