The CalendarBundle gives you a built-in calendar for managing events without relying on third-parties like Google. It comes with four different default views; agenda, by day, by week and by month. If you need greater customizations, you can use the bundle as a simple calendar API and build your own logic on it.
Add this line to your composer.json
"require": {
"carlescliment/calendar-bundle": "dev-master"
}
Execute php composer.phar update carlescliment/calendar-bundle
$bundles = array(
// ...
new BladeTester\CalendarBundle\BladeTesterCalendarBundle(),
);
// ...
BladeTesterCalendarBundle:
resource: "@BladeTesterCalendarBundle/Resources/config/routing.yml"
prefix: /
Create a new bundle extending BladeTesterCalendarBundle
namespace Your\OwnCalendarBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class YourOwnCalendarBundle extends Bundle
{
public function getParent()
{
return 'BladeTesterCalendarBundle';
}
}
WARNING: If your bundle includes its own routing file, remember to delete it or completely override the parent bundle paths.
Add it to AppKernel.
$bundles = array(
// ...
new Your\OwnCalendarBundle\YourOwnCalendarBundle(),
);
php app/console doctrine:schema:update --force
php app/console assets:install
Go to http://www.example.com/calendar and enjoy :)
If you want to override the bundle default views to use your design and markup, please follow the next steps.
Copy the template in Resources/views/Base/base.html.twig
into your own bundle and modify it to extend your base template.
<script type="text/javascript" src="{{ asset('bundles/bladetestercalendar/js/jquery-1.9.1.min.js') }}"></script>
<link rel="stylesheet" href="{{ asset('bundles/bladetestercalendar/css/calendar.css') }}" />
<script type="text/javascript" src="{{ asset('bundles/bladetestercalendar/js/calendar.js') }}"></script>
Note: remove the line including jquery if your template already includes it.
You can define your own entities. First, create your custom entity:
namespace Your\OwnCalendarBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use BladeTester\CalendarBundle\Entity\Event as BaseEvent;
/**
* @ORM\Entity(repositoryClass="BladeTester\CalendarBundle\Repository\EventRepository")
* @ORM\Table(name="events")
*/
class Event extends BaseEvent
{
// ... your implementation goes here
}
Then modify your app/config/config.yml
blade_tester_calendar:
driver: doctrine/orm
engine: twig
classes:
event:
entity: Your\OwnBundle\Entity\Event
category:
entity: Your\OwnBundle\Entity\EventCategory
It is easy to extend the behaviour of this bundle by using inheritance in your models and entities. If it is not enough, you can register listeners to the calendar events.
Dispatched whenever an item is about to be created in the database.
your_own_calendar_listener:
class: Your\OwnCalendarBundle\Event\CalendarListener
tags:
- { name: kernel.event_listener, event: calendar.pre-persist, method: onPrePersist }
namespace Your\OwnCalendarBundle\Event;
use BladeTester\CalendarBundle\Event\CalendarEvent;
class CalendarListener {
public function onPrePersist(CalendarEvent $event) {
$event_model = $event->getEvent();
// do whatever with the object before persisting it.
}
}
Dispatched after an item is added to the database.
your_own_calendar_listener:
class: Your\OwnCalendarBundle\Event\CalendarListener
tags:
- { name: kernel.event_listener, event: calendar.post-add, method: onPostAdd }
Dispatched after an item is updated.
your_own_calendar_listener:
class: Your\OwnCalendarBundle\Event\CalendarListener
tags:
- { name: kernel.event_listener, event: calendar.post-update, method: onPostUpdate }
CalendarBundle contains unitary and functional tests. Download the bundle, create the database according to the travis.yml
file and configure the access settings in src/BladeTester/CalendarBundle/Tests/App/parameters.ini
. Run the following command:
cd /path/to/calendar-bundle
composer update
php vendor/bin/phpunit
- Author: Carles Climent (programming)
- Author: Marcos Calatayud (markup and design)
- Contributor: Doug Hayward (french translations, fixes)
- Contributor: Rubén Egiguren (basque translations)
- Contributor: Andrzej Jarzebowski (polish translations)
Any feedback and contribution will be very appreciated.