Bonsoir

je trouve pas comment crée un évenment dans le calendrier j'ai utiliser le bundle https://github.com/adesigns/calendar-bundle

alors j'ai crée le listner

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
 
namespace Ecommerce\BlogBundle\EventListener;
 
use ADesigns\CalendarBundle\Event\CalendarEvent;
use ADesigns\CalendarBundle\Entity\EventEntity;
use Doctrine\ORM\EntityManager;
use Ecommerce\BlogBundle\Entity\Produit;
 
class CalendarEventListener
{
    private $entityManager;
 
    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }
 
    public function loadEvents(CalendarEvent $calendarEvent)
    {
        $startDate = $calendarEvent->getStartDatetime();
        $endDate = $calendarEvent->getEndDatetime();
 
        // The original request so you can get filters from the calendar
        // Use the filter in your query for example
 
        $request = $calendarEvent->getRequest();
        $filter = $request->get('filter');
 
 
        // load events using your custom logic here,
        // for instance, retrieving events from a repository
 
        $companyEvents = $this->entityManager->getRepository('EcommerceBlogBundle:Produit')
                          ->createQueryBuilder('c')
                          ->where('c.event_datetime BETWEEN :startDate and :endDate')
                          ->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))
                          ->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))
                          ->getQuery()->getResult();
                                          var_dump($companyEvent);
 
 
        // $companyEvents and $companyEvent in this example
        // represent entities from your database, NOT instances of EventEntity
        // within this bundle.
        //
        // Create EventEntity instances and populate it's properties with data
        // from your own entities/database values.
 
        foreach($companyEvents as $companyEvent) {
 
            // create an event with a start/end time, or an all day event
            if ($companyEvent->getAllDayEvent() === false) {
                $eventEntity = new EventEntity($companyEvent->getnomProduit(), $companyEvent->getStartDatetime(), $companyEvent->getEndDatetime());
                var_dump($companyEvent);
            } else {
                $eventEntity = new EventEntity($companyEvent->getnomProduit(), $companyEvent->getStartDatetime(), null, true);
                                var_dump($companyEvent);
 
            }
 
            //optional calendar event settings
          $eventEntity->setAllDay(true); // default is false, set to true if this is an all day event
            $eventEntity->setBgColor('#FF0000'); //set the background color of the event's label
            $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label
            $eventEntity->setUrl('http://www.google.com'); // url to send user to when event label is clicked
            $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels
 
            //finally, add the event to the CalendarEvent for displaying on the calendar
            $calendarEvent->addEvent($eventEntity);
        }
    }
}
et le service

Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" ?>
 
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
 
    <services>
        <service id="ecommerce.blogbundle.calendar_listener" class="Ecommerce\BlogBundle\EventListener\CalendarEventListener">
            <argument type="service" id="doctrine.orm.entity_manager" />
            <tag name="kernel.event_listener" event="calendar.load_events" method="loadEvents" />
        </service>
    </services>
</container>

Ça marche pas qu'est ce que je dois mettre dans le controleur pour que l'événement marchera

merci