services:
    oro_calendar.listener.entity_listener:
        class: Oro\Bundle\CalendarBundle\EventListener\EntityListener
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_calendar.model.recurrence'
        tags:
            - { name: doctrine.event_listener, event: preUpdate }
            - { name: doctrine.event_listener, event: prePersist }
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }

    oro_calendar.entity_listener.calendar_event:
        class: Oro\Bundle\CalendarBundle\EventListener\CalendarEventEntityListener
        tags:
            - { name: doctrine.orm.entity_listener, entity_manager: default, entity: Oro\Bundle\CalendarBundle\Entity\CalendarEvent, event: prePersist}
            - { name: doctrine.orm.entity_listener, entity_manager: default, entity: Oro\Bundle\CalendarBundle\Entity\CalendarEvent, event: preUpdate}

    oro_calendar.listener.calendar_event_attendees:
        class: Oro\Bundle\CalendarBundle\EventListener\CalendarEventAttendeesListener
        tags:
            - { name: doctrine.event_listener, event: onFlush }

    oro_calendar.listener.datagrid.activity:
        class: Oro\Bundle\CalendarBundle\EventListener\Datagrid\ActivityGridListener
        arguments:
            - '@oro_activity.manager'
            - '@oro_entity.routing_helper'
            - '@oro_locale.settings'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.activity-calendar-event-grid, method: onBuildAfter }

    oro_calendar.datagrid.action_permission_provider:
        class: Oro\Bundle\CalendarBundle\Datagrid\ActionPermissionProvider
        public: true
        arguments:
            - '@oro_security.token_accessor'

    oro_calendar.calendar_event.manager.api:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CalendarBundle\Entity\CalendarEvent'
            - '@doctrine.orm.entity_manager'

    oro_calendar.calendar_property.manager.api:
        class: Oro\Bundle\CalendarBundle\Manager\CalendarPropertyApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CalendarBundle\Entity\CalendarProperty'
            - '@doctrine.orm.entity_manager'
            - '@oro_calendar.calendar_manager'

    oro_calendar.system_calendar.manager.api:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CalendarBundle\Entity\SystemCalendar'
            - '@doctrine.orm.entity_manager'

    oro_calendar.twig.dateformat:
        class: Oro\Bundle\CalendarBundle\Twig\DateFormatExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_calendar.twig.recurrence:
        class: Oro\Bundle\CalendarBundle\Twig\RecurrenceExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_calendar.provider.calendar_config:
        class: 'Oro\Bundle\CalendarBundle\Provider\CalendarDateTimeConfigProvider'
        arguments:
            - '@oro_locale.settings'

    Oro\Bundle\CalendarBundle\Provider\CalendarDateTimeConfigProvider:
        alias: 'oro_calendar.provider.calendar_config'

    oro_calendar.provider.attendee_email_recipients:
        class: Oro\Bundle\CalendarBundle\Provider\AttendeeEmailRecipientsProvider
        arguments:
            - '@doctrine'
            - '@oro_email.provider.email_recipients.helper'
        tags:
            - { name: oro_email.recipients_provider, priority: 50 }

    oro_calendar.owner_assignment_checker.calendar:
        class: Oro\Bundle\CalendarBundle\Ownership\CalendarOwnerAssignmentChecker
        tags:
            - { name: oro_organization.owner_assignment_checker, entity: Oro\Bundle\CalendarBundle\Entity\Calendar }

    oro_calendar.widget_provider.actions.assign_calendar_event:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - oro_assign_calendar_event_button
            - oro_assign_calendar_event_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }
            - { name: oro_ui.update_action_provider, group: activity }

    oro_calendar.calendar_event_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEventManager'
        arguments:
            - '@oro_calendar.calendar_event.update_manager'
            - '@doctrine'
            - '@oro_security.token_accessor'
            - '@oro_entity.entity_name_resolver'
            - '@oro_calendar.system_calendar_config'

    Oro\Bundle\CalendarBundle\Manager\CalendarEventManager:
        alias: 'oro_calendar.calendar_event_manager'

    oro_calendar.calendar_event.update_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEvent\UpdateManager'
        public: false
        arguments:
            - '@oro_calendar.calendar_event.update_attendee_manager'
            - '@oro_calendar.calendar_event.update_child_manager'
            - '@oro_calendar.calendar_event.update_exception_manager'
            - '@oro_calendar.calendar_event.matching_events_manager'

    oro_calendar.calendar_event.update_attendee_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEvent\UpdateAttendeeManager'
        public: false
        arguments:
            - '@oro_calendar.attendee_relation_manager'
            - '@doctrine'

    oro_calendar.calendar_event.update_child_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEvent\UpdateChildManager'
        public: false
        arguments:
            - '@doctrine'

    oro_calendar.calendar_event.update_exception_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEvent\UpdateExceptionManager'
        public: false
        arguments:
            - '@oro_calendar.attendee_manager'
            - '@oro_calendar.calendar_event.delete_manager'

    oro_calendar.calendar_event.delete_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEvent\DeleteManager'
        public: false
        arguments:
            - '@doctrine'

    oro_calendar.calendar_event.notification_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\CalendarEvent\NotificationManager'
        public: true
        arguments:
            - '@oro_calendar.email.notification_sender'

    Oro\Bundle\CalendarBundle\Manager\CalendarEvent\NotificationManager:
        alias: 'oro_calendar.calendar_event.notification_manager'

    oro_calendar.calendar_event.matching_events_manager:
        class: Oro\Bundle\CalendarBundle\Manager\CalendarEvent\MatchingEventsManager
        public: false
        arguments:
            - '@oro_entity.doctrine_helper'

    oro_calendar.calendar_manager:
        class: Oro\Bundle\CalendarBundle\Manager\CalendarManager
        public: true
        arguments:
            - [] # provider aliases
            - ~ # service locator
            - '@oro_calendar.calendar_property_provider'

    oro_calendar.attendee_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\AttendeeManager'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_calendar.attendee_relation_manager'

    Oro\Bundle\CalendarBundle\Manager\AttendeeManager:
        alias: 'oro_calendar.attendee_manager'

    oro_calendar.attendee_relation_manager:
        class: 'Oro\Bundle\CalendarBundle\Manager\AttendeeRelationManager'
        arguments:
            - '@doctrine'
            - '@oro_locale.formatter.name'
            - '@oro_locale.dql.formatter.name'

    Oro\Bundle\CalendarBundle\Manager\AttendeeRelationManager:
        alias: 'oro_calendar.attendee_relation_manager'

    oro_calendar.calendar_property_provider:
        class: Oro\Bundle\CalendarBundle\Provider\CalendarPropertyProvider
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_entity_config.config_manager'
            - '@oro_entity_extend.extend.field_type_helper'

    oro_calendar.calendar_provider.user:
        class: Oro\Bundle\CalendarBundle\Provider\UserCalendarProvider
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_calendar.model.recurrence'
            - '@oro_entity.entity_name_resolver'
            - '@oro_calendar.calendar_event_normalizer.user'
        public: false
        tags:
            - { name: oro_calendar.calendar_provider, alias: user }

    oro_calendar.calendar_provider.system:
        class: Oro\Bundle\CalendarBundle\Provider\SystemCalendarProvider
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_calendar.model.recurrence'
            - '@oro_calendar.calendar_event_normalizer.system'
            - '@oro_calendar.system_calendar_config'
            - '@security.authorization_checker'
        public: false
        tags:
            - { name: oro_calendar.calendar_provider, alias: system }

    oro_calendar.calendar_provider.public:
        class: Oro\Bundle\CalendarBundle\Provider\PublicCalendarProvider
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_calendar.model.recurrence'
            - '@oro_calendar.calendar_event_normalizer.public'
            - '@oro_calendar.system_calendar_config'
            - '@security.authorization_checker'
        public: false
        tags:
            - { name: oro_calendar.calendar_provider, alias: public }

    oro_calendar.calendar_event_normalizer.abstract:
        class: 'Oro\Bundle\CalendarBundle\Provider\AbstractCalendarEventNormalizer'
        abstract: true
        arguments:
            - '@oro_calendar.calendar_event_manager'
            - '@oro_calendar.attendee_manager'
            - '@oro_reminder.entity.manager'
            - '@security.authorization_checker'
            - '@oro_ui.html_tag_helper'

    oro_calendar.calendar_event_normalizer.user:
        class: Oro\Bundle\CalendarBundle\Provider\UserCalendarEventNormalizer
        public: true
        parent: oro_calendar.calendar_event_normalizer.abstract
        calls:
            - [ setTokenAccessor, ['@oro_security.token_accessor'] ]

    oro_calendar.calendar_event_normalizer.system:
        class: Oro\Bundle\CalendarBundle\Provider\SystemCalendarEventNormalizer
        parent: oro_calendar.calendar_event_normalizer.abstract

    oro_calendar.calendar_event_normalizer.public:
        class: Oro\Bundle\CalendarBundle\Provider\PublicCalendarEventNormalizer
        parent: oro_calendar.calendar_event_normalizer.abstract

    oro_calendar.autocomplete.user_calendar_handler:
        class: Oro\Bundle\CalendarBundle\Autocomplete\UserCalendarHandler
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_attachment.manager'
            - 'Oro\Bundle\UserBundle\Entity\User'
            - '@security.authorization_checker'
            - '@oro_security.token_accessor'
            - '@oro_security.ownership_tree_provider'
            - '@oro_entity.routing_helper'
            - '@oro_security.acl_helper'
            - '@?security.acl.voter.basic_permissions'
        calls:
            - [ setProperties, [["namePrefix", "firstName", "middleName", "lastName", "nameSuffix"]] ]
            - [ setEntityNameResolver, ['@oro_entity.entity_name_resolver'] ]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: user_calendars, acl_resource: oro_user_user_view }
        lazy: true

    oro_calendar.activity_list.provider:
        class: Oro\Bundle\CalendarBundle\Provider\CalendarEventActivityListProvider
        arguments:
           - '@oro_entity.doctrine_helper'
           - '@oro_activity.association_helper'
           - '@oro_comment.association_helper'
        tags:
           - { name: oro_activity_list.provider, class: Oro\Bundle\CalendarBundle\Entity\CalendarEvent, priority: 50 }

    oro_calendar.email.notification_sender:
        class: 'Oro\Bundle\CalendarBundle\Model\Email\EmailNotificationSender'
        public: false
        arguments:
            - '@oro_notification.manager.email_notification'
            - '@doctrine'

    oro_calendar.listener.datagrid.system_calendar:
        class: Oro\Bundle\CalendarBundle\EventListener\Datagrid\SystemCalendarGridListener
        public: true
        arguments:
            - '@security.authorization_checker'
            - '@oro_security.token_accessor'
            - '@oro_calendar.system_calendar_config'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.system-calendar-grid, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.system-calendar-grid, method: onBuildAfter }

    oro_calendar.datagrid.helper.calendar_event_grid:
        class: Oro\Bundle\CalendarBundle\Datagrid\CalendarEventGridHelper
        public: true
        arguments:
            - '@router'

    oro_calendar.system_calendar_config:
        class: Oro\Bundle\CalendarBundle\Provider\SystemCalendarConfig
        public: true
        arguments:
            - '%oro_calendar.enabled_system_calendar%'

    oro_calendar.event_listener.navigation:
        class: Oro\Bundle\CalendarBundle\EventListener\NavigationListener
        arguments:
            - '@oro_calendar.system_calendar_config'
        tags:
            - { name: kernel.event_listener, event: oro_menu.configure.application_menu, method: onNavigationConfigure }
        calls:
            - [setAuthorizationChecker, ['@security.authorization_checker']]
            - [setTokenAccessor, ['@oro_security.token_accessor']]

    oro_calendar.delete_handler_extension.system_calendar:
        class: Oro\Bundle\CalendarBundle\Handler\SystemCalendarDeleteHandlerExtension
        parent: oro_entity.delete_handler_extension
        arguments:
            - '@oro_calendar.system_calendar_config'
            - '@security.authorization_checker'
            - '@oro_security.token_accessor'
        tags:
            - { name: oro_entity.delete_handler_extension, entity: Oro\Bundle\CalendarBundle\Entity\SystemCalendar }

    oro_calendar.delete_handler.calendar_event:
        class: Oro\Bundle\CalendarBundle\Handler\CalendarEventDeleteHandler
        parent: oro_entity.delete_handler
        arguments:
            - '@oro_calendar.calendar_event.delete_manager'
        tags:
            - { name: oro_entity.delete_handler, entity: Oro\Bundle\CalendarBundle\Entity\CalendarEvent }

    oro_calendar.delete_handler_extension.calendar_event:
        class: Oro\Bundle\CalendarBundle\Handler\CalendarEventDeleteHandlerExtension
        parent: oro_entity.delete_handler_extension
        arguments:
            - '@oro_calendar.system_calendar_config'
            - '@security.authorization_checker'
            - '@oro_calendar.calendar_event.notification_manager'
        tags:
            - { name: oro_entity.delete_handler_extension, entity: Oro\Bundle\CalendarBundle\Entity\CalendarEvent }

    oro_calendar.system_calendar_event.datagrid_helper:
        class: Oro\Bundle\CalendarBundle\Datagrid\SystemCalendarEventGridHelper
        public: true
        arguments:
            - '@security.authorization_checker'

    oro_calendar.workflow.action.create_calendar_event:
        class: Oro\Bundle\CalendarBundle\Workflow\Action\CreateCalendarEventAction
        arguments:
            - '@oro_action.expression.context_accessor'
            - '@doctrine'
        tags:
            - { name: oro_action.action, alias: create_calendar_event }

    oro_calendar.autocomplete.attendee_search_handler:
        class: Oro\Bundle\CalendarBundle\Autocomplete\AttendeeSearchHandler
        parent: oro_activity.form.handler.autocomplete
        calls:
            - [setAttendeeManager, ['@oro_calendar.attendee_manager']]

    Oro\Bundle\CalendarBundle\Autocomplete\AttendeeSearchHandler:
        alias: 'oro_calendar.autocomplete.attendee_search_handler'

    oro_calendar.recurrence.strategy.abstract:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\AbstractStrategy
        abstract: true
        public: false
        arguments:
            - '@translator'
            - '@oro_locale.formatter.date_time'
            - '@oro_locale.settings'

    oro_calendar.recurrence.strategy:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\DelegateStrategy
        arguments:
            - !tagged_iterator oro_calendar.recurrence.strategy

    oro_calendar.recurrence.strategy.daily:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\DailyStrategy
        public: false
        parent: oro_calendar.recurrence.strategy.abstract
        tags:
            - { name: oro_calendar.recurrence.strategy}

    oro_calendar.recurrence.strategy.weekly:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\WeeklyStrategy
        public: false
        parent: oro_calendar.recurrence.strategy.abstract
        tags:
            - { name: oro_calendar.recurrence.strategy}

    oro_calendar.recurrence.strategy.monthly:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\MonthlyStrategy
        public: false
        parent: oro_calendar.recurrence.strategy.abstract
        tags:
            - { name: oro_calendar.recurrence.strategy}

    oro_calendar.recurrence.strategy.yearly:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\YearlyStrategy
        public: false
        parent: oro_calendar.recurrence.strategy.abstract
        tags:
            - { name: oro_calendar.recurrence.strategy}

    oro_calendar.recurrence.strategy.monthnth:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\MonthNthStrategy
        public: false
        parent: oro_calendar.recurrence.strategy.abstract
        tags:
            - { name: oro_calendar.recurrence.strategy}

    oro_calendar.recurrence.strategy.yearnth:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence\YearNthStrategy
        public: false
        parent: oro_calendar.recurrence.strategy.abstract
        tags:
            - { name: oro_calendar.recurrence.strategy}

    oro_calendar.model.recurrence:
        class: Oro\Bundle\CalendarBundle\Model\Recurrence
        arguments:
            - '@oro_calendar.recurrence.strategy'

    oro_calendar.validator.recurrence:
        class: Oro\Bundle\CalendarBundle\Validator\RecurrenceValidator
        arguments:
            - '@oro_calendar.model.recurrence'
        tags:
            - { name: validator.constraint_validator, alias: oro_calendar.recurrence_validator }

    oro_calendar.validator.recurring_calendar_event_exception:
        class: Oro\Bundle\CalendarBundle\Validator\RecurringCalendarEventExceptionValidator
        arguments:
            - '@oro_calendar.calendar_event_manager'
        tags:
            - { name: validator.constraint_validator, alias: oro_calendar.recurring_calendar_event_exception_validator }

    oro_calendar.validator.unique_uid:
        class: Oro\Bundle\CalendarBundle\Validator\Constraints\UniqueUidValidator
        arguments:
            - '@doctrine'
        tags:
            - { name: validator.constraint_validator}

    oro_calendar.validator.event_attendees:
        class: Oro\Bundle\CalendarBundle\Validator\Constraints\EventAttendeesValidator
        arguments:
            - '@doctrine'
        tags:
            - { name: validator.constraint_validator }

    oro_calendar.datagrid.mass_action.handler.delete:
        class: Oro\Bundle\CalendarBundle\Datagrid\MassAction\DeleteMassActionHandler
        public: true
        parent: oro_datagrid.extension.mass_action.handler.delete
        calls:
            - [setDeleteManager, ['@oro_calendar.calendar_event.delete_manager']]

    oro_calendar.provider.calendar_entity_name:
        class: Oro\Bundle\CalendarBundle\Provider\CalendarEntityNameProvider
        public: false
        arguments:
            - '@translator'
        tags:
            - { name: oro_entity.name_provider, priority: 100}

    oro_calendar.provider.calendar_event_entity_name:
        class: Oro\Bundle\CalendarBundle\Provider\CalendarEventEntityNameProvider
        public: false
        tags:
            - { name: oro_entity.name_provider, priority: 100}

    oro_calendar.resolver.event_organizer:
        class: Oro\Bundle\CalendarBundle\Resolver\EventOrganizerResolver
        arguments:
            - '@doctrine'

    oro_calendar.provider.attendee_preferred_localization_provider:
        class: 'Oro\Bundle\CalendarBundle\Provider\AttendeePreferredLocalizationProvider'
        public: false
        arguments:
            - '@oro_locale.provider.preferred_localization_provider'
        tags:
            - { name: oro_locale.preferred_localization_provider }
