tattali / CalendarBundle

Provides event calendar for your Symfony project. Compatible with API like Google Calendar.
https://packagist.org/packages/tattali/calendar-bundle
MIT License
147 stars 22 forks source link

Duplicate every event #34

Closed aniskasmi closed 3 years ago

aniskasmi commented 4 years ago

Hi.

I have duplication of my all event but on database i have just 1 entry

Capture d’écran 2020-11-01 à 19 41 36

missCorie commented 3 years ago

Hi ! I have same problem !

tattali commented 3 years ago

Do you still face this issue ? this probably in your event listener

aniskasmi commented 3 years ago

@tattali My event listener is correct same of tutorial

` document.addEventListener('DOMContentLoaded', () => { var calendarEl = document.getElementById('calendar-holder');

        var calendar = new FullCalendar.Calendar(calendarEl, {
            defaultView: 'dayGridMonth',
            themeSystem: 'bootstrap',
            editable: true,
            locale: 'fr',
            eventSources: [
                {
                    url: "{{ path('fc_load_events') }}",
                    method: "POST",
                    extraParams: {
                        filters: JSON.stringify({})
                    },
                    failure: () => {
                        // alert("There was an error while fetching FullCalendar!");
                    },
                },
            ],
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'dayGridMonth,timeGridWeek,timeGridDay',
            },
            plugins: [ 'interaction', 'dayGrid', 'timeGrid' ], // https://fullcalendar.io/docs/plugin-index
            timeZone: 'UTC',
        });
        calendar.render();
    });

`

tattali commented 3 years ago

Oh my bad, not event listener, event subscriber !

aniskasmi commented 3 years ago

no problem this :

` /**

aniskasmi commented 3 years ago

@tattali Any news ?

tattali commented 3 years ago

Sorry for the delay do you have something in your services.yaml ?

aniskasmi commented 3 years ago

@tattali No problem

` parameters: google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%' picture_directory: '%kernel.project_dir%/public/uploads/pictures' pdf_signed_directory: '%kernel.project_dir%/public/uploads/accounting/quote/pdf/signed' admin_cm_publication_post: '%kernel.project_dir%/public/uploads/admin/cm/publication'

services:

default configuration for services in this file

_defaults:
    autowire: true      # Automatically injects dependencies in your services.
    autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
    resource: '../src/'
    exclude:
        - '../src/DependencyInjection/'
        - '../src/Entity/'
        - '../src/Kernel.php'
        - '../src/Tests/'

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
    resource: '../src/Controller/'
    tags: ['controller.service_arguments']

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\EventSubscriber\CalendarSubscriber:
    tags:
        - { name: 'kernel.event_listener', event: 'calendar.set_data', method: onCalendarSetData }`
tattali commented 3 years ago

you need to only have

App\EventSubscriber\CalendarSubscriber:

not

App\EventSubscriber\CalendarSubscriber:
    tags:
        - { name: 'kernel.event_listener', event: 'calendar.set_data', method: onCalendarSetData }
tattali commented 3 years ago

even without

App\EventSubscriber\CalendarSubscriber:

this should work because autoconfigure is true

aniskasmi commented 3 years ago

@tattali Is work perfect thx