display events in fullcalendarBundle symfony3.4 [closed]

I installed fullcalendarbundle, and I configured it as it is mentioned on the Github https://github.com/tattali/CalendarBundle/blob/master/src/Resources/doc/doctrine-crud.md#3-create-the-crud, I can display the calendar and create events. But, I can display the events in the calendar. I have the impression that it does not detect my CalendarSubscriber file, reason why even if I make errors they do not report anything

here is my CalendarSubcriber.php

<?php
namespace AppEventSubscriber;
use AppBundleRepositoryCalendarEventsRepository;
use CalendarBundleCalendarEvents;
use CalendarBundleEntityEvent;
use CalendarBundleEventCalendarEvent;
use SymfonyComponentEventDispatcherEventSubscriberInterface;
use SymfonyComponentRoutingGeneratorUrlGeneratorInterface;

class CalendarSubscriber implements EventSubscriberInterface
{
private $calendarEventsRepository;
private $router;

public function __construct(
    CalendarEventsRepository $calendarEventsRepository,
    UrlGeneratorInterface $router
) {
    $this->calendarEventsRepository = $calendarEventsRepository;
    $this->router = $router;
}

public static function getSubscribedEvents()
{
    return [
        CalendarEvents::SET_DATA => 'onCalendarSetData',
    ];
}

public function onCalendarSetData(CalendarEvent $calendar)
{
    $start = $calendar->getStart();
    $end = $calendar->getEnd();
    $filters = $calendar->getFilters();

    // Modify the query to fit to your entity and needs
    // Change booking.beginAt by your start date property
    $calendars = $this->calendarEventsRepository
        ->createQueryBuilder('calendar')
        ->where('calendar.datedebut BETWEEN :debut and :fin OR calendar.datefin BETWEEN :debut and :fin')
        ->setParameter('debut', $start->format('Y-m-d H:i:s'))
        ->setParameter('fin', $end->format('Y-m-d H:i:s'))
        ->getQuery()
        ->getResult()
    ;

    foreach ($calendars as $c) {
        // this create the events with your data (here booking data) to fill calendar
        $calendarsEvent = new Event(
            $c->getTitre(),
            $c->getDatedebut(),
            $c->getDatefin() // If the end date is null or not defined, a all day event is created.
        );

        /*
         * Add custom options to events
         *
         * For more information see: https://fullcalendar.io/docs/event-object
         * and: https://github.com/fullcalendar/fullcalendar/blob/master/src/core/options.ts
         */

        $calendarsEvent->setOptions([
            'backgroundColor' => 'red',
            'borderColor' => 'red',
        ]);
        $calendarsEvent->addOption(
            'url',
            $this->router->generate('booking_show', [
                'id' => $c->getId(),
            ])
        );

        // finally, add the event to the CalendarEvent to fill the calendar
        $calendar->addEvent($calendarsEvent);
    }
}
}  

here is my calendar.yaml path in my projet
img_calendar_routing

his content

calendar:
    resource: "@CalendarBundle/Resources/config/routing.yaml"

Thanks for help !

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *