ancarebeca / FullCalendarBundle

Symfony3 integration with the library FullCalendar.js
36 stars 38 forks source link

Listener::loadData() must be an instance #36

Open jacekpcmaniak opened 6 years ago

jacekpcmaniak commented 6 years ago

I did everything as in instruction, but i get: "Catchable Fatal Error: Argument 1 passed to Ent\AppBundle\Listener\LoadDataListener::loadData() must be an instance of Ent\AppBundle\Listener\CalendarEvent, instance of AncaRebeca\FullCalendarBundle\Event\CalendarEvent given"

ibrasdev commented 6 years ago

did u solve that i have the same problem

ancarebeca commented 6 years ago

Sorry for the delay @jacekpcmaniak . It looks like your listener class has loadData function has the wrong data type parameter ($calendarEvent). You have to set AncaRebeca\FullCalendarBundle\Event\CalendarEvent If you want to use type hinting, not Ent\AppBundle\Listener\CalendarEvent.

Have a look at
https://github.com/ancarebeca/FullCalendarBundle/blob/12096b8fe471832b35a91764729ae9c15d97eba6/Service/Calendar.php#L40-L43 the loadData function needs to receive the same class that Calendar.php is dispatching

You also have an example here https://github.com/ancarebeca/full-calendar-example/blob/master/src/AppBundle/EventListener/LoadDataListener.php

cc: @ibrasdev