如何由用户自定义 FullCalenderBundle [Symfony4]
How to customize the FullCalenderBundle by user [Symfony4]
我是 symfony 的初学者,我想由用户自定义 FullCalendar。用户只能显示他的事件。那么我该如何编辑这个脚本呢? :
<script type="text/javascript">
$(function () {
$('#calendar-holder').fullCalendar({
header: {
left: 'prev, next, today',
center: 'title',
right: 'month, basicWeek, basicDay'
},
lazyFetching: true,
navLinks: true,
eventSources: [
{
url: '/fc-load-events',
type: 'POST',
data: {
filters: {}
},
error: function () {
alert('There was an error while fetching FullCalendar!');
}
}
]
});
});
</script>
您需要先从数据库中获取事件。然后您可以将它们导入到该完整日历脚本中。
您需要首先在用户和事件实体之间设置 "One To Many" 关系。然后你可以使用类似这段代码的东西,让 doctrine return 所有具有与活动用户 ID 匹配的 userId 的事件。
$return = $this->getDoctrine()->getRepository(Events::class)->findBy(array('userid' => $user->getId()));
最后,您可以使用 JsonResponse return 事件作为 json。
return new JsonResponse($return)
我很高兴为您进一步整理这个答案。但我需要知道你真正在问什么。我希望这会有所帮助,但这是我在如此有限的信息下所能做的最好的事情了!
我是 symfony 的初学者,我想由用户自定义 FullCalendar。用户只能显示他的事件。那么我该如何编辑这个脚本呢? :
<script type="text/javascript">
$(function () {
$('#calendar-holder').fullCalendar({
header: {
left: 'prev, next, today',
center: 'title',
right: 'month, basicWeek, basicDay'
},
lazyFetching: true,
navLinks: true,
eventSources: [
{
url: '/fc-load-events',
type: 'POST',
data: {
filters: {}
},
error: function () {
alert('There was an error while fetching FullCalendar!');
}
}
]
});
});
</script>
您需要先从数据库中获取事件。然后您可以将它们导入到该完整日历脚本中。
您需要首先在用户和事件实体之间设置 "One To Many" 关系。然后你可以使用类似这段代码的东西,让 doctrine return 所有具有与活动用户 ID 匹配的 userId 的事件。
$return = $this->getDoctrine()->getRepository(Events::class)->findBy(array('userid' => $user->getId()));
最后,您可以使用 JsonResponse return 事件作为 json。
return new JsonResponse($return)
我很高兴为您进一步整理这个答案。但我需要知道你真正在问什么。我希望这会有所帮助,但这是我在如此有限的信息下所能做的最好的事情了!