public function __construct(IAppContainer $container, App $app) { $this->api = $container->query('API'); $this->request = $container->query('Request'); $this->server = $container->getServer(); $this->app = $app; }
public function __construct($params) { $this->appName = 'contacts'; parent::__construct($this->appName, $params); $this->container = $this->getContainer(); $this->server = $this->container->getServer(); $this->app = new App($this->container->query('API')->getUserId()); $this->registerServices(); $this->container->registerMiddleware('HttpMiddleware'); }
/** * Deletes all news entries of a given user * @param string $user */ protected function clearUserNewsDatabase($user) { $sql = ['DELETE FROM `*PREFIX*news_items` WHERE `feed_id` IN (SELECT `id` FROM `*PREFIX*news_feeds` WHERE `user_id` = ?)', 'DELETE FROM `*PREFIX*news_feeds` WHERE `user_id` = ?', 'DELETE FROM `*PREFIX*news_folders` WHERE `user_id` = ?']; $db = $this->container->query(IDb::class); foreach ($sql as $query) { $db->prepareQuery($query)->execute([$user]); } }
/** * Instantiates the environment * * @return Environment */ private function instantiateEnvironment() { $this->container->registerService('UserId', function ($c) { return $this->userId; }); $this->container->registerService('userFolder', function ($c) { return $this->userFolder; }); return $this->container->query('OCA\\GalleryPlus\\Environment\\Environment'); }
private function registerUsageChartsApi() { $this->container->registerService('ContentStatisticsClientApiConnection', function ($c) { return new ApiConnection(new \GuzzleHttp\Client(), $c->query('ServerContainer')->getConfig()->getAppValue($c->query('AppName'), 'url'), $c->query('ServerContainer')->getConfig()->getAppValue($c->query('AppName'), 'username'), $c->query('ServerContainer')->getConfig()->getAppValue($c->query('AppName'), 'password')); }); $this->container->registerService('ContentStatisticsClient', function ($c) { return new ContentStatisticsClient(new ActivityStream($c->query('ContentStatisticsClientApiConnection')), new StorageStream($c->query('ContentStatisticsClientApiConnection'))); }); $useApi = $this->container->query('ServerContainer')->getConfig()->getAppValue($this->container->query('AppName'), 'useapi'); $this->container->registerService('FileHooks', function ($c) use(&$useApi) { return new FileHooks($c->query('ContentStatisticsClient'), $useApi); }); $this->container->registerService('ContentStatisticsUpdater', function ($c) { return new ContentStatisticsUpdater($c->query('ContentStatisticsClient'), $c->query('DataProviderFactory'), $c->query('OwncloudUsers')); }); }
/** * @dataProvider queryData * @param string $service * @param string $expected */ public function testContainerQuery($service, $expected) { $this->assertTrue($this->container->query($service) instanceof $expected); }
/** * Registers the consumer to the Activity Manager * * @param IManager $am * @param IAppContainer $container */ public static function register(IManager $am, IAppContainer $container) { $am->registerConsumer(function () use($am, $container) { return $container->query('Consumer'); }); }
/** * @param IAppContainer $c */ public function registerBackends(IAppContainer $c) { $l10n = $c->getServer()->getL10N($c->getAppName()); // Local backend: Default database backend $this->backends->queue(function () use($c, $l10n) { return $this->backendFactory->createBackend('org.ownCloud.local', $this->backends, function () use($l10n) { return new Calendar\Backend\Local\Backend($l10n); }, function (Calendar\IBackend $backend) use($c) { $db = $c->getServer()->getDatabaseConnection(); $factory = $c->query('CalendarFactory'); return new Calendar\Backend\Local\Calendar($db, $backend, $factory); }, function (Calendar\ICalendar $calendar) use($c) { $db = $c->getServer()->getDatabaseConnection(); $factory = $c->query('ObjectFactory'); return new Calendar\Backend\Local\Object($db, $calendar, $factory); }); }); // Contacts backend: show contact's birthdays and anniversaries $contactsManager = $c->getServer()->getContactsManager(); $this->backends->queue(function () use($c, $l10n, $contactsManager) { return $this->backendFactory->createBackend('org.ownCloud.contact', $this->backends, function () use($c, $contactsManager) { $appManager = $c->getServer()->getAppManager(); return new Calendar\Backend\Contact\Backend($contactsManager, $appManager); }, function (Calendar\IBackend $backend) use($c, $contactsManager) { $l10n = $c->getServer()->getL10N('calendar'); $calendarFactory = $c->query('CalendarFactory'); return new Calendar\Backend\Contact\Calendar($contactsManager, $backend, $l10n, $calendarFactory); }, function (Calendar\ICalendar $calendar) use($c, $contactsManager) { $l10n = $c->getServer()->getL10N('calendar'); $objectFactory = $c->query('ObjectFactory'); return new Calendar\Backend\Contact\Object($contactsManager, $calendar, $l10n, $objectFactory); }); }); // Sharing backend: Enabling users to share calendars if (Share::isEnabled() && false) { $this->backends->queue(function () use($c, $l10n) { return $this->backendFactory->createBackend('org.ownCloud.sharing', $this->backends, function () { return new Calendar\Backend\Sharing\Backend(); }, function (Calendar\IBackend $backend) { return new Calendar\Backend\Sharing\Calendar($backend); }, function (Calendar\ICalendar $calendar) { return new Calendar\Backend\Sharing\Object($calendar); }); }); } // Webcal Backend: Show ICS files on the net if (function_exists('curl_init')) { $this->backends->queue(function () use($c, $l10n) { return $this->backendFactory->createBackend('org.ownCloud.webcal', $this->backends, function () use($c, $l10n) { $subscriptions = $c->query('SubscriptionBusinessLayer'); $cacheFactory = $c->getServer()->getMemCacheFactory(); return new Calendar\Backend\WebCal\Backend($subscriptions, $l10n, $cacheFactory); }, function (Calendar\IBackend $backend) use($c, $l10n) { $subscriptions = $c->query('SubscriptionBusinessLayer'); $cacheFactory = $c->getServer()->getMemCacheFactory(); $calendarFactory = $c->query('CalendarFactory'); return new Calendar\Backend\WebCal\Calendar($subscriptions, $l10n, $cacheFactory, $backend, $calendarFactory); }, function (Calendar\ICalendar $calendar) use($c, $l10n) { $subscriptions = $c->query('SubscriptionBusinessLayer'); $cacheFactory = $c->getServer()->getMemCacheFactory(); $objectFactory = $c->query('ObjectFactory'); return new Calendar\Backend\WebCal\Object($subscriptions, $l10n, $cacheFactory, $calendar, $objectFactory); }); }); } }