使用calendar-bundle adesigns显示日历活动

时间:2017-09-18 18:46:17

标签: symfony doctrine-orm fullcalendar bundle

我正在使用使用此捆绑包的日历fullcalendar.io,如以下链接所述:https://github.com/adesigns/calendar-bundle

它显示没有问题,从数据库加载事件时带来的不便。 https://github.com/adesigns/calendar-bundle#adding-events他们没有加载,也没有向我显示任何错误。

我使用的代码是:

//app/config/service.yml
app_bundle.service.listener:
    class: AppBundle\EventListener\CalendarEventListener
    arguments: [ "@doctrine.orm.entity_manager" ]
    tags:
       - { name: 'kernel.event_listener', event: 'calendar.load_data', method: loadData }

然后在将从数据库加载数据的类中:

//AppBundle/EventListener/CalendarEventListener.php 
<?php
namespace AppBundle\EventListener;

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

class CalendarEventListener
{
    private $entityManager;

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


    public function loadData(CalendarEvent $calendarEvent)
    {
        // You can retrieve information from the event dispatcher (eg, You may want which day was selected in the calendar):
        // $startDate = $calendarEvent->getStart();
        // $endDate = $calendarEvent->getEnd();
        // $filters = $calendarEvent->getFilters();

        // You may want do a custom query to populate the events
        // $currentEvents = $repository->findByStartDate($startDate);
        $repository = $this->entityManager->getRepository('BackendBundle:Torneos');
        $torneos = $repository->findAll();

        // You may want to add an Event into the Calendar view.
        /** @var Torneos $torneo */
        foreach ($torneos as $torneo) {
            $calendarEvent->addEvent(new Event($torneo->getNombre(), $torneo->getFechaInicio()));
        }
    }
}

执行此操作不会加载可以执行的信息以使其正常工作?缺少什么

此致

0 个答案:

没有答案