summaryrefslogtreecommitdiffstats
path: root/apps/dav/appinfo/application.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/appinfo/application.php')
-rw-r--r--apps/dav/appinfo/application.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/dav/appinfo/application.php b/apps/dav/appinfo/application.php
new file mode 100644
index 00000000000..f97d43f188e
--- /dev/null
+++ b/apps/dav/appinfo/application.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace OCA\Dav\AppInfo;
+
+use OCA\DAV\CardDAV\ContactsManager;
+use \OCP\AppFramework\App;
+use OCP\AppFramework\IAppContainer;
+use OCP\Contacts\IManager;
+
+class Application extends App {
+
+ /**
+ * Application constructor.
+ *
+ * @param array $urlParams
+ */
+ public function __construct (array $urlParams=array()) {
+ parent::__construct('dav', $urlParams);
+
+ $container = $this->getContainer();
+ $container->registerService('ContactsManager', function($c) {
+ /** @var IAppContainer $c */
+ return new ContactsManager(
+ $c->query('CardDavBackend')
+ );
+ });
+
+ $container->registerService('CardDavBackend', function($c) {
+ /** @var IAppContainer $c */
+ $db = $c->getServer()->getDatabaseConnection();
+ $logger = $c->getServer()->getLogger();
+ $principal = new \OCA\DAV\Connector\Sabre\Principal(
+ $c->getServer()->getUserManager()
+ );
+ return new \OCA\DAV\CardDAV\CardDavBackend($db, $principal, $logger);
+ });
+
+ }
+
+ /**
+ * @param IManager $contactsManager
+ * @param string $userID
+ */
+ public function setupContactsProvider(IManager $contactsManager, $userID) {
+ /** @var ContactsManager $cm */
+ $cm = $this->getContainer()->query('ContactsManager');
+ $cm->setupContactsProvider($contactsManager, $userID);
+ }
+
+}