diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-25 18:21:30 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-30 15:23:10 +0200 |
commit | e365ea7ec55ca50cf133cc6bf64adb475a6303bf (patch) | |
tree | 10062018160d01a03d984b99dd1a9d770e84c988 /apps | |
parent | dd535968e822c21084ecb4f118b3dc4f572bf330 (diff) | |
download | nextcloud-server-e365ea7ec55ca50cf133cc6bf64adb475a6303bf.tar.gz nextcloud-server-e365ea7ec55ca50cf133cc6bf64adb475a6303bf.zip |
Use DI for the objects where possible
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/appinfo/app.php | 5 | ||||
-rw-r--r-- | apps/files/lib/activity.php | 29 |
2 files changed, 27 insertions, 7 deletions
diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index e4cac7c7c14..578c1a52e80 100644 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -59,6 +59,9 @@ $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadshe \OC::$server->getActivityManager()->registerExtension(function() { return new \OCA\Files\Activity( \OC::$server->query('L10NFactory'), - \OC::$server->getURLGenerator() + \OC::$server->getURLGenerator(), + \OC::$server->getActivityManager(), + \OC::$server->getTagManager(), + \OC::$server->getConfig() ); }); diff --git a/apps/files/lib/activity.php b/apps/files/lib/activity.php index c613a074722..559342d9796 100644 --- a/apps/files/lib/activity.php +++ b/apps/files/lib/activity.php @@ -24,7 +24,10 @@ namespace OCA\Files; use OC\L10N\Factory; use OCP\Activity\IExtension; +use OCP\Activity\IManager; +use OCP\IConfig; use OCP\IL10N; +use OCP\ITagManager; use OCP\IURLGenerator; class Activity implements IExtension { @@ -46,14 +49,29 @@ class Activity implements IExtension { /** @var IURLGenerator */ protected $URLGenerator; + /** @var \OCP\Activity\IManager */ + protected $activityManager; + + /** @var \OCP\IConfig */ + protected $config; + + /** @var \OCP\ITagManager */ + protected $tagManager; + /** * @param Factory $languageFactory * @param IURLGenerator $URLGenerator + * @param IManager $activityManager + * @param ITagManager $tagManager + * @param IConfig $config */ - public function __construct(Factory $languageFactory, IURLGenerator $URLGenerator) { + public function __construct(Factory $languageFactory, IURLGenerator $URLGenerator, IManager $activityManager, ITagManager $tagManager, IConfig $config) { $this->languageFactory = $languageFactory; $this->URLGenerator = $URLGenerator; $this->l = $this->getL10N(); + $this->activityManager = $activityManager; + $this->tagManager = $tagManager; + $this->config = $config; } /** @@ -288,7 +306,7 @@ class Activity implements IExtension { * @return array|false */ public function getQueryForFilter($filter) { - $user = \OC::$server->getActivityManager()->getCurrentUserId(); + $user = $this->activityManager->getCurrentUserId(); // Display actions from all files if ($filter === self::FILTER_FILES) { return ['`app` = ?', ['files']]; @@ -301,9 +319,7 @@ class Activity implements IExtension { // Display actions from favorites only if ($filter === self::FILTER_FAVORITES || $filter === 'all' && $this->userSettingFavoritesOnly($user)) { - $tagManager = \OC::$server->getTagManager(); - - $tags = $tagManager->load('files', [], false, $user); + $tags = $this->tagManager->load('files', [], false, $user); $favorites = $tags->getFavorites(); if (isset($favorites[50])) { @@ -311,6 +327,7 @@ class Activity implements IExtension { return ['`app` = ?', ['files']]; } + // Can not DI because the user is not known on instantiation $rootFolder = \OC::$server->getUserFolder($user); $parameters = $fileQueryList = []; foreach ($favorites as $favorite) { @@ -350,6 +367,6 @@ class Activity implements IExtension { * @return bool */ protected function userSettingFavoritesOnly($user) { - return (bool) \OC::$server->getConfig()->getUserValue($user, 'activity', 'notify_stream_' . self::TYPE_FAVORITES, false); + return (bool) $this->config->getUserValue($user, 'activity', 'notify_stream_' . self::TYPE_FAVORITES, false); } } |