diff options
Diffstat (limited to 'lib/AppInfo/Application.php')
-rw-r--r-- | lib/AppInfo/Application.php | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 565fe5b7..a2f3a396 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -22,16 +22,36 @@ */ namespace OCA\Contacts\AppInfo; +use OCA\Contacts\Dav\PatchPlugin; use OCP\AppFramework\App; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\SabrePluginEvent; class Application extends App { public const APP_ID = 'contacts'; - - public function __construct() { - parent::__construct(self::APP_ID); - } public const AVAIL_SETTINGS = [ 'allowSocialSync' => 'yes', ]; + + public function __construct() { + parent::__construct(self::APP_ID); + } + + public function register() { + $server = $this->getContainer()->getServer(); + + /** @var IEventDispatcher $eventDispatcher */ + $eventDispatcher = $server->query(IEventDispatcher::class); + $eventDispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) { + $server = $event->getServer(); + + if ($server !== null) { + // We have to register the LockPlugin here and not info.xml, + // because info.xml plugins are loaded, after the + // beforeMethod:* hook has already been emitted. + $server->addPlugin($this->getContainer()->query(PatchPlugin::class)); + } + }); + } } |