Fork me on Github

Symfony2 Integration

Use CalendR inside your Symfony2 application via FrequenceWebCalendRBundle

Installation

You can install it with composer (frequence-web/calendr-bundle), git submodule, or Symfony2.0 deps file. Then, juste add the bundle to your AppKernelClass.

<?php

use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // Your bundles
            new FrequenceWeb\Bundle\CalendRBundle\FrequenceWebCalendRBundle(),
        );

        return $bundles;
    }
}

Accessing CalendR

The CalendR bundle register the CalendR factory into the Symfony2 DIC. You can access it everywhere by requesting the calendr service.

Register an event provider

To add your event provider to the CalendR event manager, you have to declare it as a service, and mark it with the calendr.event_provider tag.

Example Plain Old PHP Object

services:
    my_awesome_event_provider:
        class: Vendor\MyAwesomeEventProvider
        tags:
            - { name: calendr.event_provider }

Example Doctrine2 repository

For Doctrine2 repositories, wich are instantied by the EntityManager, you have to declare the service via factory_service and factory_method.

services:
    booking_repository:
        class:           Your\Bundle\Entity\EventRepository
        factory_service: doctrine.orm.default_entity_manager
        factory_method:  getRepository
        arguments:       ['YourEntity:ShortName']
        tags:
            - { name: calendr.event_provider }

Twig and Symfony2 integration

If you’re using Twig with Symfony2, the CalendR Twig extension will be automatically registered. See Twig integration.