@@ -28,48 +28,48 @@ |
||
28 | 28 | |
29 | 29 | class BackupCodeMapper extends Mapper { |
30 | 30 | |
31 | - public function __construct(IDBConnection $db) { |
|
32 | - parent::__construct($db, 'twofactor_backupcodes'); |
|
33 | - } |
|
31 | + public function __construct(IDBConnection $db) { |
|
32 | + parent::__construct($db, 'twofactor_backupcodes'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param IUser $user |
|
37 | - * @return BackupCode[] |
|
38 | - */ |
|
39 | - public function getBackupCodes(IUser $user) { |
|
40 | - /* @var IQueryBuilder $qb */ |
|
41 | - $qb = $this->db->getQueryBuilder(); |
|
35 | + /** |
|
36 | + * @param IUser $user |
|
37 | + * @return BackupCode[] |
|
38 | + */ |
|
39 | + public function getBackupCodes(IUser $user) { |
|
40 | + /* @var IQueryBuilder $qb */ |
|
41 | + $qb = $this->db->getQueryBuilder(); |
|
42 | 42 | |
43 | - $qb->select('id', 'user_id', 'code', 'used') |
|
44 | - ->from('twofactor_backupcodes') |
|
45 | - ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID()))); |
|
46 | - $result = $qb->execute(); |
|
43 | + $qb->select('id', 'user_id', 'code', 'used') |
|
44 | + ->from('twofactor_backupcodes') |
|
45 | + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID()))); |
|
46 | + $result = $qb->execute(); |
|
47 | 47 | |
48 | - $rows = $result->fetchAll(); |
|
49 | - $result->closeCursor(); |
|
48 | + $rows = $result->fetchAll(); |
|
49 | + $result->closeCursor(); |
|
50 | 50 | |
51 | - return array_map(function ($row) { |
|
52 | - return BackupCode::fromRow($row); |
|
53 | - }, $rows); |
|
54 | - } |
|
51 | + return array_map(function ($row) { |
|
52 | + return BackupCode::fromRow($row); |
|
53 | + }, $rows); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param IUser $user |
|
58 | - */ |
|
59 | - public function deleteCodes(IUser $user) { |
|
60 | - $this->deleteCodesByUserId($user->getUID()); |
|
61 | - } |
|
56 | + /** |
|
57 | + * @param IUser $user |
|
58 | + */ |
|
59 | + public function deleteCodes(IUser $user) { |
|
60 | + $this->deleteCodesByUserId($user->getUID()); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param string $uid |
|
65 | - */ |
|
66 | - public function deleteCodesByUserId($uid) { |
|
67 | - /* @var IQueryBuilder $qb */ |
|
68 | - $qb = $this->db->getQueryBuilder(); |
|
63 | + /** |
|
64 | + * @param string $uid |
|
65 | + */ |
|
66 | + public function deleteCodesByUserId($uid) { |
|
67 | + /* @var IQueryBuilder $qb */ |
|
68 | + $qb = $this->db->getQueryBuilder(); |
|
69 | 69 | |
70 | - $qb->delete('twofactor_backupcodes') |
|
71 | - ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($uid))); |
|
72 | - $qb->execute(); |
|
73 | - } |
|
70 | + $qb->delete('twofactor_backupcodes') |
|
71 | + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($uid))); |
|
72 | + $qb->execute(); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | } |
@@ -28,39 +28,39 @@ |
||
28 | 28 | |
29 | 29 | class SecurityFilter implements IFilter { |
30 | 30 | |
31 | - /** @var IURLGenerator */ |
|
32 | - private $urlGenerator; |
|
31 | + /** @var IURLGenerator */ |
|
32 | + private $urlGenerator; |
|
33 | 33 | |
34 | - /** @var IL10N */ |
|
35 | - private $l10n; |
|
34 | + /** @var IL10N */ |
|
35 | + private $l10n; |
|
36 | 36 | |
37 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { |
|
38 | - $this->urlGenerator = $urlGenerator; |
|
39 | - $this->l10n = $l10n; |
|
40 | - } |
|
37 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { |
|
38 | + $this->urlGenerator = $urlGenerator; |
|
39 | + $this->l10n = $l10n; |
|
40 | + } |
|
41 | 41 | |
42 | - public function allowedApps() { |
|
43 | - return []; |
|
44 | - } |
|
42 | + public function allowedApps() { |
|
43 | + return []; |
|
44 | + } |
|
45 | 45 | |
46 | - public function filterTypes(array $types) { |
|
47 | - return array_intersect(['security'], $types); |
|
48 | - } |
|
46 | + public function filterTypes(array $types) { |
|
47 | + return array_intersect(['security'], $types); |
|
48 | + } |
|
49 | 49 | |
50 | - public function getIcon() { |
|
51 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')); |
|
52 | - } |
|
50 | + public function getIcon() { |
|
51 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')); |
|
52 | + } |
|
53 | 53 | |
54 | - public function getIdentifier() { |
|
55 | - return 'security'; |
|
56 | - } |
|
54 | + public function getIdentifier() { |
|
55 | + return 'security'; |
|
56 | + } |
|
57 | 57 | |
58 | - public function getName() { |
|
59 | - return $this->l10n->t('Security'); |
|
60 | - } |
|
58 | + public function getName() { |
|
59 | + return $this->l10n->t('Security'); |
|
60 | + } |
|
61 | 61 | |
62 | - public function getPriority() { |
|
63 | - return 30; |
|
64 | - } |
|
62 | + public function getPriority() { |
|
63 | + return 30; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
@@ -27,39 +27,39 @@ |
||
27 | 27 | |
28 | 28 | class SecuritySetting implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - private $l10n; |
|
30 | + /** @var IL10N */ |
|
31 | + private $l10n; |
|
32 | 32 | |
33 | - public function __construct(IL10N $l10n) { |
|
34 | - $this->l10n = $l10n; |
|
35 | - } |
|
33 | + public function __construct(IL10N $l10n) { |
|
34 | + $this->l10n = $l10n; |
|
35 | + } |
|
36 | 36 | |
37 | - public function canChangeMail() { |
|
38 | - return false; |
|
39 | - } |
|
37 | + public function canChangeMail() { |
|
38 | + return false; |
|
39 | + } |
|
40 | 40 | |
41 | - public function canChangeStream() { |
|
42 | - return false; |
|
43 | - } |
|
41 | + public function canChangeStream() { |
|
42 | + return false; |
|
43 | + } |
|
44 | 44 | |
45 | - public function getIdentifier() { |
|
46 | - return 'security'; |
|
47 | - } |
|
45 | + public function getIdentifier() { |
|
46 | + return 'security'; |
|
47 | + } |
|
48 | 48 | |
49 | - public function getName() { |
|
50 | - return $this->l10n->t('Security'); |
|
51 | - } |
|
49 | + public function getName() { |
|
50 | + return $this->l10n->t('Security'); |
|
51 | + } |
|
52 | 52 | |
53 | - public function getPriority() { |
|
54 | - return 30; |
|
55 | - } |
|
53 | + public function getPriority() { |
|
54 | + return 30; |
|
55 | + } |
|
56 | 56 | |
57 | - public function isDefaultEnabledMail() { |
|
58 | - return true; |
|
59 | - } |
|
57 | + public function isDefaultEnabledMail() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - public function isDefaultEnabledStream() { |
|
62 | - return true; |
|
63 | - } |
|
61 | + public function isDefaultEnabledStream() { |
|
62 | + return true; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OC\Files\Cache\Wrapper; |
25 | 25 | |
26 | 26 | class CachePermissionsMask extends CacheWrapper { |
27 | - /** |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - protected $mask; |
|
27 | + /** |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + protected $mask; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param \OCP\Files\Cache\ICache $cache |
|
34 | - * @param int $mask |
|
35 | - */ |
|
36 | - public function __construct($cache, $mask) { |
|
37 | - parent::__construct($cache); |
|
38 | - $this->mask = $mask; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param \OCP\Files\Cache\ICache $cache |
|
34 | + * @param int $mask |
|
35 | + */ |
|
36 | + public function __construct($cache, $mask) { |
|
37 | + parent::__construct($cache); |
|
38 | + $this->mask = $mask; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function formatCacheEntry($entry) { |
|
42 | - if (isset($entry['permissions'])) { |
|
43 | - $entry['scan_permissions'] = $entry['permissions']; |
|
44 | - $entry['permissions'] &= $this->mask; |
|
45 | - } |
|
46 | - return $entry; |
|
47 | - } |
|
41 | + protected function formatCacheEntry($entry) { |
|
42 | + if (isset($entry['permissions'])) { |
|
43 | + $entry['scan_permissions'] = $entry['permissions']; |
|
44 | + $entry['permissions'] &= $this->mask; |
|
45 | + } |
|
46 | + return $entry; |
|
47 | + } |
|
48 | 48 | } |
@@ -28,62 +28,62 @@ |
||
28 | 28 | |
29 | 29 | class ClientMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * @param IDBConnection $db |
|
33 | - */ |
|
34 | - public function __construct(IDBConnection $db) { |
|
35 | - parent::__construct($db, 'oauth2_clients'); |
|
36 | - } |
|
31 | + /** |
|
32 | + * @param IDBConnection $db |
|
33 | + */ |
|
34 | + public function __construct(IDBConnection $db) { |
|
35 | + parent::__construct($db, 'oauth2_clients'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $clientIdentifier |
|
40 | - * @return Client |
|
41 | - * @throws ClientNotFoundException |
|
42 | - */ |
|
43 | - public function getByIdentifier($clientIdentifier) { |
|
44 | - $qb = $this->db->getQueryBuilder(); |
|
45 | - $qb |
|
46 | - ->select('*') |
|
47 | - ->from($this->tableName) |
|
48 | - ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
49 | - $result = $qb->execute(); |
|
50 | - $row = $result->fetch(); |
|
51 | - $result->closeCursor(); |
|
52 | - if($row === false) { |
|
53 | - throw new ClientNotFoundException(); |
|
54 | - } |
|
55 | - return Client::fromRow($row); |
|
56 | - } |
|
38 | + /** |
|
39 | + * @param string $clientIdentifier |
|
40 | + * @return Client |
|
41 | + * @throws ClientNotFoundException |
|
42 | + */ |
|
43 | + public function getByIdentifier($clientIdentifier) { |
|
44 | + $qb = $this->db->getQueryBuilder(); |
|
45 | + $qb |
|
46 | + ->select('*') |
|
47 | + ->from($this->tableName) |
|
48 | + ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
49 | + $result = $qb->execute(); |
|
50 | + $row = $result->fetch(); |
|
51 | + $result->closeCursor(); |
|
52 | + if($row === false) { |
|
53 | + throw new ClientNotFoundException(); |
|
54 | + } |
|
55 | + return Client::fromRow($row); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param string $uid internal uid of the client |
|
60 | - * @return Client |
|
61 | - * @throws ClientNotFoundException |
|
62 | - */ |
|
63 | - public function getByUid($uid) { |
|
64 | - $qb = $this->db->getQueryBuilder(); |
|
65 | - $qb |
|
66 | - ->select('*') |
|
67 | - ->from($this->tableName) |
|
68 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
69 | - $result = $qb->execute(); |
|
70 | - $row = $result->fetch(); |
|
71 | - $result->closeCursor(); |
|
72 | - if($row === false) { |
|
73 | - throw new ClientNotFoundException(); |
|
74 | - } |
|
75 | - return Client::fromRow($row); |
|
76 | - } |
|
58 | + /** |
|
59 | + * @param string $uid internal uid of the client |
|
60 | + * @return Client |
|
61 | + * @throws ClientNotFoundException |
|
62 | + */ |
|
63 | + public function getByUid($uid) { |
|
64 | + $qb = $this->db->getQueryBuilder(); |
|
65 | + $qb |
|
66 | + ->select('*') |
|
67 | + ->from($this->tableName) |
|
68 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
69 | + $result = $qb->execute(); |
|
70 | + $row = $result->fetch(); |
|
71 | + $result->closeCursor(); |
|
72 | + if($row === false) { |
|
73 | + throw new ClientNotFoundException(); |
|
74 | + } |
|
75 | + return Client::fromRow($row); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return Client[] |
|
80 | - */ |
|
81 | - public function getClients() { |
|
82 | - $qb = $this->db->getQueryBuilder(); |
|
83 | - $qb |
|
84 | - ->select('*') |
|
85 | - ->from($this->tableName); |
|
78 | + /** |
|
79 | + * @return Client[] |
|
80 | + */ |
|
81 | + public function getClients() { |
|
82 | + $qb = $this->db->getQueryBuilder(); |
|
83 | + $qb |
|
84 | + ->select('*') |
|
85 | + ->from($this->tableName); |
|
86 | 86 | |
87 | - return $this->findEntities($qb->getSQL()); |
|
88 | - } |
|
87 | + return $this->findEntities($qb->getSQL()); |
|
88 | + } |
|
89 | 89 | } |
@@ -28,43 +28,43 @@ |
||
28 | 28 | |
29 | 29 | class AccessTokenMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * @param IDBConnection $db |
|
33 | - */ |
|
34 | - public function __construct(IDBConnection $db) { |
|
35 | - parent::__construct($db, 'oauth2_access_tokens'); |
|
36 | - } |
|
31 | + /** |
|
32 | + * @param IDBConnection $db |
|
33 | + */ |
|
34 | + public function __construct(IDBConnection $db) { |
|
35 | + parent::__construct($db, 'oauth2_access_tokens'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $code |
|
40 | - * @return AccessToken |
|
41 | - * @throws AccessTokenNotFoundException |
|
42 | - */ |
|
43 | - public function getByCode($code) { |
|
44 | - $qb = $this->db->getQueryBuilder(); |
|
45 | - $qb |
|
46 | - ->select('*') |
|
47 | - ->from($this->tableName) |
|
48 | - ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
49 | - $result = $qb->execute(); |
|
50 | - $row = $result->fetch(); |
|
51 | - $result->closeCursor(); |
|
52 | - if($row === false) { |
|
53 | - throw new AccessTokenNotFoundException(); |
|
54 | - } |
|
55 | - return AccessToken::fromRow($row); |
|
56 | - } |
|
38 | + /** |
|
39 | + * @param string $code |
|
40 | + * @return AccessToken |
|
41 | + * @throws AccessTokenNotFoundException |
|
42 | + */ |
|
43 | + public function getByCode($code) { |
|
44 | + $qb = $this->db->getQueryBuilder(); |
|
45 | + $qb |
|
46 | + ->select('*') |
|
47 | + ->from($this->tableName) |
|
48 | + ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
49 | + $result = $qb->execute(); |
|
50 | + $row = $result->fetch(); |
|
51 | + $result->closeCursor(); |
|
52 | + if($row === false) { |
|
53 | + throw new AccessTokenNotFoundException(); |
|
54 | + } |
|
55 | + return AccessToken::fromRow($row); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * delete all access token from a given client |
|
60 | - * |
|
61 | - * @param int $id |
|
62 | - */ |
|
63 | - public function deleteByClientId($id) { |
|
64 | - $qb = $this->db->getQueryBuilder(); |
|
65 | - $qb |
|
66 | - ->delete($this->tableName) |
|
67 | - ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
68 | - $qb->execute(); |
|
69 | - } |
|
58 | + /** |
|
59 | + * delete all access token from a given client |
|
60 | + * |
|
61 | + * @param int $id |
|
62 | + */ |
|
63 | + public function deleteByClientId($id) { |
|
64 | + $qb = $this->db->getQueryBuilder(); |
|
65 | + $qb |
|
66 | + ->delete($this->tableName) |
|
67 | + ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
68 | + $qb->execute(); |
|
69 | + } |
|
70 | 70 | } |
@@ -29,31 +29,31 @@ |
||
29 | 29 | |
30 | 30 | class Additional implements ISettings { |
31 | 31 | |
32 | - /** |
|
33 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
34 | - * @since 9.1 |
|
35 | - */ |
|
36 | - public function getForm() { |
|
37 | - return new TemplateResponse('settings', 'settings/empty'); |
|
38 | - } |
|
32 | + /** |
|
33 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
34 | + * @since 9.1 |
|
35 | + */ |
|
36 | + public function getForm() { |
|
37 | + return new TemplateResponse('settings', 'settings/empty'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string the section ID, e.g. 'sharing' |
|
42 | - * @since 9.1 |
|
43 | - */ |
|
44 | - public function getSection() { |
|
45 | - return 'additional'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string the section ID, e.g. 'sharing' |
|
42 | + * @since 9.1 |
|
43 | + */ |
|
44 | + public function getSection() { |
|
45 | + return 'additional'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return int whether the form should be rather on the top or bottom of |
|
50 | - * the admin section. The forms are arranged in ascending order of the |
|
51 | - * priority values. It is required to return a value between 0 and 100. |
|
52 | - * |
|
53 | - * E.g.: 70 |
|
54 | - * @since 9.1 |
|
55 | - */ |
|
56 | - public function getPriority() { |
|
57 | - return '5'; |
|
58 | - } |
|
48 | + /** |
|
49 | + * @return int whether the form should be rather on the top or bottom of |
|
50 | + * the admin section. The forms are arranged in ascending order of the |
|
51 | + * priority values. It is required to return a value between 0 and 100. |
|
52 | + * |
|
53 | + * E.g.: 70 |
|
54 | + * @since 9.1 |
|
55 | + */ |
|
56 | + public function getPriority() { |
|
57 | + return '5'; |
|
58 | + } |
|
59 | 59 | } |
@@ -34,101 +34,101 @@ |
||
34 | 34 | * @package OC |
35 | 35 | */ |
36 | 36 | class ServerContainer extends SimpleContainer { |
37 | - /** @var DIContainer[] */ |
|
38 | - protected $appContainers; |
|
37 | + /** @var DIContainer[] */ |
|
38 | + protected $appContainers; |
|
39 | 39 | |
40 | - /** @var string[] */ |
|
41 | - protected $hasNoAppContainer; |
|
40 | + /** @var string[] */ |
|
41 | + protected $hasNoAppContainer; |
|
42 | 42 | |
43 | - /** @var string[] */ |
|
44 | - protected $namespaces; |
|
43 | + /** @var string[] */ |
|
44 | + protected $namespaces; |
|
45 | 45 | |
46 | - /** |
|
47 | - * ServerContainer constructor. |
|
48 | - */ |
|
49 | - public function __construct() { |
|
50 | - parent::__construct(); |
|
51 | - $this->appContainers = []; |
|
52 | - $this->namespaces = []; |
|
53 | - $this->hasNoAppContainer = []; |
|
54 | - } |
|
46 | + /** |
|
47 | + * ServerContainer constructor. |
|
48 | + */ |
|
49 | + public function __construct() { |
|
50 | + parent::__construct(); |
|
51 | + $this->appContainers = []; |
|
52 | + $this->namespaces = []; |
|
53 | + $this->hasNoAppContainer = []; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $appName |
|
58 | - * @param string $appNamespace |
|
59 | - */ |
|
60 | - public function registerNamespace($appName, $appNamespace) { |
|
61 | - // Cut of OCA\ and lowercase |
|
62 | - $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
63 | - $this->namespaces[$appNamespace] = $appName; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @param string $appName |
|
58 | + * @param string $appNamespace |
|
59 | + */ |
|
60 | + public function registerNamespace($appName, $appNamespace) { |
|
61 | + // Cut of OCA\ and lowercase |
|
62 | + $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
63 | + $this->namespaces[$appNamespace] = $appName; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string $appName |
|
68 | - * @param DIContainer $container |
|
69 | - */ |
|
70 | - public function registerAppContainer($appName, DIContainer $container) { |
|
71 | - $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @param string $appName |
|
68 | + * @param DIContainer $container |
|
69 | + */ |
|
70 | + public function registerAppContainer($appName, DIContainer $container) { |
|
71 | + $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $namespace |
|
76 | - * @param string $sensitiveNamespace |
|
77 | - * @return DIContainer |
|
78 | - * @throws QueryException |
|
79 | - */ |
|
80 | - protected function getAppContainer($namespace, $sensitiveNamespace) { |
|
81 | - if (isset($this->appContainers[$namespace])) { |
|
82 | - return $this->appContainers[$namespace]; |
|
83 | - } |
|
74 | + /** |
|
75 | + * @param string $namespace |
|
76 | + * @param string $sensitiveNamespace |
|
77 | + * @return DIContainer |
|
78 | + * @throws QueryException |
|
79 | + */ |
|
80 | + protected function getAppContainer($namespace, $sensitiveNamespace) { |
|
81 | + if (isset($this->appContainers[$namespace])) { |
|
82 | + return $this->appContainers[$namespace]; |
|
83 | + } |
|
84 | 84 | |
85 | - if (isset($this->namespaces[$namespace])) { |
|
86 | - if (!isset($this->hasNoAppContainer[$namespace])) { |
|
87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
88 | - if (class_exists($applicationClassName)) { |
|
89 | - new $applicationClassName(); |
|
90 | - if (isset($this->appContainers[$namespace])) { |
|
91 | - return $this->appContainers[$namespace]; |
|
92 | - } |
|
93 | - } |
|
94 | - $this->hasNoAppContainer[$namespace] = true; |
|
95 | - } |
|
85 | + if (isset($this->namespaces[$namespace])) { |
|
86 | + if (!isset($this->hasNoAppContainer[$namespace])) { |
|
87 | + $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
88 | + if (class_exists($applicationClassName)) { |
|
89 | + new $applicationClassName(); |
|
90 | + if (isset($this->appContainers[$namespace])) { |
|
91 | + return $this->appContainers[$namespace]; |
|
92 | + } |
|
93 | + } |
|
94 | + $this->hasNoAppContainer[$namespace] = true; |
|
95 | + } |
|
96 | 96 | |
97 | - return new DIContainer($this->namespaces[$namespace]); |
|
98 | - } |
|
99 | - throw new QueryException(); |
|
100 | - } |
|
97 | + return new DIContainer($this->namespaces[$namespace]); |
|
98 | + } |
|
99 | + throw new QueryException(); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @param string $name name of the service to query for |
|
104 | - * @return mixed registered service for the given $name |
|
105 | - * @throws QueryException if the query could not be resolved |
|
106 | - */ |
|
107 | - public function query($name) { |
|
108 | - $name = $this->sanitizeName($name); |
|
102 | + /** |
|
103 | + * @param string $name name of the service to query for |
|
104 | + * @return mixed registered service for the given $name |
|
105 | + * @throws QueryException if the query could not be resolved |
|
106 | + */ |
|
107 | + public function query($name) { |
|
108 | + $name = $this->sanitizeName($name); |
|
109 | 109 | |
110 | - // In case the service starts with OCA\ we try to find the service in |
|
111 | - // the apps container first. |
|
112 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
113 | - $segments = explode('\\', $name); |
|
114 | - try { |
|
115 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
116 | - return $appContainer->queryNoFallback($name); |
|
117 | - } catch (QueryException $e) { |
|
118 | - // Didn't find the service or the respective app container, |
|
119 | - // ignore it and fall back to the core container. |
|
120 | - } |
|
121 | - } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
122 | - $segments = explode('\\', $name); |
|
123 | - try { |
|
124 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
125 | - return $appContainer->queryNoFallback($name); |
|
126 | - } catch (QueryException $e) { |
|
127 | - // Didn't find the service or the respective app container, |
|
128 | - // ignore it and fall back to the core container. |
|
129 | - } |
|
130 | - } |
|
110 | + // In case the service starts with OCA\ we try to find the service in |
|
111 | + // the apps container first. |
|
112 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
113 | + $segments = explode('\\', $name); |
|
114 | + try { |
|
115 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
116 | + return $appContainer->queryNoFallback($name); |
|
117 | + } catch (QueryException $e) { |
|
118 | + // Didn't find the service or the respective app container, |
|
119 | + // ignore it and fall back to the core container. |
|
120 | + } |
|
121 | + } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
122 | + $segments = explode('\\', $name); |
|
123 | + try { |
|
124 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
125 | + return $appContainer->queryNoFallback($name); |
|
126 | + } catch (QueryException $e) { |
|
127 | + // Didn't find the service or the respective app container, |
|
128 | + // ignore it and fall back to the core container. |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - return parent::query($name); |
|
133 | - } |
|
132 | + return parent::query($name); |
|
133 | + } |
|
134 | 134 | } |
@@ -27,45 +27,45 @@ |
||
27 | 27 | |
28 | 28 | class Config implements \OCP\GlobalScale\IConfig { |
29 | 29 | |
30 | - /** @var IConfig */ |
|
31 | - private $config; |
|
30 | + /** @var IConfig */ |
|
31 | + private $config; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Config constructor. |
|
35 | - * |
|
36 | - * @param IConfig $config |
|
37 | - */ |
|
38 | - public function __construct(IConfig $config) { |
|
39 | - $this->config = $config; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Config constructor. |
|
35 | + * |
|
36 | + * @param IConfig $config |
|
37 | + */ |
|
38 | + public function __construct(IConfig $config) { |
|
39 | + $this->config = $config; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * check if global scale is enabled |
|
44 | - * |
|
45 | - * @since 12.0.1 |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function isGlobalScaleEnabled() { |
|
49 | - $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | - return $enabled !== false; |
|
51 | - } |
|
42 | + /** |
|
43 | + * check if global scale is enabled |
|
44 | + * |
|
45 | + * @since 12.0.1 |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function isGlobalScaleEnabled() { |
|
49 | + $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | + return $enabled !== false; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * check if federation should only be used internally in a global scale setup |
|
55 | - * |
|
56 | - * @since 12.0.1 |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function onlyInternalFederation() { |
|
60 | - // if global scale is disabled federation works always globally |
|
61 | - $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | - if ($gsEnabled === false) { |
|
63 | - return false; |
|
64 | - } |
|
53 | + /** |
|
54 | + * check if federation should only be used internally in a global scale setup |
|
55 | + * |
|
56 | + * @since 12.0.1 |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function onlyInternalFederation() { |
|
60 | + // if global scale is disabled federation works always globally |
|
61 | + $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | + if ($gsEnabled === false) { |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | |
66 | - $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
66 | + $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
67 | 67 | |
68 | - return $enabled === 'internal'; |
|
69 | - } |
|
68 | + return $enabled === 'internal'; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |