Symfony2 Event Listener not called - Adesign Calendar Bundle

841 views Asked by At

I've installed the Adesign Calendar Bundle and followed the setup instructions as documented here: https://github.com/adesigns/calendar-bundle

My issue is that in the template where I am trying to display the calendar it is generating an empty div called #calendar-holder - with no calendar inside it.

I'm not getting an console errors, but in the Symfony Profiler I've found this:

Not Called Listeners

Event: calendar.load_events

Listener: CalendarEventListener::loadEvents

I'm fairly new to Symfony so I'm not too sure what this means - I think I have registered my event listener correctly.

Any advice would be much appreciated!

Thanks, Tom

My Code is below:

Services.yml

kernel.listener.calendar_listener:
    class: FrontendBundle\Listener\CalendarEventListener
    tags:
    - { name: kernel.event_listener, event: calendar.load_events, method: loadEvents }
    arguments: [@doctrine.orm.entity_manager, @service_container]

Event Listener Class - CalendarEventListener.php

(I know this class get called as I can echo from within it - but the below method inside the class does not)

namespace FrontendBundle\Listener;

use ADesigns\CalendarBundle\Event\CalendarEvent;
use ADesigns\CalendarBundle\Entity\EventEntity;
use Doctrine\ORM\EntityManager;

class CalendarEventListener
{
private $entityManager;

public function __construct(EntityManager $entityManager)
{
    $this->entityManager = $entityManager;
}

public function loadEvents(CalendarEvent $calendarEvent)
{

    /* Test data */
    $beginDatetime = new \DateTime('2012-01-01 00:00:00');
    $endDatetime = new \DateTime('2012-05-01 00:00:00');
    $eventTitle = "Test Title 1";

    $eventEntity = new EventEntity($eventTitle, $beginDatetime, null, true);

    $calendarEvent->addEvent($eventEntity);

}
}
1

There are 1 answers

0
benza On
services:
    kernel.listener.allotaxi_exception_listener:
        class: FrontendBundle\Listener\CalendarEventListener
        arguments: [@templating, @kernel]
        tags:
        - { name: kernel.event_listener, event: kernel.exception, method: onKernelException }

try this code for your service, with the indentation