ancarebeca / FullCalendarBundle

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

Creating event #50

Open marmanova3 opened 6 years ago

marmanova3 commented 6 years ago

I am implementing FullCalendarBundle into Symfony 3.4 but I am struggling to load data into calendar. The calendar works fine but I cannot see my own event.

I did read the documentation and now I am trying to get an inspiration from example.

The data I am loading is the Event entity with title and date.

I made this listener based on documentation and example:

LoadDataListener.php

namespace AppBundle\Listener;

use AncaRebeca\FullCalendarBundle\Event\CalendarEvent as BundleCalendarEvent;
use AncaRebeca\FullCalendarBundle\Model\Event as BundleEvent;
use AppBundle\Entity\Event as MyEvent;

class LoadDataListener
{
    public function loadData(MyEvent $event, BundleCalendarEvent $calendarEvent)
    {
        $calendarEvent->addEvent(new BundleEvent($event->getName(), $event->getDateTime()));
    }
}

and than I load the data to calendar with:

$loading = new LoadDataListener();
$loading->loadData($event, new CalendarEvent($event->getDateTime(), $event->getDateTime(), array()));

If I understand it correctly, here is the part where I can set up the method how to load the events (fullcalendar.default-settings.js).

    eventSources: [
    {
        url: /full-calendar/load,
        type: 'POST',
        data: {
            filters: { param: foo }
        }
        error: function() {
           //alert()
        }
    }

Thanks a lot for any idea.