summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-25 18:21:30 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-30 15:23:10 +0200
commite365ea7ec55ca50cf133cc6bf64adb475a6303bf (patch)
tree10062018160d01a03d984b99dd1a9d770e84c988 /apps/files/lib
parentdd535968e822c21084ecb4f118b3dc4f572bf330 (diff)
downloadnextcloud-server-e365ea7ec55ca50cf133cc6bf64adb475a6303bf.tar.gz
nextcloud-server-e365ea7ec55ca50cf133cc6bf64adb475a6303bf.zip
Use DI for the objects where possible
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/activity.php29
1 files changed, 23 insertions, 6 deletions
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);
}
}