@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class PropFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -27,28 +27,28 @@ |
||
27 | 27 | |
28 | 28 | class ParamFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $property = $att['property']; |
|
38 | - $parameter = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $property = $att['property']; |
|
38 | + $parameter = $att['name']; |
|
39 | 39 | |
40 | - $reader->parseInnerTree(); |
|
40 | + $reader->parseInnerTree(); |
|
41 | 41 | |
42 | - if (!is_string($property)) { |
|
43 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | - } |
|
45 | - if (!is_string($parameter)) { |
|
46 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | - } |
|
42 | + if (!is_string($property)) { |
|
43 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | + } |
|
45 | + if (!is_string($parameter)) { |
|
46 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | + } |
|
48 | 48 | |
49 | - return [ |
|
50 | - 'property' => $property, |
|
51 | - 'parameter' => $parameter, |
|
52 | - ]; |
|
53 | - } |
|
49 | + return [ |
|
50 | + 'property' => $property, |
|
51 | + 'parameter' => $parameter, |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | } |
@@ -35,144 +35,144 @@ |
||
35 | 35 | |
36 | 36 | class SystemTagsByIdCollection implements ICollection { |
37 | 37 | |
38 | - /** |
|
39 | - * @var ISystemTagManager |
|
40 | - */ |
|
41 | - private $tagManager; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var IGroupManager |
|
45 | - */ |
|
46 | - private $groupManager; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var IUserSession |
|
50 | - */ |
|
51 | - private $userSession; |
|
52 | - |
|
53 | - /** |
|
54 | - * SystemTagsByIdCollection constructor. |
|
55 | - * |
|
56 | - * @param ISystemTagManager $tagManager |
|
57 | - * @param IUserSession $userSession |
|
58 | - * @param IGroupManager $groupManager |
|
59 | - */ |
|
60 | - public function __construct( |
|
61 | - ISystemTagManager $tagManager, |
|
62 | - IUserSession $userSession, |
|
63 | - IGroupManager $groupManager |
|
64 | - ) { |
|
65 | - $this->tagManager = $tagManager; |
|
66 | - $this->userSession = $userSession; |
|
67 | - $this->groupManager = $groupManager; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Returns whether the currently logged in user is an administrator |
|
72 | - * |
|
73 | - * @return bool true if the user is an admin |
|
74 | - */ |
|
75 | - private function isAdmin() { |
|
76 | - $user = $this->userSession->getUser(); |
|
77 | - if ($user !== null) { |
|
78 | - return $this->groupManager->isAdmin($user->getUID()); |
|
79 | - } |
|
80 | - return false; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string $name |
|
85 | - * @param resource|string $data Initial payload |
|
86 | - * @throws Forbidden |
|
87 | - */ |
|
88 | - public function createFile($name, $data = null) { |
|
89 | - throw new Forbidden('Cannot create tags by id'); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param string $name |
|
94 | - */ |
|
95 | - public function createDirectory($name) { |
|
96 | - throw new Forbidden('Permission denied to create collections'); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param string $name |
|
101 | - */ |
|
102 | - public function getChild($name) { |
|
103 | - try { |
|
104 | - $tag = $this->tagManager->getTagsByIds([$name]); |
|
105 | - $tag = current($tag); |
|
106 | - if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
107 | - throw new NotFound('Tag with id ' . $name . ' not found'); |
|
108 | - } |
|
109 | - return $this->makeNode($tag); |
|
110 | - } catch (\InvalidArgumentException $e) { |
|
111 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
112 | - } catch (TagNotFoundException $e) { |
|
113 | - throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - public function getChildren() { |
|
118 | - $visibilityFilter = true; |
|
119 | - if ($this->isAdmin()) { |
|
120 | - $visibilityFilter = null; |
|
121 | - } |
|
122 | - |
|
123 | - $tags = $this->tagManager->getAllTags($visibilityFilter); |
|
124 | - return array_map(function ($tag) { |
|
125 | - return $this->makeNode($tag); |
|
126 | - }, $tags); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @param string $name |
|
131 | - */ |
|
132 | - public function childExists($name) { |
|
133 | - try { |
|
134 | - $tag = $this->tagManager->getTagsByIds([$name]); |
|
135 | - $tag = current($tag); |
|
136 | - if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
137 | - return false; |
|
138 | - } |
|
139 | - return true; |
|
140 | - } catch (\InvalidArgumentException $e) { |
|
141 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
142 | - } catch (TagNotFoundException $e) { |
|
143 | - return false; |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - public function delete() { |
|
148 | - throw new Forbidden('Permission denied to delete this collection'); |
|
149 | - } |
|
150 | - |
|
151 | - public function getName() { |
|
152 | - return 'systemtags'; |
|
153 | - } |
|
154 | - |
|
155 | - public function setName($name) { |
|
156 | - throw new Forbidden('Permission denied to rename this collection'); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Returns the last modification time, as a unix timestamp |
|
161 | - * |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - public function getLastModified() { |
|
165 | - return null; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Create a sabre node for the given system tag |
|
170 | - * |
|
171 | - * @param ISystemTag $tag |
|
172 | - * |
|
173 | - * @return SystemTagNode |
|
174 | - */ |
|
175 | - private function makeNode(ISystemTag $tag) { |
|
176 | - return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager); |
|
177 | - } |
|
38 | + /** |
|
39 | + * @var ISystemTagManager |
|
40 | + */ |
|
41 | + private $tagManager; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var IGroupManager |
|
45 | + */ |
|
46 | + private $groupManager; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var IUserSession |
|
50 | + */ |
|
51 | + private $userSession; |
|
52 | + |
|
53 | + /** |
|
54 | + * SystemTagsByIdCollection constructor. |
|
55 | + * |
|
56 | + * @param ISystemTagManager $tagManager |
|
57 | + * @param IUserSession $userSession |
|
58 | + * @param IGroupManager $groupManager |
|
59 | + */ |
|
60 | + public function __construct( |
|
61 | + ISystemTagManager $tagManager, |
|
62 | + IUserSession $userSession, |
|
63 | + IGroupManager $groupManager |
|
64 | + ) { |
|
65 | + $this->tagManager = $tagManager; |
|
66 | + $this->userSession = $userSession; |
|
67 | + $this->groupManager = $groupManager; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Returns whether the currently logged in user is an administrator |
|
72 | + * |
|
73 | + * @return bool true if the user is an admin |
|
74 | + */ |
|
75 | + private function isAdmin() { |
|
76 | + $user = $this->userSession->getUser(); |
|
77 | + if ($user !== null) { |
|
78 | + return $this->groupManager->isAdmin($user->getUID()); |
|
79 | + } |
|
80 | + return false; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string $name |
|
85 | + * @param resource|string $data Initial payload |
|
86 | + * @throws Forbidden |
|
87 | + */ |
|
88 | + public function createFile($name, $data = null) { |
|
89 | + throw new Forbidden('Cannot create tags by id'); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param string $name |
|
94 | + */ |
|
95 | + public function createDirectory($name) { |
|
96 | + throw new Forbidden('Permission denied to create collections'); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param string $name |
|
101 | + */ |
|
102 | + public function getChild($name) { |
|
103 | + try { |
|
104 | + $tag = $this->tagManager->getTagsByIds([$name]); |
|
105 | + $tag = current($tag); |
|
106 | + if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
107 | + throw new NotFound('Tag with id ' . $name . ' not found'); |
|
108 | + } |
|
109 | + return $this->makeNode($tag); |
|
110 | + } catch (\InvalidArgumentException $e) { |
|
111 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
112 | + } catch (TagNotFoundException $e) { |
|
113 | + throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + public function getChildren() { |
|
118 | + $visibilityFilter = true; |
|
119 | + if ($this->isAdmin()) { |
|
120 | + $visibilityFilter = null; |
|
121 | + } |
|
122 | + |
|
123 | + $tags = $this->tagManager->getAllTags($visibilityFilter); |
|
124 | + return array_map(function ($tag) { |
|
125 | + return $this->makeNode($tag); |
|
126 | + }, $tags); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @param string $name |
|
131 | + */ |
|
132 | + public function childExists($name) { |
|
133 | + try { |
|
134 | + $tag = $this->tagManager->getTagsByIds([$name]); |
|
135 | + $tag = current($tag); |
|
136 | + if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
137 | + return false; |
|
138 | + } |
|
139 | + return true; |
|
140 | + } catch (\InvalidArgumentException $e) { |
|
141 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
142 | + } catch (TagNotFoundException $e) { |
|
143 | + return false; |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + public function delete() { |
|
148 | + throw new Forbidden('Permission denied to delete this collection'); |
|
149 | + } |
|
150 | + |
|
151 | + public function getName() { |
|
152 | + return 'systemtags'; |
|
153 | + } |
|
154 | + |
|
155 | + public function setName($name) { |
|
156 | + throw new Forbidden('Permission denied to rename this collection'); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Returns the last modification time, as a unix timestamp |
|
161 | + * |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + public function getLastModified() { |
|
165 | + return null; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Create a sabre node for the given system tag |
|
170 | + * |
|
171 | + * @param ISystemTag $tag |
|
172 | + * |
|
173 | + * @return SystemTagNode |
|
174 | + */ |
|
175 | + private function makeNode(ISystemTag $tag) { |
|
176 | + return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager); |
|
177 | + } |
|
178 | 178 | } |
@@ -38,136 +38,136 @@ |
||
38 | 38 | */ |
39 | 39 | class SystemTagsObjectTypeCollection implements ICollection { |
40 | 40 | |
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - private $objectType; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var ISystemTagManager |
|
48 | - */ |
|
49 | - private $tagManager; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var ISystemTagObjectMapper |
|
53 | - */ |
|
54 | - private $tagMapper; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var IGroupManager |
|
58 | - */ |
|
59 | - private $groupManager; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var IUserSession |
|
63 | - */ |
|
64 | - private $userSession; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var \Closure |
|
68 | - **/ |
|
69 | - protected $childExistsFunction; |
|
70 | - |
|
71 | - /** |
|
72 | - * Constructor |
|
73 | - * |
|
74 | - * @param string $objectType object type |
|
75 | - * @param ISystemTagManager $tagManager |
|
76 | - * @param ISystemTagObjectMapper $tagMapper |
|
77 | - * @param IUserSession $userSession |
|
78 | - * @param IGroupManager $groupManager |
|
79 | - * @param \Closure $childExistsFunction |
|
80 | - */ |
|
81 | - public function __construct( |
|
82 | - $objectType, |
|
83 | - ISystemTagManager $tagManager, |
|
84 | - ISystemTagObjectMapper $tagMapper, |
|
85 | - IUserSession $userSession, |
|
86 | - IGroupManager $groupManager, |
|
87 | - \Closure $childExistsFunction |
|
88 | - ) { |
|
89 | - $this->tagManager = $tagManager; |
|
90 | - $this->tagMapper = $tagMapper; |
|
91 | - $this->objectType = $objectType; |
|
92 | - $this->userSession = $userSession; |
|
93 | - $this->groupManager = $groupManager; |
|
94 | - $this->childExistsFunction = $childExistsFunction; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $name |
|
99 | - * @param resource|string $data Initial payload |
|
100 | - * @return null|string |
|
101 | - * @throws Forbidden |
|
102 | - */ |
|
103 | - public function createFile($name, $data = null) { |
|
104 | - throw new Forbidden('Permission denied to create nodes'); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $name |
|
109 | - * @throws Forbidden |
|
110 | - */ |
|
111 | - public function createDirectory($name) { |
|
112 | - throw new Forbidden('Permission denied to create collections'); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @param string $objectId |
|
117 | - * @return SystemTagsObjectMappingCollection |
|
118 | - * @throws NotFound |
|
119 | - */ |
|
120 | - public function getChild($objectId) { |
|
121 | - // make sure the object exists and is reachable |
|
122 | - if (!$this->childExists($objectId)) { |
|
123 | - throw new NotFound('Entity does not exist or is not available'); |
|
124 | - } |
|
125 | - return new SystemTagsObjectMappingCollection( |
|
126 | - $objectId, |
|
127 | - $this->objectType, |
|
128 | - $this->userSession->getUser(), |
|
129 | - $this->tagManager, |
|
130 | - $this->tagMapper |
|
131 | - ); |
|
132 | - } |
|
133 | - |
|
134 | - public function getChildren() { |
|
135 | - // do not list object ids |
|
136 | - throw new MethodNotAllowed(); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Checks if a child-node with the specified name exists |
|
141 | - * |
|
142 | - * @param string $name |
|
143 | - * @return bool |
|
144 | - */ |
|
145 | - public function childExists($name) { |
|
146 | - return call_user_func($this->childExistsFunction, $name); |
|
147 | - } |
|
148 | - |
|
149 | - public function delete() { |
|
150 | - throw new Forbidden('Permission denied to delete this collection'); |
|
151 | - } |
|
152 | - |
|
153 | - public function getName() { |
|
154 | - return $this->objectType; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @param string $name |
|
159 | - * @throws Forbidden |
|
160 | - */ |
|
161 | - public function setName($name) { |
|
162 | - throw new Forbidden('Permission denied to rename this collection'); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns the last modification time, as a unix timestamp |
|
167 | - * |
|
168 | - * @return int |
|
169 | - */ |
|
170 | - public function getLastModified() { |
|
171 | - return null; |
|
172 | - } |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + private $objectType; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var ISystemTagManager |
|
48 | + */ |
|
49 | + private $tagManager; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var ISystemTagObjectMapper |
|
53 | + */ |
|
54 | + private $tagMapper; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var IGroupManager |
|
58 | + */ |
|
59 | + private $groupManager; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var IUserSession |
|
63 | + */ |
|
64 | + private $userSession; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var \Closure |
|
68 | + **/ |
|
69 | + protected $childExistsFunction; |
|
70 | + |
|
71 | + /** |
|
72 | + * Constructor |
|
73 | + * |
|
74 | + * @param string $objectType object type |
|
75 | + * @param ISystemTagManager $tagManager |
|
76 | + * @param ISystemTagObjectMapper $tagMapper |
|
77 | + * @param IUserSession $userSession |
|
78 | + * @param IGroupManager $groupManager |
|
79 | + * @param \Closure $childExistsFunction |
|
80 | + */ |
|
81 | + public function __construct( |
|
82 | + $objectType, |
|
83 | + ISystemTagManager $tagManager, |
|
84 | + ISystemTagObjectMapper $tagMapper, |
|
85 | + IUserSession $userSession, |
|
86 | + IGroupManager $groupManager, |
|
87 | + \Closure $childExistsFunction |
|
88 | + ) { |
|
89 | + $this->tagManager = $tagManager; |
|
90 | + $this->tagMapper = $tagMapper; |
|
91 | + $this->objectType = $objectType; |
|
92 | + $this->userSession = $userSession; |
|
93 | + $this->groupManager = $groupManager; |
|
94 | + $this->childExistsFunction = $childExistsFunction; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $name |
|
99 | + * @param resource|string $data Initial payload |
|
100 | + * @return null|string |
|
101 | + * @throws Forbidden |
|
102 | + */ |
|
103 | + public function createFile($name, $data = null) { |
|
104 | + throw new Forbidden('Permission denied to create nodes'); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $name |
|
109 | + * @throws Forbidden |
|
110 | + */ |
|
111 | + public function createDirectory($name) { |
|
112 | + throw new Forbidden('Permission denied to create collections'); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @param string $objectId |
|
117 | + * @return SystemTagsObjectMappingCollection |
|
118 | + * @throws NotFound |
|
119 | + */ |
|
120 | + public function getChild($objectId) { |
|
121 | + // make sure the object exists and is reachable |
|
122 | + if (!$this->childExists($objectId)) { |
|
123 | + throw new NotFound('Entity does not exist or is not available'); |
|
124 | + } |
|
125 | + return new SystemTagsObjectMappingCollection( |
|
126 | + $objectId, |
|
127 | + $this->objectType, |
|
128 | + $this->userSession->getUser(), |
|
129 | + $this->tagManager, |
|
130 | + $this->tagMapper |
|
131 | + ); |
|
132 | + } |
|
133 | + |
|
134 | + public function getChildren() { |
|
135 | + // do not list object ids |
|
136 | + throw new MethodNotAllowed(); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Checks if a child-node with the specified name exists |
|
141 | + * |
|
142 | + * @param string $name |
|
143 | + * @return bool |
|
144 | + */ |
|
145 | + public function childExists($name) { |
|
146 | + return call_user_func($this->childExistsFunction, $name); |
|
147 | + } |
|
148 | + |
|
149 | + public function delete() { |
|
150 | + throw new Forbidden('Permission denied to delete this collection'); |
|
151 | + } |
|
152 | + |
|
153 | + public function getName() { |
|
154 | + return $this->objectType; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @param string $name |
|
159 | + * @throws Forbidden |
|
160 | + */ |
|
161 | + public function setName($name) { |
|
162 | + throw new Forbidden('Permission denied to rename this collection'); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns the last modification time, as a unix timestamp |
|
167 | + * |
|
168 | + * @return int |
|
169 | + */ |
|
170 | + public function getLastModified() { |
|
171 | + return null; |
|
172 | + } |
|
173 | 173 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | use OCP\Capabilities\ICapability; |
26 | 26 | |
27 | 27 | class Capabilities implements ICapability { |
28 | - public function getCapabilities() { |
|
29 | - return [ |
|
30 | - 'dav' => [ |
|
31 | - 'chunking' => '1.0', |
|
32 | - ] |
|
33 | - ]; |
|
34 | - } |
|
28 | + public function getCapabilities() { |
|
29 | + return [ |
|
30 | + 'dav' => [ |
|
31 | + 'chunking' => '1.0', |
|
32 | + ] |
|
33 | + ]; |
|
34 | + } |
|
35 | 35 | } |
@@ -36,87 +36,87 @@ |
||
36 | 36 | */ |
37 | 37 | class FutureFile implements \Sabre\DAV\IFile { |
38 | 38 | |
39 | - /** @var Directory */ |
|
40 | - private $root; |
|
41 | - /** @var string */ |
|
42 | - private $name; |
|
39 | + /** @var Directory */ |
|
40 | + private $root; |
|
41 | + /** @var string */ |
|
42 | + private $name; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param Directory $root |
|
46 | - * @param string $name |
|
47 | - */ |
|
48 | - public function __construct(Directory $root, $name) { |
|
49 | - $this->root = $root; |
|
50 | - $this->name = $name; |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param Directory $root |
|
46 | + * @param string $name |
|
47 | + */ |
|
48 | + public function __construct(Directory $root, $name) { |
|
49 | + $this->root = $root; |
|
50 | + $this->name = $name; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @inheritdoc |
|
55 | - */ |
|
56 | - public function put($data) { |
|
57 | - throw new Forbidden('Permission denied to put into this file'); |
|
58 | - } |
|
53 | + /** |
|
54 | + * @inheritdoc |
|
55 | + */ |
|
56 | + public function put($data) { |
|
57 | + throw new Forbidden('Permission denied to put into this file'); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @inheritdoc |
|
62 | - */ |
|
63 | - public function get() { |
|
64 | - $nodes = $this->root->getChildren(); |
|
65 | - return AssemblyStream::wrap($nodes); |
|
66 | - } |
|
60 | + /** |
|
61 | + * @inheritdoc |
|
62 | + */ |
|
63 | + public function get() { |
|
64 | + $nodes = $this->root->getChildren(); |
|
65 | + return AssemblyStream::wrap($nodes); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @inheritdoc |
|
70 | - */ |
|
71 | - public function getContentType() { |
|
72 | - return 'application/octet-stream'; |
|
73 | - } |
|
68 | + /** |
|
69 | + * @inheritdoc |
|
70 | + */ |
|
71 | + public function getContentType() { |
|
72 | + return 'application/octet-stream'; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @inheritdoc |
|
77 | - */ |
|
78 | - public function getETag() { |
|
79 | - return $this->root->getETag(); |
|
80 | - } |
|
75 | + /** |
|
76 | + * @inheritdoc |
|
77 | + */ |
|
78 | + public function getETag() { |
|
79 | + return $this->root->getETag(); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @inheritdoc |
|
84 | - */ |
|
85 | - public function getSize() { |
|
86 | - $children = $this->root->getChildren(); |
|
87 | - $sizes = array_map(function ($node) { |
|
88 | - /** @var IFile $node */ |
|
89 | - return $node->getSize(); |
|
90 | - }, $children); |
|
82 | + /** |
|
83 | + * @inheritdoc |
|
84 | + */ |
|
85 | + public function getSize() { |
|
86 | + $children = $this->root->getChildren(); |
|
87 | + $sizes = array_map(function ($node) { |
|
88 | + /** @var IFile $node */ |
|
89 | + return $node->getSize(); |
|
90 | + }, $children); |
|
91 | 91 | |
92 | - return array_sum($sizes); |
|
93 | - } |
|
92 | + return array_sum($sizes); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @inheritdoc |
|
97 | - */ |
|
98 | - public function delete() { |
|
99 | - $this->root->delete(); |
|
100 | - } |
|
95 | + /** |
|
96 | + * @inheritdoc |
|
97 | + */ |
|
98 | + public function delete() { |
|
99 | + $this->root->delete(); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @inheritdoc |
|
104 | - */ |
|
105 | - public function getName() { |
|
106 | - return $this->name; |
|
107 | - } |
|
102 | + /** |
|
103 | + * @inheritdoc |
|
104 | + */ |
|
105 | + public function getName() { |
|
106 | + return $this->name; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @inheritdoc |
|
111 | - */ |
|
112 | - public function setName($name) { |
|
113 | - throw new Forbidden('Permission denied to rename this file'); |
|
114 | - } |
|
109 | + /** |
|
110 | + * @inheritdoc |
|
111 | + */ |
|
112 | + public function setName($name) { |
|
113 | + throw new Forbidden('Permission denied to rename this file'); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * @inheritdoc |
|
118 | - */ |
|
119 | - public function getLastModified() { |
|
120 | - return $this->root->getLastModified(); |
|
121 | - } |
|
116 | + /** |
|
117 | + * @inheritdoc |
|
118 | + */ |
|
119 | + public function getLastModified() { |
|
120 | + return $this->root->getLastModified(); |
|
121 | + } |
|
122 | 122 | } |
@@ -31,35 +31,35 @@ |
||
31 | 31 | */ |
32 | 32 | class DeleteOrphanedSharesJob extends TimedJob { |
33 | 33 | |
34 | - /** |
|
35 | - * Default interval in minutes |
|
36 | - * |
|
37 | - * @var int $defaultIntervalMin |
|
38 | - **/ |
|
39 | - protected $defaultIntervalMin = 15; |
|
34 | + /** |
|
35 | + * Default interval in minutes |
|
36 | + * |
|
37 | + * @var int $defaultIntervalMin |
|
38 | + **/ |
|
39 | + protected $defaultIntervalMin = 15; |
|
40 | 40 | |
41 | - /** |
|
42 | - * sets the correct interval for this timed job |
|
43 | - */ |
|
44 | - public function __construct() { |
|
45 | - $this->interval = $this->defaultIntervalMin * 60; |
|
46 | - } |
|
41 | + /** |
|
42 | + * sets the correct interval for this timed job |
|
43 | + */ |
|
44 | + public function __construct() { |
|
45 | + $this->interval = $this->defaultIntervalMin * 60; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Makes the background job do its work |
|
50 | - * |
|
51 | - * @param array $argument unused argument |
|
52 | - */ |
|
53 | - public function run($argument) { |
|
54 | - $connection = \OC::$server->getDatabaseConnection(); |
|
55 | - $logger = \OC::$server->getLogger(); |
|
48 | + /** |
|
49 | + * Makes the background job do its work |
|
50 | + * |
|
51 | + * @param array $argument unused argument |
|
52 | + */ |
|
53 | + public function run($argument) { |
|
54 | + $connection = \OC::$server->getDatabaseConnection(); |
|
55 | + $logger = \OC::$server->getLogger(); |
|
56 | 56 | |
57 | - $sql = |
|
58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
60 | - 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
57 | + $sql = |
|
58 | + 'DELETE FROM `*PREFIX*share` ' . |
|
59 | + 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
60 | + 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
61 | 61 | |
62 | - $deletedEntries = $connection->executeUpdate($sql); |
|
63 | - $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
64 | - } |
|
62 | + $deletedEntries = $connection->executeUpdate($sql); |
|
63 | + $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
64 | + } |
|
65 | 65 | } |
@@ -33,167 +33,167 @@ |
||
33 | 33 | * Read-only access available, attempting to write will throw DomainException |
34 | 34 | */ |
35 | 35 | class UserGlobalStoragesService extends GlobalStoragesService { |
36 | - use UserTrait; |
|
37 | - |
|
38 | - /** @var IGroupManager */ |
|
39 | - protected $groupManager; |
|
40 | - |
|
41 | - /** |
|
42 | - * @param BackendService $backendService |
|
43 | - * @param DBConfigService $dbConfig |
|
44 | - * @param IUserSession $userSession |
|
45 | - * @param IGroupManager $groupManager |
|
46 | - * @param IUserMountCache $userMountCache |
|
47 | - */ |
|
48 | - public function __construct( |
|
49 | - BackendService $backendService, |
|
50 | - DBConfigService $dbConfig, |
|
51 | - IUserSession $userSession, |
|
52 | - IGroupManager $groupManager, |
|
53 | - IUserMountCache $userMountCache |
|
54 | - ) { |
|
55 | - parent::__construct($backendService, $dbConfig, $userMountCache); |
|
56 | - $this->userSession = $userSession; |
|
57 | - $this->groupManager = $groupManager; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Replace config hash ID with real IDs, for migrating legacy storages |
|
62 | - * |
|
63 | - * @param StorageConfig[] $storages Storages with real IDs |
|
64 | - * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs |
|
65 | - */ |
|
66 | - protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) { |
|
67 | - // as a read-only view, storage IDs don't need to be real |
|
68 | - foreach ($storagesWithConfigHash as $storage) { |
|
69 | - $storages[$storage->getId()] = $storage; |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - protected function readDBConfig() { |
|
74 | - $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID()); |
|
75 | - $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null); |
|
76 | - $groups = $this->groupManager->getUserGroupIds($this->getUser()); |
|
77 | - if (is_array($groups) && count($groups) !== 0) { |
|
78 | - $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups); |
|
79 | - } else { |
|
80 | - $groupMounts = []; |
|
81 | - } |
|
82 | - return array_merge($userMounts, $groupMounts, $globalMounts); |
|
83 | - } |
|
84 | - |
|
85 | - public function addStorage(StorageConfig $newStorage) { |
|
86 | - throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
87 | - } |
|
88 | - |
|
89 | - public function updateStorage(StorageConfig $updatedStorage) { |
|
90 | - throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param integer $id |
|
95 | - */ |
|
96 | - public function removeStorage($id) { |
|
97 | - throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Get unique storages, in case two are defined with the same mountpoint |
|
102 | - * Higher priority storages take precedence |
|
103 | - * |
|
104 | - * @return StorageConfig[] |
|
105 | - */ |
|
106 | - public function getUniqueStorages() { |
|
107 | - $storages = $this->getStorages(); |
|
108 | - |
|
109 | - $storagesByMountpoint = []; |
|
110 | - foreach ($storages as $storage) { |
|
111 | - $storagesByMountpoint[$storage->getMountPoint()][] = $storage; |
|
112 | - } |
|
113 | - |
|
114 | - $result = []; |
|
115 | - foreach ($storagesByMountpoint as $storageList) { |
|
116 | - $storage = array_reduce($storageList, function ($carry, $item) { |
|
117 | - if (isset($carry)) { |
|
118 | - $carryPriorityType = $this->getPriorityType($carry); |
|
119 | - $itemPriorityType = $this->getPriorityType($item); |
|
120 | - if ($carryPriorityType > $itemPriorityType) { |
|
121 | - return $carry; |
|
122 | - } elseif ($carryPriorityType === $itemPriorityType) { |
|
123 | - if ($carry->getPriority() > $item->getPriority()) { |
|
124 | - return $carry; |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
128 | - return $item; |
|
129 | - }); |
|
130 | - $result[$storage->getID()] = $storage; |
|
131 | - } |
|
132 | - |
|
133 | - return $result; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Get a priority 'type', where a bigger number means higher priority |
|
138 | - * user applicable > group applicable > 'all' |
|
139 | - * |
|
140 | - * @param StorageConfig $storage |
|
141 | - * @return int |
|
142 | - */ |
|
143 | - protected function getPriorityType(StorageConfig $storage) { |
|
144 | - $applicableUsers = $storage->getApplicableUsers(); |
|
145 | - $applicableGroups = $storage->getApplicableGroups(); |
|
146 | - |
|
147 | - if ($applicableUsers && $applicableUsers[0] !== 'all') { |
|
148 | - return 2; |
|
149 | - } |
|
150 | - if ($applicableGroups) { |
|
151 | - return 1; |
|
152 | - } |
|
153 | - return 0; |
|
154 | - } |
|
155 | - |
|
156 | - protected function isApplicable(StorageConfig $config) { |
|
157 | - $applicableUsers = $config->getApplicableUsers(); |
|
158 | - $applicableGroups = $config->getApplicableGroups(); |
|
159 | - |
|
160 | - if (count($applicableUsers) === 0 && count($applicableGroups) === 0) { |
|
161 | - return true; |
|
162 | - } |
|
163 | - if (in_array($this->getUser()->getUID(), $applicableUsers, true)) { |
|
164 | - return true; |
|
165 | - } |
|
166 | - $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
167 | - foreach ($groupIds as $groupId) { |
|
168 | - if (in_array($groupId, $applicableGroups, true)) { |
|
169 | - return true; |
|
170 | - } |
|
171 | - } |
|
172 | - return false; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * Gets all storages for the user, admin, personal, global, etc |
|
178 | - * |
|
179 | - * @return StorageConfig[] array of storage configs |
|
180 | - */ |
|
181 | - public function getAllStoragesForUser() { |
|
182 | - if (is_null($this->getUser())) { |
|
183 | - return []; |
|
184 | - } |
|
185 | - $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
186 | - $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds); |
|
187 | - $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
188 | - $configs = array_filter($configs, function ($config) { |
|
189 | - return $config instanceof StorageConfig; |
|
190 | - }); |
|
191 | - |
|
192 | - $keys = array_map(function (StorageConfig $config) { |
|
193 | - return $config->getId(); |
|
194 | - }, $configs); |
|
195 | - |
|
196 | - $storages = array_combine($keys, $configs); |
|
197 | - return array_filter($storages, [$this, 'validateStorage']); |
|
198 | - } |
|
36 | + use UserTrait; |
|
37 | + |
|
38 | + /** @var IGroupManager */ |
|
39 | + protected $groupManager; |
|
40 | + |
|
41 | + /** |
|
42 | + * @param BackendService $backendService |
|
43 | + * @param DBConfigService $dbConfig |
|
44 | + * @param IUserSession $userSession |
|
45 | + * @param IGroupManager $groupManager |
|
46 | + * @param IUserMountCache $userMountCache |
|
47 | + */ |
|
48 | + public function __construct( |
|
49 | + BackendService $backendService, |
|
50 | + DBConfigService $dbConfig, |
|
51 | + IUserSession $userSession, |
|
52 | + IGroupManager $groupManager, |
|
53 | + IUserMountCache $userMountCache |
|
54 | + ) { |
|
55 | + parent::__construct($backendService, $dbConfig, $userMountCache); |
|
56 | + $this->userSession = $userSession; |
|
57 | + $this->groupManager = $groupManager; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Replace config hash ID with real IDs, for migrating legacy storages |
|
62 | + * |
|
63 | + * @param StorageConfig[] $storages Storages with real IDs |
|
64 | + * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs |
|
65 | + */ |
|
66 | + protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) { |
|
67 | + // as a read-only view, storage IDs don't need to be real |
|
68 | + foreach ($storagesWithConfigHash as $storage) { |
|
69 | + $storages[$storage->getId()] = $storage; |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + protected function readDBConfig() { |
|
74 | + $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID()); |
|
75 | + $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null); |
|
76 | + $groups = $this->groupManager->getUserGroupIds($this->getUser()); |
|
77 | + if (is_array($groups) && count($groups) !== 0) { |
|
78 | + $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups); |
|
79 | + } else { |
|
80 | + $groupMounts = []; |
|
81 | + } |
|
82 | + return array_merge($userMounts, $groupMounts, $globalMounts); |
|
83 | + } |
|
84 | + |
|
85 | + public function addStorage(StorageConfig $newStorage) { |
|
86 | + throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
87 | + } |
|
88 | + |
|
89 | + public function updateStorage(StorageConfig $updatedStorage) { |
|
90 | + throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param integer $id |
|
95 | + */ |
|
96 | + public function removeStorage($id) { |
|
97 | + throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Get unique storages, in case two are defined with the same mountpoint |
|
102 | + * Higher priority storages take precedence |
|
103 | + * |
|
104 | + * @return StorageConfig[] |
|
105 | + */ |
|
106 | + public function getUniqueStorages() { |
|
107 | + $storages = $this->getStorages(); |
|
108 | + |
|
109 | + $storagesByMountpoint = []; |
|
110 | + foreach ($storages as $storage) { |
|
111 | + $storagesByMountpoint[$storage->getMountPoint()][] = $storage; |
|
112 | + } |
|
113 | + |
|
114 | + $result = []; |
|
115 | + foreach ($storagesByMountpoint as $storageList) { |
|
116 | + $storage = array_reduce($storageList, function ($carry, $item) { |
|
117 | + if (isset($carry)) { |
|
118 | + $carryPriorityType = $this->getPriorityType($carry); |
|
119 | + $itemPriorityType = $this->getPriorityType($item); |
|
120 | + if ($carryPriorityType > $itemPriorityType) { |
|
121 | + return $carry; |
|
122 | + } elseif ($carryPriorityType === $itemPriorityType) { |
|
123 | + if ($carry->getPriority() > $item->getPriority()) { |
|
124 | + return $carry; |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | + return $item; |
|
129 | + }); |
|
130 | + $result[$storage->getID()] = $storage; |
|
131 | + } |
|
132 | + |
|
133 | + return $result; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Get a priority 'type', where a bigger number means higher priority |
|
138 | + * user applicable > group applicable > 'all' |
|
139 | + * |
|
140 | + * @param StorageConfig $storage |
|
141 | + * @return int |
|
142 | + */ |
|
143 | + protected function getPriorityType(StorageConfig $storage) { |
|
144 | + $applicableUsers = $storage->getApplicableUsers(); |
|
145 | + $applicableGroups = $storage->getApplicableGroups(); |
|
146 | + |
|
147 | + if ($applicableUsers && $applicableUsers[0] !== 'all') { |
|
148 | + return 2; |
|
149 | + } |
|
150 | + if ($applicableGroups) { |
|
151 | + return 1; |
|
152 | + } |
|
153 | + return 0; |
|
154 | + } |
|
155 | + |
|
156 | + protected function isApplicable(StorageConfig $config) { |
|
157 | + $applicableUsers = $config->getApplicableUsers(); |
|
158 | + $applicableGroups = $config->getApplicableGroups(); |
|
159 | + |
|
160 | + if (count($applicableUsers) === 0 && count($applicableGroups) === 0) { |
|
161 | + return true; |
|
162 | + } |
|
163 | + if (in_array($this->getUser()->getUID(), $applicableUsers, true)) { |
|
164 | + return true; |
|
165 | + } |
|
166 | + $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
167 | + foreach ($groupIds as $groupId) { |
|
168 | + if (in_array($groupId, $applicableGroups, true)) { |
|
169 | + return true; |
|
170 | + } |
|
171 | + } |
|
172 | + return false; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * Gets all storages for the user, admin, personal, global, etc |
|
178 | + * |
|
179 | + * @return StorageConfig[] array of storage configs |
|
180 | + */ |
|
181 | + public function getAllStoragesForUser() { |
|
182 | + if (is_null($this->getUser())) { |
|
183 | + return []; |
|
184 | + } |
|
185 | + $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
186 | + $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds); |
|
187 | + $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
188 | + $configs = array_filter($configs, function ($config) { |
|
189 | + return $config instanceof StorageConfig; |
|
190 | + }); |
|
191 | + |
|
192 | + $keys = array_map(function (StorageConfig $config) { |
|
193 | + return $config->getId(); |
|
194 | + }, $configs); |
|
195 | + |
|
196 | + $storages = array_combine($keys, $configs); |
|
197 | + return array_filter($storages, [$this, 'validateStorage']); |
|
198 | + } |
|
199 | 199 | } |
@@ -29,31 +29,31 @@ |
||
29 | 29 | */ |
30 | 30 | trait PriorityTrait { |
31 | 31 | |
32 | - /** @var int initial priority */ |
|
33 | - protected $priority = BackendService::PRIORITY_DEFAULT; |
|
32 | + /** @var int initial priority */ |
|
33 | + protected $priority = BackendService::PRIORITY_DEFAULT; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return int |
|
37 | - */ |
|
38 | - public function getPriority() { |
|
39 | - return $this->priority; |
|
40 | - } |
|
35 | + /** |
|
36 | + * @return int |
|
37 | + */ |
|
38 | + public function getPriority() { |
|
39 | + return $this->priority; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param int $priority |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public function setPriority($priority) { |
|
47 | - $this->priority = $priority; |
|
48 | - return $this; |
|
49 | - } |
|
42 | + /** |
|
43 | + * @param int $priority |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public function setPriority($priority) { |
|
47 | + $this->priority = $priority; |
|
48 | + return $this; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param PriorityTrait $a |
|
53 | - * @param PriorityTrait $b |
|
54 | - * @return int |
|
55 | - */ |
|
56 | - public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | - return ($a->getPriority() - $b->getPriority()); |
|
58 | - } |
|
51 | + /** |
|
52 | + * @param PriorityTrait $a |
|
53 | + * @param PriorityTrait $b |
|
54 | + * @return int |
|
55 | + */ |
|
56 | + public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | + return ($a->getPriority() - $b->getPriority()); |
|
58 | + } |
|
59 | 59 | } |