@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
27 | 27 | if ($useStaticLoader) { |
28 | - require_once __DIR__ . '/autoload_static.php'; |
|
28 | + require_once __DIR__.'/autoload_static.php'; |
|
29 | 29 | |
30 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInitProvisioning_API::getInitializer($loader)); |
31 | 31 | } else { |
32 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
32 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
33 | 33 | if ($classMap) { |
34 | 34 | $loader->addClassMap($classMap); |
35 | 35 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
27 | 27 | if ($useStaticLoader) { |
28 | - require_once __DIR__ . '/autoload_static.php'; |
|
28 | + require_once __DIR__.'/autoload_static.php'; |
|
29 | 29 | |
30 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInitOAuth2::getInitializer($loader)); |
31 | 31 | } else { |
32 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
32 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
33 | 33 | if ($classMap) { |
34 | 34 | $loader->addClassMap($classMap); |
35 | 35 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
27 | 27 | if ($useStaticLoader) { |
28 | - require_once __DIR__ . '/autoload_static.php'; |
|
28 | + require_once __DIR__.'/autoload_static.php'; |
|
29 | 29 | |
30 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInitAdminAudit::getInitializer($loader)); |
31 | 31 | } else { |
32 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
32 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
33 | 33 | if ($classMap) { |
34 | 34 | $loader->addClassMap($classMap); |
35 | 35 | } |
@@ -32,33 +32,33 @@ |
||
32 | 32 | |
33 | 33 | class UpdateTheme extends UpdateJS { |
34 | 34 | |
35 | - /** @var IMimeTypeDetector */ |
|
36 | - protected $mimetypeDetector; |
|
35 | + /** @var IMimeTypeDetector */ |
|
36 | + protected $mimetypeDetector; |
|
37 | 37 | |
38 | - /** @var ICacheFactory */ |
|
39 | - protected $cacheFactory; |
|
38 | + /** @var ICacheFactory */ |
|
39 | + protected $cacheFactory; |
|
40 | 40 | |
41 | - public function __construct( |
|
42 | - IMimeTypeDetector $mimetypeDetector, |
|
43 | - ICacheFactory $cacheFactory |
|
44 | - ) { |
|
45 | - parent::__construct($mimetypeDetector); |
|
46 | - $this->cacheFactory = $cacheFactory; |
|
47 | - } |
|
41 | + public function __construct( |
|
42 | + IMimeTypeDetector $mimetypeDetector, |
|
43 | + ICacheFactory $cacheFactory |
|
44 | + ) { |
|
45 | + parent::__construct($mimetypeDetector); |
|
46 | + $this->cacheFactory = $cacheFactory; |
|
47 | + } |
|
48 | 48 | |
49 | - protected function configure() { |
|
50 | - $this |
|
51 | - ->setName('maintenance:theme:update') |
|
52 | - ->setDescription('Apply custom theme changes'); |
|
53 | - } |
|
49 | + protected function configure() { |
|
50 | + $this |
|
51 | + ->setName('maintenance:theme:update') |
|
52 | + ->setDescription('Apply custom theme changes'); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | - // run mimetypelist.js update since themes might change mimetype icons |
|
57 | - parent::execute($input, $output); |
|
55 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | + // run mimetypelist.js update since themes might change mimetype icons |
|
57 | + parent::execute($input, $output); |
|
58 | 58 | |
59 | - // cleanup image cache |
|
60 | - $c = $this->cacheFactory->createDistributed('imagePath'); |
|
61 | - $c->clear(''); |
|
62 | - $output->writeln('<info>Image cache cleared'); |
|
63 | - } |
|
59 | + // cleanup image cache |
|
60 | + $c = $this->cacheFactory->createDistributed('imagePath'); |
|
61 | + $c->clear(''); |
|
62 | + $output->writeln('<info>Image cache cleared'); |
|
63 | + } |
|
64 | 64 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * @inheritdoc |
30 | 30 | */ |
31 | 31 | public function like($x, $y, $type = null) { |
32 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
32 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function iLike($x, $y, $type = null) { |
@@ -24,14 +24,14 @@ |
||
24 | 24 | namespace OC\DB\QueryBuilder\ExpressionBuilder; |
25 | 25 | |
26 | 26 | class SqliteExpressionBuilder extends ExpressionBuilder { |
27 | - /** |
|
28 | - * @inheritdoc |
|
29 | - */ |
|
30 | - public function like($x, $y, $type = null) { |
|
31 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
32 | - } |
|
27 | + /** |
|
28 | + * @inheritdoc |
|
29 | + */ |
|
30 | + public function like($x, $y, $type = null) { |
|
31 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
32 | + } |
|
33 | 33 | |
34 | - public function iLike($x, $y, $type = null) { |
|
35 | - return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); |
|
36 | - } |
|
34 | + public function iLike($x, $y, $type = null) { |
|
35 | + return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); |
|
36 | + } |
|
37 | 37 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this |
50 | 50 | ->setIdentifier($invalidId) |
51 | 51 | ->setStorageClass('\OC\Files\Storage\FailedStorage') |
52 | - ->setText('Unknown storage backend ' . $invalidId); |
|
52 | + ->setText('Unknown storage backend '.$invalidId); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
65 | - $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); |
|
65 | + $storage->setBackendOption('exception', new \Exception('Unknown storage backend "'.$this->invalidId.'"', StorageNotAvailableException::STATUS_ERROR)); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 |
@@ -34,33 +34,33 @@ |
||
34 | 34 | */ |
35 | 35 | class InvalidBackend extends Backend { |
36 | 36 | |
37 | - /** @var string Invalid backend id */ |
|
38 | - private $invalidId; |
|
37 | + /** @var string Invalid backend id */ |
|
38 | + private $invalidId; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Constructs a new InvalidBackend with the id of the invalid backend |
|
42 | - * for display purposes |
|
43 | - * |
|
44 | - * @param string $invalidId id of the backend that did not exist |
|
45 | - */ |
|
46 | - public function __construct($invalidId) { |
|
47 | - $this->invalidId = $invalidId; |
|
48 | - $this |
|
49 | - ->setIdentifier($invalidId) |
|
50 | - ->setStorageClass('\OC\Files\Storage\FailedStorage') |
|
51 | - ->setText('Unknown storage backend ' . $invalidId); |
|
52 | - } |
|
40 | + /** |
|
41 | + * Constructs a new InvalidBackend with the id of the invalid backend |
|
42 | + * for display purposes |
|
43 | + * |
|
44 | + * @param string $invalidId id of the backend that did not exist |
|
45 | + */ |
|
46 | + public function __construct($invalidId) { |
|
47 | + $this->invalidId = $invalidId; |
|
48 | + $this |
|
49 | + ->setIdentifier($invalidId) |
|
50 | + ->setStorageClass('\OC\Files\Storage\FailedStorage') |
|
51 | + ->setText('Unknown storage backend ' . $invalidId); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Returns the invalid backend id |
|
56 | - * |
|
57 | - * @return string invalid backend id |
|
58 | - */ |
|
59 | - public function getInvalidId() { |
|
60 | - return $this->invalidId; |
|
61 | - } |
|
54 | + /** |
|
55 | + * Returns the invalid backend id |
|
56 | + * |
|
57 | + * @return string invalid backend id |
|
58 | + */ |
|
59 | + public function getInvalidId() { |
|
60 | + return $this->invalidId; |
|
61 | + } |
|
62 | 62 | |
63 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | - $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); |
|
65 | - } |
|
63 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | + $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); |
|
65 | + } |
|
66 | 66 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
66 | 66 | |
67 | 67 | if ($username_as_share) { |
68 | - $share = '/' . $storage->getBackendOption('user'); |
|
68 | + $share = '/'.$storage->getBackendOption('user'); |
|
69 | 69 | $storage->setBackendOption('share', $share); |
70 | 70 | } |
71 | 71 | } |
@@ -37,35 +37,35 @@ |
||
37 | 37 | * Deprecated SMB_OC class - use SMB with the password::sessioncredentials auth mechanism |
38 | 38 | */ |
39 | 39 | class SMB_OC extends Backend { |
40 | - use LegacyDependencyCheckPolyfill; |
|
40 | + use LegacyDependencyCheckPolyfill; |
|
41 | 41 | |
42 | - public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { |
|
43 | - $this |
|
44 | - ->setIdentifier('\OC\Files\Storage\SMB_OC') |
|
45 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
46 | - ->setText($l->t('SMB / CIFS using OC login')) |
|
47 | - ->addParameters([ |
|
48 | - new DefinitionParameter('host', $l->t('Host')), |
|
49 | - (new DefinitionParameter('username_as_share', $l->t('Username as share'))) |
|
50 | - ->setType(DefinitionParameter::VALUE_BOOLEAN), |
|
51 | - (new DefinitionParameter('share', $l->t('Share'))) |
|
52 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
53 | - (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
54 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
55 | - ]) |
|
56 | - ->setPriority(BackendService::PRIORITY_DEFAULT - 10) |
|
57 | - ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
58 | - ->setLegacyAuthMechanism($legacyAuth) |
|
59 | - ->deprecateTo($smbBackend) |
|
60 | - ; |
|
61 | - } |
|
42 | + public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { |
|
43 | + $this |
|
44 | + ->setIdentifier('\OC\Files\Storage\SMB_OC') |
|
45 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
46 | + ->setText($l->t('SMB / CIFS using OC login')) |
|
47 | + ->addParameters([ |
|
48 | + new DefinitionParameter('host', $l->t('Host')), |
|
49 | + (new DefinitionParameter('username_as_share', $l->t('Username as share'))) |
|
50 | + ->setType(DefinitionParameter::VALUE_BOOLEAN), |
|
51 | + (new DefinitionParameter('share', $l->t('Share'))) |
|
52 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
53 | + (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
54 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
55 | + ]) |
|
56 | + ->setPriority(BackendService::PRIORITY_DEFAULT - 10) |
|
57 | + ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
58 | + ->setLegacyAuthMechanism($legacyAuth) |
|
59 | + ->deprecateTo($smbBackend) |
|
60 | + ; |
|
61 | + } |
|
62 | 62 | |
63 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | - $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
|
63 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | + $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
|
65 | 65 | |
66 | - if ($username_as_share) { |
|
67 | - $share = '/' . $storage->getBackendOption('user'); |
|
68 | - $storage->setBackendOption('share', $share); |
|
69 | - } |
|
70 | - } |
|
66 | + if ($username_as_share) { |
|
67 | + $share = '/' . $storage->getBackendOption('user'); |
|
68 | + $storage->setBackendOption('share', $share); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | private function getCredentialsIdentifier($storageId) { |
64 | - return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
64 | + return self::CREDENTIALS_IDENTIFIER_PREFIX.$storageId; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function saveBackendOptions(IUser $user, $id, array $options) { |
@@ -37,51 +37,51 @@ |
||
37 | 37 | * User provided Username and Password |
38 | 38 | */ |
39 | 39 | class UserProvided extends AuthMechanism implements IUserProvided { |
40 | - public const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; |
|
40 | + public const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; |
|
41 | 41 | |
42 | - /** @var ICredentialsManager */ |
|
43 | - protected $credentialsManager; |
|
42 | + /** @var ICredentialsManager */ |
|
43 | + protected $credentialsManager; |
|
44 | 44 | |
45 | - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
46 | - $this->credentialsManager = $credentialsManager; |
|
45 | + public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
46 | + $this->credentialsManager = $credentialsManager; |
|
47 | 47 | |
48 | - $this |
|
49 | - ->setIdentifier('password::userprovided') |
|
50 | - ->setVisibility(BackendService::VISIBILITY_ADMIN) |
|
51 | - ->setScheme(self::SCHEME_PASSWORD) |
|
52 | - ->setText($l->t('User entered, store in database')) |
|
53 | - ->addParameters([ |
|
54 | - (new DefinitionParameter('user', $l->t('Username'))) |
|
55 | - ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
56 | - (new DefinitionParameter('password', $l->t('Password'))) |
|
57 | - ->setType(DefinitionParameter::VALUE_PASSWORD) |
|
58 | - ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
59 | - ]); |
|
60 | - } |
|
48 | + $this |
|
49 | + ->setIdentifier('password::userprovided') |
|
50 | + ->setVisibility(BackendService::VISIBILITY_ADMIN) |
|
51 | + ->setScheme(self::SCHEME_PASSWORD) |
|
52 | + ->setText($l->t('User entered, store in database')) |
|
53 | + ->addParameters([ |
|
54 | + (new DefinitionParameter('user', $l->t('Username'))) |
|
55 | + ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
56 | + (new DefinitionParameter('password', $l->t('Password'))) |
|
57 | + ->setType(DefinitionParameter::VALUE_PASSWORD) |
|
58 | + ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
59 | + ]); |
|
60 | + } |
|
61 | 61 | |
62 | - private function getCredentialsIdentifier($storageId) { |
|
63 | - return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
64 | - } |
|
62 | + private function getCredentialsIdentifier($storageId) { |
|
63 | + return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
64 | + } |
|
65 | 65 | |
66 | - public function saveBackendOptions(IUser $user, $id, array $options) { |
|
67 | - $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ |
|
68 | - 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array |
|
69 | - 'password' => $options['password'] // this way we prevent users from being able to modify any other field |
|
70 | - ]); |
|
71 | - } |
|
66 | + public function saveBackendOptions(IUser $user, $id, array $options) { |
|
67 | + $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ |
|
68 | + 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array |
|
69 | + 'password' => $options['password'] // this way we prevent users from being able to modify any other field |
|
70 | + ]); |
|
71 | + } |
|
72 | 72 | |
73 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
74 | - if (!isset($user)) { |
|
75 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
76 | - } |
|
77 | - $uid = $user->getUID(); |
|
78 | - $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId())); |
|
73 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
74 | + if (!isset($user)) { |
|
75 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
76 | + } |
|
77 | + $uid = $user->getUID(); |
|
78 | + $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId())); |
|
79 | 79 | |
80 | - if (!isset($credentials)) { |
|
81 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
82 | - } |
|
80 | + if (!isset($credentials)) { |
|
81 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
82 | + } |
|
83 | 83 | |
84 | - $storage->setBackendOption('user', $credentials['user']); |
|
85 | - $storage->setBackendOption('password', $credentials['password']); |
|
86 | - } |
|
84 | + $storage->setBackendOption('user', $credentials['user']); |
|
85 | + $storage->setBackendOption('password', $credentials['password']); |
|
86 | + } |
|
87 | 87 | } |
@@ -122,7 +122,7 @@ |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite'; |
125 | - $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [ |
|
125 | + $this->dispatcher->dispatch(self::class.'::'.$eventName, new GenericEvent(null, [ |
|
126 | 126 | 'userId' => $user->getUID(), |
127 | 127 | 'fileId' => $fileId, |
128 | 128 | 'path' => $path, |
@@ -38,110 +38,110 @@ |
||
38 | 38 | */ |
39 | 39 | class TagService { |
40 | 40 | |
41 | - /** @var IUserSession */ |
|
42 | - private $userSession; |
|
43 | - /** @var IManager */ |
|
44 | - private $activityManager; |
|
45 | - /** @var ITags */ |
|
46 | - private $tagger; |
|
47 | - /** @var Folder */ |
|
48 | - private $homeFolder; |
|
49 | - /** @var EventDispatcherInterface */ |
|
50 | - private $dispatcher; |
|
41 | + /** @var IUserSession */ |
|
42 | + private $userSession; |
|
43 | + /** @var IManager */ |
|
44 | + private $activityManager; |
|
45 | + /** @var ITags */ |
|
46 | + private $tagger; |
|
47 | + /** @var Folder */ |
|
48 | + private $homeFolder; |
|
49 | + /** @var EventDispatcherInterface */ |
|
50 | + private $dispatcher; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param IUserSession $userSession |
|
54 | - * @param IManager $activityManager |
|
55 | - * @param ITags $tagger |
|
56 | - * @param Folder $homeFolder |
|
57 | - * @param EventDispatcherInterface $dispatcher |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - IUserSession $userSession, |
|
61 | - IManager $activityManager, |
|
62 | - ITags $tagger, |
|
63 | - Folder $homeFolder, |
|
64 | - EventDispatcherInterface $dispatcher |
|
65 | - ) { |
|
66 | - $this->userSession = $userSession; |
|
67 | - $this->activityManager = $activityManager; |
|
68 | - $this->tagger = $tagger; |
|
69 | - $this->homeFolder = $homeFolder; |
|
70 | - $this->dispatcher = $dispatcher; |
|
71 | - } |
|
52 | + /** |
|
53 | + * @param IUserSession $userSession |
|
54 | + * @param IManager $activityManager |
|
55 | + * @param ITags $tagger |
|
56 | + * @param Folder $homeFolder |
|
57 | + * @param EventDispatcherInterface $dispatcher |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + IUserSession $userSession, |
|
61 | + IManager $activityManager, |
|
62 | + ITags $tagger, |
|
63 | + Folder $homeFolder, |
|
64 | + EventDispatcherInterface $dispatcher |
|
65 | + ) { |
|
66 | + $this->userSession = $userSession; |
|
67 | + $this->activityManager = $activityManager; |
|
68 | + $this->tagger = $tagger; |
|
69 | + $this->homeFolder = $homeFolder; |
|
70 | + $this->dispatcher = $dispatcher; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Updates the tags of the specified file path. |
|
75 | - * The passed tags are absolute, which means they will |
|
76 | - * replace the actual tag selection. |
|
77 | - * |
|
78 | - * @param string $path path |
|
79 | - * @param array $tags array of tags |
|
80 | - * @return array list of tags |
|
81 | - * @throws \OCP\Files\NotFoundException if the file does not exist |
|
82 | - */ |
|
83 | - public function updateFileTags($path, $tags) { |
|
84 | - $fileId = $this->homeFolder->get($path)->getId(); |
|
73 | + /** |
|
74 | + * Updates the tags of the specified file path. |
|
75 | + * The passed tags are absolute, which means they will |
|
76 | + * replace the actual tag selection. |
|
77 | + * |
|
78 | + * @param string $path path |
|
79 | + * @param array $tags array of tags |
|
80 | + * @return array list of tags |
|
81 | + * @throws \OCP\Files\NotFoundException if the file does not exist |
|
82 | + */ |
|
83 | + public function updateFileTags($path, $tags) { |
|
84 | + $fileId = $this->homeFolder->get($path)->getId(); |
|
85 | 85 | |
86 | - $currentTags = $this->tagger->getTagsForObjects([$fileId]); |
|
86 | + $currentTags = $this->tagger->getTagsForObjects([$fileId]); |
|
87 | 87 | |
88 | - if (!empty($currentTags)) { |
|
89 | - $currentTags = current($currentTags); |
|
90 | - } |
|
88 | + if (!empty($currentTags)) { |
|
89 | + $currentTags = current($currentTags); |
|
90 | + } |
|
91 | 91 | |
92 | - $newTags = array_diff($tags, $currentTags); |
|
93 | - foreach ($newTags as $tag) { |
|
94 | - if ($tag === ITags::TAG_FAVORITE) { |
|
95 | - $this->addActivity(true, $fileId, $path); |
|
96 | - } |
|
97 | - $this->tagger->tagAs($fileId, $tag); |
|
98 | - } |
|
99 | - $deletedTags = array_diff($currentTags, $tags); |
|
100 | - foreach ($deletedTags as $tag) { |
|
101 | - if ($tag === ITags::TAG_FAVORITE) { |
|
102 | - $this->addActivity(false, $fileId, $path); |
|
103 | - } |
|
104 | - $this->tagger->unTag($fileId, $tag); |
|
105 | - } |
|
92 | + $newTags = array_diff($tags, $currentTags); |
|
93 | + foreach ($newTags as $tag) { |
|
94 | + if ($tag === ITags::TAG_FAVORITE) { |
|
95 | + $this->addActivity(true, $fileId, $path); |
|
96 | + } |
|
97 | + $this->tagger->tagAs($fileId, $tag); |
|
98 | + } |
|
99 | + $deletedTags = array_diff($currentTags, $tags); |
|
100 | + foreach ($deletedTags as $tag) { |
|
101 | + if ($tag === ITags::TAG_FAVORITE) { |
|
102 | + $this->addActivity(false, $fileId, $path); |
|
103 | + } |
|
104 | + $this->tagger->unTag($fileId, $tag); |
|
105 | + } |
|
106 | 106 | |
107 | - // TODO: re-read from tagger to make sure the |
|
108 | - // list is up to date, in case of concurrent changes ? |
|
109 | - return $tags; |
|
110 | - } |
|
107 | + // TODO: re-read from tagger to make sure the |
|
108 | + // list is up to date, in case of concurrent changes ? |
|
109 | + return $tags; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @param bool $addToFavorite |
|
114 | - * @param int $fileId |
|
115 | - * @param string $path |
|
116 | - */ |
|
117 | - protected function addActivity($addToFavorite, $fileId, $path) { |
|
118 | - $user = $this->userSession->getUser(); |
|
119 | - if (!$user instanceof IUser) { |
|
120 | - return; |
|
121 | - } |
|
112 | + /** |
|
113 | + * @param bool $addToFavorite |
|
114 | + * @param int $fileId |
|
115 | + * @param string $path |
|
116 | + */ |
|
117 | + protected function addActivity($addToFavorite, $fileId, $path) { |
|
118 | + $user = $this->userSession->getUser(); |
|
119 | + if (!$user instanceof IUser) { |
|
120 | + return; |
|
121 | + } |
|
122 | 122 | |
123 | - $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite'; |
|
124 | - $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [ |
|
125 | - 'userId' => $user->getUID(), |
|
126 | - 'fileId' => $fileId, |
|
127 | - 'path' => $path, |
|
128 | - ])); |
|
123 | + $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite'; |
|
124 | + $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [ |
|
125 | + 'userId' => $user->getUID(), |
|
126 | + 'fileId' => $fileId, |
|
127 | + 'path' => $path, |
|
128 | + ])); |
|
129 | 129 | |
130 | - $event = $this->activityManager->generateEvent(); |
|
131 | - try { |
|
132 | - $event->setApp('files') |
|
133 | - ->setObject('files', $fileId, $path) |
|
134 | - ->setType('favorite') |
|
135 | - ->setAuthor($user->getUID()) |
|
136 | - ->setAffectedUser($user->getUID()) |
|
137 | - ->setTimestamp(time()) |
|
138 | - ->setSubject( |
|
139 | - $addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED, |
|
140 | - ['id' => $fileId, 'path' => $path] |
|
141 | - ); |
|
142 | - $this->activityManager->publish($event); |
|
143 | - } catch (\InvalidArgumentException $e) { |
|
144 | - } catch (\BadMethodCallException $e) { |
|
145 | - } |
|
146 | - } |
|
130 | + $event = $this->activityManager->generateEvent(); |
|
131 | + try { |
|
132 | + $event->setApp('files') |
|
133 | + ->setObject('files', $fileId, $path) |
|
134 | + ->setType('favorite') |
|
135 | + ->setAuthor($user->getUID()) |
|
136 | + ->setAffectedUser($user->getUID()) |
|
137 | + ->setTimestamp(time()) |
|
138 | + ->setSubject( |
|
139 | + $addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED, |
|
140 | + ['id' => $fileId, 'path' => $path] |
|
141 | + ); |
|
142 | + $this->activityManager->publish($event); |
|
143 | + } catch (\InvalidArgumentException $e) { |
|
144 | + } catch (\BadMethodCallException $e) { |
|
145 | + } |
|
146 | + } |
|
147 | 147 | } |