diff options
author | Joas Schilling <coding@schilljs.com> | 2016-10-13 15:34:26 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-11-03 12:07:59 +0100 |
commit | 52dd27892b80ab91d0776c45d05d8447ac24b76e (patch) | |
tree | 56457a3d0eb6119bbe200413557bcb6d76a7329a /apps/dav/lib/AppInfo/Application.php | |
parent | d3e8463de28197de2d4d61c35906b020ec85b432 (diff) | |
download | nextcloud-server-52dd27892b80ab91d0776c45d05d8447ac24b76e.tar.gz nextcloud-server-52dd27892b80ab91d0776c45d05d8447ac24b76e.zip |
Use the event dispatcher
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/lib/AppInfo/Application.php')
-rw-r--r-- | apps/dav/lib/AppInfo/Application.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 32483e8fd8e..c777f5e5a35 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -24,6 +24,7 @@ */ namespace OCA\DAV\AppInfo; +use OCA\DAV\CalDAV\Activity\Backend; use OCA\DAV\CalDAV\Activity\Extension; use OCA\DAV\CalDAV\BirthdayService; use OCA\DAV\Capabilities; @@ -90,6 +91,62 @@ class Application extends App { } }); + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) { + /** @var Backend $backend */ + $backend = $this->getContainer()->query(Backend::class); + $backend->onCalendarAdd( + $event->getArgument('calendarData') + ); + }); + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', function(GenericEvent $event) { + /** @var Backend $backend */ + $backend = $this->getContainer()->query(Backend::class); + $backend->onCalendarUpdate( + $event->getArgument('calendarData'), + $event->getArgument('shares'), + $event->getArgument('propertyMutations') + ); + }); + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function(GenericEvent $event) { + /** @var Backend $backend */ + $backend = $this->getContainer()->query(Backend::class); + $backend->onCalendarDelete( + $event->getArgument('calendarData'), + $event->getArgument('shares') + ); + }); + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) { + /** @var Backend $backend */ + $backend = $this->getContainer()->query(Backend::class); + $backend->onCalendarUpdateShares( + $event->getArgument('calendarData'), + $event->getArgument('shares'), + $event->getArgument('add'), + $event->getArgument('remove') + ); + }); + + $listener = function(GenericEvent $event, $eventName) { + /** @var Backend $backend */ + $backend = $this->getContainer()->query(Backend::class); + + $subject = Extension::SUBJECT_OBJECT_ADD; + if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') { + $subject = Extension::SUBJECT_OBJECT_UPDATE; + } else if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') { + $subject = Extension::SUBJECT_OBJECT_DELETE; + } + $backend->onTouchCalendarObject( + $subject, + $event->getArgument('calendarData'), + $event->getArgument('shares'), + $event->getArgument('objectData') + ); + }; + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener); + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener); + $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener); + $aM = $this->getContainer()->getServer()->getActivityManager(); $aM->registerExtension(function() { return $this->getContainer()->query(Extension::class); |