我正在使用adesigns / calendar-bundle。日历已经显示。但是,当我点击任何给定日期时,它不允许我添加事件。此外,我创建了一个持久化到数据库以存储事件的实体类。我加载它们,当我想显示它们时,它会抛出一个错误:http://localhost/guilford/web/app_dev.php/fc-load-events无法加载资源:服务器响应状态为500(内部服务器错误)
CalendarListener.php
<?php
namespace AppBundle\EventListener;
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)
{
$request = $calendarEvent->getRequest();
$filter = $request->get('filter');
$em = $this->getDoctrine()->getManager();
$events =$em->getRepository('AppBundle:CalendarEvent')
->findAll();
foreach ($events as $event) {
// create an event with a start/end time, or an all day event
if ($event->getAllDay() === false) {
$eventEntity = new EventEntity($event->getTitle(), $event->getStartDate(), $event->getEndDate());
} else {
$eventEntity = new EventEntity($event->getTitle(), $event->getStartDate(), null, true);
}
$calendarEvent->addEvent($eventEntity);
}
}
}
日历-settings.js
$(function () {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar-holder').fullCalendar({
header: {
left: 'prev, next',
center: 'title',
right: 'month, basicWeek, basicDay,'
},
lazyFetching: true,
timeFormat: {
// for agendaWeek and agendaDay
agenda: 'h:mmt', // 5:00 - 6:30
// for all other views
'': 'h:mmt' // 7p
},
eventSources: [
{
url: Routing.generate('fullcalendar_loader'),
type: 'POST',
// A way to add custom filters to your event listeners
data: {
},
error: function() {
alert('There was an error while fetching Google Calendar!');
}
}
]
});
});