@@ -33,128 +33,128 @@ |
||
33 | 33 | use Symfony\Component\Routing\Route as SymfonyRoute; |
34 | 34 | |
35 | 35 | class Route extends SymfonyRoute implements IRoute { |
36 | - /** |
|
37 | - * Specify the method when this route is to be used |
|
38 | - * |
|
39 | - * @param string $method HTTP method (uppercase) |
|
40 | - * @return \OC\Route\Route |
|
41 | - */ |
|
42 | - public function method($method) { |
|
43 | - $this->setMethods($method); |
|
44 | - return $this; |
|
45 | - } |
|
36 | + /** |
|
37 | + * Specify the method when this route is to be used |
|
38 | + * |
|
39 | + * @param string $method HTTP method (uppercase) |
|
40 | + * @return \OC\Route\Route |
|
41 | + */ |
|
42 | + public function method($method) { |
|
43 | + $this->setMethods($method); |
|
44 | + return $this; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Specify POST as the method to use with this route |
|
49 | - * @return \OC\Route\Route |
|
50 | - */ |
|
51 | - public function post() { |
|
52 | - $this->method('POST'); |
|
53 | - return $this; |
|
54 | - } |
|
47 | + /** |
|
48 | + * Specify POST as the method to use with this route |
|
49 | + * @return \OC\Route\Route |
|
50 | + */ |
|
51 | + public function post() { |
|
52 | + $this->method('POST'); |
|
53 | + return $this; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Specify GET as the method to use with this route |
|
58 | - * @return \OC\Route\Route |
|
59 | - */ |
|
60 | - public function get() { |
|
61 | - $this->method('GET'); |
|
62 | - return $this; |
|
63 | - } |
|
56 | + /** |
|
57 | + * Specify GET as the method to use with this route |
|
58 | + * @return \OC\Route\Route |
|
59 | + */ |
|
60 | + public function get() { |
|
61 | + $this->method('GET'); |
|
62 | + return $this; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Specify PUT as the method to use with this route |
|
67 | - * @return \OC\Route\Route |
|
68 | - */ |
|
69 | - public function put() { |
|
70 | - $this->method('PUT'); |
|
71 | - return $this; |
|
72 | - } |
|
65 | + /** |
|
66 | + * Specify PUT as the method to use with this route |
|
67 | + * @return \OC\Route\Route |
|
68 | + */ |
|
69 | + public function put() { |
|
70 | + $this->method('PUT'); |
|
71 | + return $this; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Specify DELETE as the method to use with this route |
|
76 | - * @return \OC\Route\Route |
|
77 | - */ |
|
78 | - public function delete() { |
|
79 | - $this->method('DELETE'); |
|
80 | - return $this; |
|
81 | - } |
|
74 | + /** |
|
75 | + * Specify DELETE as the method to use with this route |
|
76 | + * @return \OC\Route\Route |
|
77 | + */ |
|
78 | + public function delete() { |
|
79 | + $this->method('DELETE'); |
|
80 | + return $this; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Specify PATCH as the method to use with this route |
|
85 | - * @return \OC\Route\Route |
|
86 | - */ |
|
87 | - public function patch() { |
|
88 | - $this->method('PATCH'); |
|
89 | - return $this; |
|
90 | - } |
|
83 | + /** |
|
84 | + * Specify PATCH as the method to use with this route |
|
85 | + * @return \OC\Route\Route |
|
86 | + */ |
|
87 | + public function patch() { |
|
88 | + $this->method('PATCH'); |
|
89 | + return $this; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Defaults to use for this route |
|
94 | - * |
|
95 | - * @param array $defaults The defaults |
|
96 | - * @return \OC\Route\Route |
|
97 | - */ |
|
98 | - public function defaults($defaults) { |
|
99 | - $action = $this->getDefault('action'); |
|
100 | - $this->setDefaults($defaults); |
|
101 | - if (isset($defaults['action'])) { |
|
102 | - $action = $defaults['action']; |
|
103 | - } |
|
104 | - $this->action($action); |
|
105 | - return $this; |
|
106 | - } |
|
92 | + /** |
|
93 | + * Defaults to use for this route |
|
94 | + * |
|
95 | + * @param array $defaults The defaults |
|
96 | + * @return \OC\Route\Route |
|
97 | + */ |
|
98 | + public function defaults($defaults) { |
|
99 | + $action = $this->getDefault('action'); |
|
100 | + $this->setDefaults($defaults); |
|
101 | + if (isset($defaults['action'])) { |
|
102 | + $action = $defaults['action']; |
|
103 | + } |
|
104 | + $this->action($action); |
|
105 | + return $this; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Requirements for this route |
|
110 | - * |
|
111 | - * @param array $requirements The requirements |
|
112 | - * @return \OC\Route\Route |
|
113 | - */ |
|
114 | - public function requirements($requirements) { |
|
115 | - $method = $this->getMethods(); |
|
116 | - $this->setRequirements($requirements); |
|
117 | - if (isset($requirements['_method'])) { |
|
118 | - $method = $requirements['_method']; |
|
119 | - } |
|
120 | - if ($method) { |
|
121 | - $this->method($method); |
|
122 | - } |
|
123 | - return $this; |
|
124 | - } |
|
108 | + /** |
|
109 | + * Requirements for this route |
|
110 | + * |
|
111 | + * @param array $requirements The requirements |
|
112 | + * @return \OC\Route\Route |
|
113 | + */ |
|
114 | + public function requirements($requirements) { |
|
115 | + $method = $this->getMethods(); |
|
116 | + $this->setRequirements($requirements); |
|
117 | + if (isset($requirements['_method'])) { |
|
118 | + $method = $requirements['_method']; |
|
119 | + } |
|
120 | + if ($method) { |
|
121 | + $this->method($method); |
|
122 | + } |
|
123 | + return $this; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * The action to execute when this route matches |
|
128 | - * |
|
129 | - * @param string|callable $class the class or a callable |
|
130 | - * @param string $function the function to use with the class |
|
131 | - * @return \OC\Route\Route |
|
132 | - * |
|
133 | - * This function is called with $class set to a callable or |
|
134 | - * to the class with $function |
|
135 | - */ |
|
136 | - public function action($class, $function = null) { |
|
137 | - $action = [$class, $function]; |
|
138 | - if (is_null($function)) { |
|
139 | - $action = $class; |
|
140 | - } |
|
141 | - $this->setDefault('action', $action); |
|
142 | - return $this; |
|
143 | - } |
|
126 | + /** |
|
127 | + * The action to execute when this route matches |
|
128 | + * |
|
129 | + * @param string|callable $class the class or a callable |
|
130 | + * @param string $function the function to use with the class |
|
131 | + * @return \OC\Route\Route |
|
132 | + * |
|
133 | + * This function is called with $class set to a callable or |
|
134 | + * to the class with $function |
|
135 | + */ |
|
136 | + public function action($class, $function = null) { |
|
137 | + $action = [$class, $function]; |
|
138 | + if (is_null($function)) { |
|
139 | + $action = $class; |
|
140 | + } |
|
141 | + $this->setDefault('action', $action); |
|
142 | + return $this; |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * The action to execute when this route matches, includes a file like |
|
147 | - * it is called directly |
|
148 | - * @param string $file |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - public function actionInclude($file) { |
|
152 | - $function = function ($param) use ($file) { |
|
153 | - unset($param["_route"]); |
|
154 | - $_GET = array_merge($_GET, $param); |
|
155 | - unset($param); |
|
156 | - require_once "$file"; |
|
157 | - } ; |
|
158 | - $this->action($function); |
|
159 | - } |
|
145 | + /** |
|
146 | + * The action to execute when this route matches, includes a file like |
|
147 | + * it is called directly |
|
148 | + * @param string $file |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + public function actionInclude($file) { |
|
152 | + $function = function ($param) use ($file) { |
|
153 | + unset($param["_route"]); |
|
154 | + $_GET = array_merge($_GET, $param); |
|
155 | + unset($param); |
|
156 | + require_once "$file"; |
|
157 | + } ; |
|
158 | + $this->action($function); |
|
159 | + } |
|
160 | 160 | } |
@@ -33,99 +33,99 @@ |
||
33 | 33 | use OCP\AppFramework\Http as BaseHttp; |
34 | 34 | |
35 | 35 | class Http extends BaseHttp { |
36 | - private $server; |
|
37 | - private $protocolVersion; |
|
38 | - protected $headers; |
|
36 | + private $server; |
|
37 | + private $protocolVersion; |
|
38 | + protected $headers; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param array $server $_SERVER |
|
42 | - * @param string $protocolVersion the http version to use defaults to HTTP/1.1 |
|
43 | - */ |
|
44 | - public function __construct($server, $protocolVersion = 'HTTP/1.1') { |
|
45 | - $this->server = $server; |
|
46 | - $this->protocolVersion = $protocolVersion; |
|
40 | + /** |
|
41 | + * @param array $server $_SERVER |
|
42 | + * @param string $protocolVersion the http version to use defaults to HTTP/1.1 |
|
43 | + */ |
|
44 | + public function __construct($server, $protocolVersion = 'HTTP/1.1') { |
|
45 | + $this->server = $server; |
|
46 | + $this->protocolVersion = $protocolVersion; |
|
47 | 47 | |
48 | - $this->headers = [ |
|
49 | - self::STATUS_CONTINUE => 'Continue', |
|
50 | - self::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols', |
|
51 | - self::STATUS_PROCESSING => 'Processing', |
|
52 | - self::STATUS_OK => 'OK', |
|
53 | - self::STATUS_CREATED => 'Created', |
|
54 | - self::STATUS_ACCEPTED => 'Accepted', |
|
55 | - self::STATUS_NON_AUTHORATIVE_INFORMATION => 'Non-Authorative Information', |
|
56 | - self::STATUS_NO_CONTENT => 'No Content', |
|
57 | - self::STATUS_RESET_CONTENT => 'Reset Content', |
|
58 | - self::STATUS_PARTIAL_CONTENT => 'Partial Content', |
|
59 | - self::STATUS_MULTI_STATUS => 'Multi-Status', // RFC 4918 |
|
60 | - self::STATUS_ALREADY_REPORTED => 'Already Reported', // RFC 5842 |
|
61 | - self::STATUS_IM_USED => 'IM Used', // RFC 3229 |
|
62 | - self::STATUS_MULTIPLE_CHOICES => 'Multiple Choices', |
|
63 | - self::STATUS_MOVED_PERMANENTLY => 'Moved Permanently', |
|
64 | - self::STATUS_FOUND => 'Found', |
|
65 | - self::STATUS_SEE_OTHER => 'See Other', |
|
66 | - self::STATUS_NOT_MODIFIED => 'Not Modified', |
|
67 | - self::STATUS_USE_PROXY => 'Use Proxy', |
|
68 | - self::STATUS_RESERVED => 'Reserved', |
|
69 | - self::STATUS_TEMPORARY_REDIRECT => 'Temporary Redirect', |
|
70 | - self::STATUS_BAD_REQUEST => 'Bad request', |
|
71 | - self::STATUS_UNAUTHORIZED => 'Unauthorized', |
|
72 | - self::STATUS_PAYMENT_REQUIRED => 'Payment Required', |
|
73 | - self::STATUS_FORBIDDEN => 'Forbidden', |
|
74 | - self::STATUS_NOT_FOUND => 'Not Found', |
|
75 | - self::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed', |
|
76 | - self::STATUS_NOT_ACCEPTABLE => 'Not Acceptable', |
|
77 | - self::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required', |
|
78 | - self::STATUS_REQUEST_TIMEOUT => 'Request Timeout', |
|
79 | - self::STATUS_CONFLICT => 'Conflict', |
|
80 | - self::STATUS_GONE => 'Gone', |
|
81 | - self::STATUS_LENGTH_REQUIRED => 'Length Required', |
|
82 | - self::STATUS_PRECONDITION_FAILED => 'Precondition failed', |
|
83 | - self::STATUS_REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large', |
|
84 | - self::STATUS_REQUEST_URI_TOO_LONG => 'Request-URI Too Long', |
|
85 | - self::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type', |
|
86 | - self::STATUS_REQUEST_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable', |
|
87 | - self::STATUS_EXPECTATION_FAILED => 'Expectation Failed', |
|
88 | - self::STATUS_IM_A_TEAPOT => 'I\'m a teapot', // RFC 2324 |
|
89 | - self::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', // RFC 4918 |
|
90 | - self::STATUS_LOCKED => 'Locked', // RFC 4918 |
|
91 | - self::STATUS_FAILED_DEPENDENCY => 'Failed Dependency', // RFC 4918 |
|
92 | - self::STATUS_UPGRADE_REQUIRED => 'Upgrade required', |
|
93 | - self::STATUS_PRECONDITION_REQUIRED => 'Precondition required', // draft-nottingham-http-new-status |
|
94 | - self::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests', // draft-nottingham-http-new-status |
|
95 | - self::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', // draft-nottingham-http-new-status |
|
96 | - self::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error', |
|
97 | - self::STATUS_NOT_IMPLEMENTED => 'Not Implemented', |
|
98 | - self::STATUS_BAD_GATEWAY => 'Bad Gateway', |
|
99 | - self::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable', |
|
100 | - self::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout', |
|
101 | - self::STATUS_HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported', |
|
102 | - self::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates', |
|
103 | - self::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage', // RFC 4918 |
|
104 | - self::STATUS_LOOP_DETECTED => 'Loop Detected', // RFC 5842 |
|
105 | - self::STATUS_BANDWIDTH_LIMIT_EXCEEDED => 'Bandwidth Limit Exceeded', // non-standard |
|
106 | - self::STATUS_NOT_EXTENDED => 'Not extended', |
|
107 | - self::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', // draft-nottingham-http-new-status |
|
108 | - ]; |
|
109 | - } |
|
48 | + $this->headers = [ |
|
49 | + self::STATUS_CONTINUE => 'Continue', |
|
50 | + self::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols', |
|
51 | + self::STATUS_PROCESSING => 'Processing', |
|
52 | + self::STATUS_OK => 'OK', |
|
53 | + self::STATUS_CREATED => 'Created', |
|
54 | + self::STATUS_ACCEPTED => 'Accepted', |
|
55 | + self::STATUS_NON_AUTHORATIVE_INFORMATION => 'Non-Authorative Information', |
|
56 | + self::STATUS_NO_CONTENT => 'No Content', |
|
57 | + self::STATUS_RESET_CONTENT => 'Reset Content', |
|
58 | + self::STATUS_PARTIAL_CONTENT => 'Partial Content', |
|
59 | + self::STATUS_MULTI_STATUS => 'Multi-Status', // RFC 4918 |
|
60 | + self::STATUS_ALREADY_REPORTED => 'Already Reported', // RFC 5842 |
|
61 | + self::STATUS_IM_USED => 'IM Used', // RFC 3229 |
|
62 | + self::STATUS_MULTIPLE_CHOICES => 'Multiple Choices', |
|
63 | + self::STATUS_MOVED_PERMANENTLY => 'Moved Permanently', |
|
64 | + self::STATUS_FOUND => 'Found', |
|
65 | + self::STATUS_SEE_OTHER => 'See Other', |
|
66 | + self::STATUS_NOT_MODIFIED => 'Not Modified', |
|
67 | + self::STATUS_USE_PROXY => 'Use Proxy', |
|
68 | + self::STATUS_RESERVED => 'Reserved', |
|
69 | + self::STATUS_TEMPORARY_REDIRECT => 'Temporary Redirect', |
|
70 | + self::STATUS_BAD_REQUEST => 'Bad request', |
|
71 | + self::STATUS_UNAUTHORIZED => 'Unauthorized', |
|
72 | + self::STATUS_PAYMENT_REQUIRED => 'Payment Required', |
|
73 | + self::STATUS_FORBIDDEN => 'Forbidden', |
|
74 | + self::STATUS_NOT_FOUND => 'Not Found', |
|
75 | + self::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed', |
|
76 | + self::STATUS_NOT_ACCEPTABLE => 'Not Acceptable', |
|
77 | + self::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required', |
|
78 | + self::STATUS_REQUEST_TIMEOUT => 'Request Timeout', |
|
79 | + self::STATUS_CONFLICT => 'Conflict', |
|
80 | + self::STATUS_GONE => 'Gone', |
|
81 | + self::STATUS_LENGTH_REQUIRED => 'Length Required', |
|
82 | + self::STATUS_PRECONDITION_FAILED => 'Precondition failed', |
|
83 | + self::STATUS_REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large', |
|
84 | + self::STATUS_REQUEST_URI_TOO_LONG => 'Request-URI Too Long', |
|
85 | + self::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type', |
|
86 | + self::STATUS_REQUEST_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable', |
|
87 | + self::STATUS_EXPECTATION_FAILED => 'Expectation Failed', |
|
88 | + self::STATUS_IM_A_TEAPOT => 'I\'m a teapot', // RFC 2324 |
|
89 | + self::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', // RFC 4918 |
|
90 | + self::STATUS_LOCKED => 'Locked', // RFC 4918 |
|
91 | + self::STATUS_FAILED_DEPENDENCY => 'Failed Dependency', // RFC 4918 |
|
92 | + self::STATUS_UPGRADE_REQUIRED => 'Upgrade required', |
|
93 | + self::STATUS_PRECONDITION_REQUIRED => 'Precondition required', // draft-nottingham-http-new-status |
|
94 | + self::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests', // draft-nottingham-http-new-status |
|
95 | + self::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', // draft-nottingham-http-new-status |
|
96 | + self::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error', |
|
97 | + self::STATUS_NOT_IMPLEMENTED => 'Not Implemented', |
|
98 | + self::STATUS_BAD_GATEWAY => 'Bad Gateway', |
|
99 | + self::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable', |
|
100 | + self::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout', |
|
101 | + self::STATUS_HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported', |
|
102 | + self::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates', |
|
103 | + self::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage', // RFC 4918 |
|
104 | + self::STATUS_LOOP_DETECTED => 'Loop Detected', // RFC 5842 |
|
105 | + self::STATUS_BANDWIDTH_LIMIT_EXCEEDED => 'Bandwidth Limit Exceeded', // non-standard |
|
106 | + self::STATUS_NOT_EXTENDED => 'Not extended', |
|
107 | + self::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', // draft-nottingham-http-new-status |
|
108 | + ]; |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * Gets the correct header |
|
114 | - * @param int Http::CONSTANT $status the constant from the Http class |
|
115 | - * @param \DateTime $lastModified formatted last modified date |
|
116 | - * @param string $ETag the etag |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function getStatusHeader($status) { |
|
120 | - // we have one change currently for the http 1.0 header that differs |
|
121 | - // from 1.1: STATUS_TEMPORARY_REDIRECT should be STATUS_FOUND |
|
122 | - // if this differs any more, we want to create childclasses for this |
|
123 | - if ($status === self::STATUS_TEMPORARY_REDIRECT |
|
124 | - && $this->protocolVersion === 'HTTP/1.0') { |
|
125 | - $status = self::STATUS_FOUND; |
|
126 | - } |
|
112 | + /** |
|
113 | + * Gets the correct header |
|
114 | + * @param int Http::CONSTANT $status the constant from the Http class |
|
115 | + * @param \DateTime $lastModified formatted last modified date |
|
116 | + * @param string $ETag the etag |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function getStatusHeader($status) { |
|
120 | + // we have one change currently for the http 1.0 header that differs |
|
121 | + // from 1.1: STATUS_TEMPORARY_REDIRECT should be STATUS_FOUND |
|
122 | + // if this differs any more, we want to create childclasses for this |
|
123 | + if ($status === self::STATUS_TEMPORARY_REDIRECT |
|
124 | + && $this->protocolVersion === 'HTTP/1.0') { |
|
125 | + $status = self::STATUS_FOUND; |
|
126 | + } |
|
127 | 127 | |
128 | - return $this->protocolVersion . ' ' . $status . ' ' . |
|
129 | - $this->headers[$status]; |
|
130 | - } |
|
128 | + return $this->protocolVersion . ' ' . $status . ' ' . |
|
129 | + $this->headers[$status]; |
|
130 | + } |
|
131 | 131 | } |
@@ -29,54 +29,54 @@ |
||
29 | 29 | use OCP\IServerContainer; |
30 | 30 | |
31 | 31 | class Manager implements IManager { |
32 | - /** @var string[] */ |
|
33 | - protected $sorters = []; |
|
32 | + /** @var string[] */ |
|
33 | + protected $sorters = []; |
|
34 | 34 | |
35 | - /** @var ISorter[] */ |
|
36 | - protected $sorterInstances = []; |
|
37 | - /** @var IServerContainer */ |
|
38 | - private $c; |
|
35 | + /** @var ISorter[] */ |
|
36 | + protected $sorterInstances = []; |
|
37 | + /** @var IServerContainer */ |
|
38 | + private $c; |
|
39 | 39 | |
40 | - public function __construct(IServerContainer $container) { |
|
41 | - $this->c = $container; |
|
42 | - } |
|
40 | + public function __construct(IServerContainer $container) { |
|
41 | + $this->c = $container; |
|
42 | + } |
|
43 | 43 | |
44 | - public function runSorters(array $sorters, array &$sortArray, array $context) { |
|
45 | - $sorterInstances = $this->getSorters(); |
|
46 | - while ($sorter = array_shift($sorters)) { |
|
47 | - if (isset($sorterInstances[$sorter])) { |
|
48 | - $sorterInstances[$sorter]->sort($sortArray, $context); |
|
49 | - } else { |
|
50 | - $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ |
|
51 | - 'app' => 'core', 'id' => $sorter |
|
52 | - ]); |
|
53 | - } |
|
54 | - } |
|
55 | - } |
|
44 | + public function runSorters(array $sorters, array &$sortArray, array $context) { |
|
45 | + $sorterInstances = $this->getSorters(); |
|
46 | + while ($sorter = array_shift($sorters)) { |
|
47 | + if (isset($sorterInstances[$sorter])) { |
|
48 | + $sorterInstances[$sorter]->sort($sortArray, $context); |
|
49 | + } else { |
|
50 | + $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ |
|
51 | + 'app' => 'core', 'id' => $sorter |
|
52 | + ]); |
|
53 | + } |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - public function registerSorter($className) { |
|
58 | - $this->sorters[] = $className; |
|
59 | - } |
|
57 | + public function registerSorter($className) { |
|
58 | + $this->sorters[] = $className; |
|
59 | + } |
|
60 | 60 | |
61 | - protected function getSorters() { |
|
62 | - if (count($this->sorterInstances) === 0) { |
|
63 | - foreach ($this->sorters as $sorter) { |
|
64 | - /** @var ISorter $instance */ |
|
65 | - $instance = $this->c->resolve($sorter); |
|
66 | - if (!$instance instanceof ISorter) { |
|
67 | - $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', |
|
68 | - ['app' => 'core', 'class' => $sorter]); |
|
69 | - continue; |
|
70 | - } |
|
71 | - $sorterId = trim($instance->getId()); |
|
72 | - if (trim($sorterId) === '') { |
|
73 | - $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', |
|
74 | - ['app' => 'core', 'class' => $sorter]); |
|
75 | - continue; |
|
76 | - } |
|
77 | - $this->sorterInstances[$sorterId] = $instance; |
|
78 | - } |
|
79 | - } |
|
80 | - return $this->sorterInstances; |
|
81 | - } |
|
61 | + protected function getSorters() { |
|
62 | + if (count($this->sorterInstances) === 0) { |
|
63 | + foreach ($this->sorters as $sorter) { |
|
64 | + /** @var ISorter $instance */ |
|
65 | + $instance = $this->c->resolve($sorter); |
|
66 | + if (!$instance instanceof ISorter) { |
|
67 | + $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', |
|
68 | + ['app' => 'core', 'class' => $sorter]); |
|
69 | + continue; |
|
70 | + } |
|
71 | + $sorterId = trim($instance->getId()); |
|
72 | + if (trim($sorterId) === '') { |
|
73 | + $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', |
|
74 | + ['app' => 'core', 'class' => $sorter]); |
|
75 | + continue; |
|
76 | + } |
|
77 | + $this->sorterInstances[$sorterId] = $instance; |
|
78 | + } |
|
79 | + } |
|
80 | + return $this->sorterInstances; |
|
81 | + } |
|
82 | 82 | } |
@@ -30,13 +30,13 @@ |
||
30 | 30 | * @since 14.0.0 |
31 | 31 | */ |
32 | 32 | interface IFileBased { |
33 | - /** |
|
34 | - * @since 14.0.0 |
|
35 | - */ |
|
36 | - public function getLogFilePath():string; |
|
33 | + /** |
|
34 | + * @since 14.0.0 |
|
35 | + */ |
|
36 | + public function getLogFilePath():string; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @since 14.0.0 |
|
40 | - */ |
|
41 | - public function getEntries(int $limit = 50, int $offset = 0): array; |
|
38 | + /** |
|
39 | + * @since 14.0.0 |
|
40 | + */ |
|
41 | + public function getEntries(int $limit = 50, int $offset = 0): array; |
|
42 | 42 | } |
@@ -34,98 +34,98 @@ |
||
34 | 34 | * @since 8.0.0 |
35 | 35 | */ |
36 | 36 | class Template extends \OC_Template { |
37 | - /** |
|
38 | - * Make OC_Helper::imagePath available as a simple function |
|
39 | - * |
|
40 | - * @see \OCP\IURLGenerator::imagePath |
|
41 | - * |
|
42 | - * @param string $app |
|
43 | - * @param string $image |
|
44 | - * @return string to the image |
|
45 | - * @since 8.0.0 |
|
46 | - * @suppress PhanDeprecatedFunction |
|
47 | - */ |
|
48 | - public static function image_path($app, $image) { |
|
49 | - return \image_path($app, $image); |
|
50 | - } |
|
37 | + /** |
|
38 | + * Make OC_Helper::imagePath available as a simple function |
|
39 | + * |
|
40 | + * @see \OCP\IURLGenerator::imagePath |
|
41 | + * |
|
42 | + * @param string $app |
|
43 | + * @param string $image |
|
44 | + * @return string to the image |
|
45 | + * @since 8.0.0 |
|
46 | + * @suppress PhanDeprecatedFunction |
|
47 | + */ |
|
48 | + public static function image_path($app, $image) { |
|
49 | + return \image_path($app, $image); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Make OC_Helper::mimetypeIcon available as a simple function |
|
55 | - * |
|
56 | - * @param string $mimetype |
|
57 | - * @return string to the image of this file type. |
|
58 | - * @since 8.0.0 |
|
59 | - * @suppress PhanDeprecatedFunction |
|
60 | - */ |
|
61 | - public static function mimetype_icon($mimetype) { |
|
62 | - return \mimetype_icon($mimetype); |
|
63 | - } |
|
53 | + /** |
|
54 | + * Make OC_Helper::mimetypeIcon available as a simple function |
|
55 | + * |
|
56 | + * @param string $mimetype |
|
57 | + * @return string to the image of this file type. |
|
58 | + * @since 8.0.0 |
|
59 | + * @suppress PhanDeprecatedFunction |
|
60 | + */ |
|
61 | + public static function mimetype_icon($mimetype) { |
|
62 | + return \mimetype_icon($mimetype); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Make preview_icon available as a simple function |
|
67 | - * |
|
68 | - * @param string $path path to file |
|
69 | - * @return string to the preview of the image |
|
70 | - * @since 8.0.0 |
|
71 | - * @suppress PhanDeprecatedFunction |
|
72 | - */ |
|
73 | - public static function preview_icon($path) { |
|
74 | - return \preview_icon($path); |
|
75 | - } |
|
65 | + /** |
|
66 | + * Make preview_icon available as a simple function |
|
67 | + * |
|
68 | + * @param string $path path to file |
|
69 | + * @return string to the preview of the image |
|
70 | + * @since 8.0.0 |
|
71 | + * @suppress PhanDeprecatedFunction |
|
72 | + */ |
|
73 | + public static function preview_icon($path) { |
|
74 | + return \preview_icon($path); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Make publicpreview_icon available as a simple function |
|
79 | - * Returns the path to the preview of the image. |
|
80 | - * |
|
81 | - * @param string $path of file |
|
82 | - * @param string $token |
|
83 | - * @return string link to the preview |
|
84 | - * @since 8.0.0 |
|
85 | - * @suppress PhanDeprecatedFunction |
|
86 | - */ |
|
87 | - public static function publicPreview_icon($path, $token) { |
|
88 | - return \publicPreview_icon($path, $token); |
|
89 | - } |
|
77 | + /** |
|
78 | + * Make publicpreview_icon available as a simple function |
|
79 | + * Returns the path to the preview of the image. |
|
80 | + * |
|
81 | + * @param string $path of file |
|
82 | + * @param string $token |
|
83 | + * @return string link to the preview |
|
84 | + * @since 8.0.0 |
|
85 | + * @suppress PhanDeprecatedFunction |
|
86 | + */ |
|
87 | + public static function publicPreview_icon($path, $token) { |
|
88 | + return \publicPreview_icon($path, $token); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Make OC_Helper::humanFileSize available as a simple function |
|
93 | - * Example: 2048 to 2 kB. |
|
94 | - * |
|
95 | - * @param int $bytes in bytes |
|
96 | - * @return string size as string |
|
97 | - * @since 8.0.0 |
|
98 | - * @suppress PhanDeprecatedFunction |
|
99 | - */ |
|
100 | - public static function human_file_size($bytes) { |
|
101 | - return \human_file_size($bytes); |
|
102 | - } |
|
91 | + /** |
|
92 | + * Make OC_Helper::humanFileSize available as a simple function |
|
93 | + * Example: 2048 to 2 kB. |
|
94 | + * |
|
95 | + * @param int $bytes in bytes |
|
96 | + * @return string size as string |
|
97 | + * @since 8.0.0 |
|
98 | + * @suppress PhanDeprecatedFunction |
|
99 | + */ |
|
100 | + public static function human_file_size($bytes) { |
|
101 | + return \human_file_size($bytes); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" |
|
106 | - * |
|
107 | - * @param int $timestamp unix timestamp |
|
108 | - * @param boolean $dateOnly |
|
109 | - * @return string human readable interpretation of the timestamp |
|
110 | - * @since 8.0.0 |
|
111 | - * @suppress PhanDeprecatedFunction |
|
112 | - * @suppress PhanTypeMismatchArgument |
|
113 | - */ |
|
114 | - public static function relative_modified_date($timestamp, $dateOnly = false) { |
|
115 | - return \relative_modified_date($timestamp, null, $dateOnly); |
|
116 | - } |
|
104 | + /** |
|
105 | + * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" |
|
106 | + * |
|
107 | + * @param int $timestamp unix timestamp |
|
108 | + * @param boolean $dateOnly |
|
109 | + * @return string human readable interpretation of the timestamp |
|
110 | + * @since 8.0.0 |
|
111 | + * @suppress PhanDeprecatedFunction |
|
112 | + * @suppress PhanTypeMismatchArgument |
|
113 | + */ |
|
114 | + public static function relative_modified_date($timestamp, $dateOnly = false) { |
|
115 | + return \relative_modified_date($timestamp, null, $dateOnly); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Generate html code for an options block. |
|
120 | - * |
|
121 | - * @param array $options the options |
|
122 | - * @param mixed $selected which one is selected? |
|
123 | - * @param array $params the parameters |
|
124 | - * @return string html options |
|
125 | - * @since 8.0.0 |
|
126 | - * @suppress PhanDeprecatedFunction |
|
127 | - */ |
|
128 | - public static function html_select_options($options, $selected, $params = []) { |
|
129 | - return \html_select_options($options, $selected, $params); |
|
130 | - } |
|
118 | + /** |
|
119 | + * Generate html code for an options block. |
|
120 | + * |
|
121 | + * @param array $options the options |
|
122 | + * @param mixed $selected which one is selected? |
|
123 | + * @param array $params the parameters |
|
124 | + * @return string html options |
|
125 | + * @since 8.0.0 |
|
126 | + * @suppress PhanDeprecatedFunction |
|
127 | + */ |
|
128 | + public static function html_select_options($options, $selected, $params = []) { |
|
129 | + return \html_select_options($options, $selected, $params); |
|
130 | + } |
|
131 | 131 | } |
@@ -41,149 +41,149 @@ |
||
41 | 41 | * @deprecated 20.0.0 use the PSR-3 logger \Psr\Log\LoggerInterface |
42 | 42 | */ |
43 | 43 | interface ILogger { |
44 | - /** |
|
45 | - * @since 14.0.0 |
|
46 | - * @deprecated 20.0.0 |
|
47 | - */ |
|
48 | - public const DEBUG = 0; |
|
49 | - /** |
|
50 | - * @since 14.0.0 |
|
51 | - * @deprecated 20.0.0 |
|
52 | - */ |
|
53 | - public const INFO = 1; |
|
54 | - /** |
|
55 | - * @since 14.0.0 |
|
56 | - * @deprecated 20.0.0 |
|
57 | - */ |
|
58 | - public const WARN = 2; |
|
59 | - /** |
|
60 | - * @since 14.0.0 |
|
61 | - * @deprecated 20.0.0 |
|
62 | - */ |
|
63 | - public const ERROR = 3; |
|
64 | - /** |
|
65 | - * @since 14.0.0 |
|
66 | - * @deprecated 20.0.0 |
|
67 | - */ |
|
68 | - public const FATAL = 4; |
|
44 | + /** |
|
45 | + * @since 14.0.0 |
|
46 | + * @deprecated 20.0.0 |
|
47 | + */ |
|
48 | + public const DEBUG = 0; |
|
49 | + /** |
|
50 | + * @since 14.0.0 |
|
51 | + * @deprecated 20.0.0 |
|
52 | + */ |
|
53 | + public const INFO = 1; |
|
54 | + /** |
|
55 | + * @since 14.0.0 |
|
56 | + * @deprecated 20.0.0 |
|
57 | + */ |
|
58 | + public const WARN = 2; |
|
59 | + /** |
|
60 | + * @since 14.0.0 |
|
61 | + * @deprecated 20.0.0 |
|
62 | + */ |
|
63 | + public const ERROR = 3; |
|
64 | + /** |
|
65 | + * @since 14.0.0 |
|
66 | + * @deprecated 20.0.0 |
|
67 | + */ |
|
68 | + public const FATAL = 4; |
|
69 | 69 | |
70 | - /** |
|
71 | - * System is unusable. |
|
72 | - * |
|
73 | - * @param string $message |
|
74 | - * @param array $context |
|
75 | - * @return null |
|
76 | - * @since 7.0.0 |
|
77 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::emergency |
|
78 | - */ |
|
79 | - public function emergency(string $message, array $context = []); |
|
70 | + /** |
|
71 | + * System is unusable. |
|
72 | + * |
|
73 | + * @param string $message |
|
74 | + * @param array $context |
|
75 | + * @return null |
|
76 | + * @since 7.0.0 |
|
77 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::emergency |
|
78 | + */ |
|
79 | + public function emergency(string $message, array $context = []); |
|
80 | 80 | |
81 | - /** |
|
82 | - * Action must be taken immediately. |
|
83 | - * |
|
84 | - * @param string $message |
|
85 | - * @param array $context |
|
86 | - * @return null |
|
87 | - * @since 7.0.0 |
|
88 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::alert |
|
89 | - */ |
|
90 | - public function alert(string $message, array $context = []); |
|
81 | + /** |
|
82 | + * Action must be taken immediately. |
|
83 | + * |
|
84 | + * @param string $message |
|
85 | + * @param array $context |
|
86 | + * @return null |
|
87 | + * @since 7.0.0 |
|
88 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::alert |
|
89 | + */ |
|
90 | + public function alert(string $message, array $context = []); |
|
91 | 91 | |
92 | - /** |
|
93 | - * Critical conditions. |
|
94 | - * |
|
95 | - * @param string $message |
|
96 | - * @param array $context |
|
97 | - * @return null |
|
98 | - * @since 7.0.0 |
|
99 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::critical |
|
100 | - */ |
|
101 | - public function critical(string $message, array $context = []); |
|
92 | + /** |
|
93 | + * Critical conditions. |
|
94 | + * |
|
95 | + * @param string $message |
|
96 | + * @param array $context |
|
97 | + * @return null |
|
98 | + * @since 7.0.0 |
|
99 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::critical |
|
100 | + */ |
|
101 | + public function critical(string $message, array $context = []); |
|
102 | 102 | |
103 | - /** |
|
104 | - * Runtime errors that do not require immediate action but should typically |
|
105 | - * be logged and monitored. |
|
106 | - * |
|
107 | - * @param string $message |
|
108 | - * @param array $context |
|
109 | - * @return null |
|
110 | - * @since 7.0.0 |
|
111 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::error |
|
112 | - */ |
|
113 | - public function error(string $message, array $context = []); |
|
103 | + /** |
|
104 | + * Runtime errors that do not require immediate action but should typically |
|
105 | + * be logged and monitored. |
|
106 | + * |
|
107 | + * @param string $message |
|
108 | + * @param array $context |
|
109 | + * @return null |
|
110 | + * @since 7.0.0 |
|
111 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::error |
|
112 | + */ |
|
113 | + public function error(string $message, array $context = []); |
|
114 | 114 | |
115 | - /** |
|
116 | - * Exceptional occurrences that are not errors. |
|
117 | - * |
|
118 | - * @param string $message |
|
119 | - * @param array $context |
|
120 | - * @return null |
|
121 | - * @since 7.0.0 |
|
122 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::warning |
|
123 | - */ |
|
124 | - public function warning(string $message, array $context = []); |
|
115 | + /** |
|
116 | + * Exceptional occurrences that are not errors. |
|
117 | + * |
|
118 | + * @param string $message |
|
119 | + * @param array $context |
|
120 | + * @return null |
|
121 | + * @since 7.0.0 |
|
122 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::warning |
|
123 | + */ |
|
124 | + public function warning(string $message, array $context = []); |
|
125 | 125 | |
126 | - /** |
|
127 | - * Normal but significant events. |
|
128 | - * |
|
129 | - * @param string $message |
|
130 | - * @param array $context |
|
131 | - * @return null |
|
132 | - * @since 7.0.0 |
|
133 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::notice |
|
134 | - */ |
|
135 | - public function notice(string $message, array $context = []); |
|
126 | + /** |
|
127 | + * Normal but significant events. |
|
128 | + * |
|
129 | + * @param string $message |
|
130 | + * @param array $context |
|
131 | + * @return null |
|
132 | + * @since 7.0.0 |
|
133 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::notice |
|
134 | + */ |
|
135 | + public function notice(string $message, array $context = []); |
|
136 | 136 | |
137 | - /** |
|
138 | - * Interesting events. |
|
139 | - * |
|
140 | - * @param string $message |
|
141 | - * @param array $context |
|
142 | - * @return null |
|
143 | - * @since 7.0.0 |
|
144 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::info |
|
145 | - */ |
|
146 | - public function info(string $message, array $context = []); |
|
137 | + /** |
|
138 | + * Interesting events. |
|
139 | + * |
|
140 | + * @param string $message |
|
141 | + * @param array $context |
|
142 | + * @return null |
|
143 | + * @since 7.0.0 |
|
144 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::info |
|
145 | + */ |
|
146 | + public function info(string $message, array $context = []); |
|
147 | 147 | |
148 | - /** |
|
149 | - * Detailed debug information. |
|
150 | - * |
|
151 | - * @param string $message |
|
152 | - * @param array $context |
|
153 | - * @return null |
|
154 | - * @since 7.0.0 |
|
155 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::debug |
|
156 | - */ |
|
157 | - public function debug(string $message, array $context = []); |
|
148 | + /** |
|
149 | + * Detailed debug information. |
|
150 | + * |
|
151 | + * @param string $message |
|
152 | + * @param array $context |
|
153 | + * @return null |
|
154 | + * @since 7.0.0 |
|
155 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::debug |
|
156 | + */ |
|
157 | + public function debug(string $message, array $context = []); |
|
158 | 158 | |
159 | - /** |
|
160 | - * Logs with an arbitrary level. |
|
161 | - * |
|
162 | - * @param int $level |
|
163 | - * @param string $message |
|
164 | - * @param array $context |
|
165 | - * @return mixed |
|
166 | - * @since 7.0.0 |
|
167 | - * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::log |
|
168 | - */ |
|
169 | - public function log(int $level, string $message, array $context = []); |
|
159 | + /** |
|
160 | + * Logs with an arbitrary level. |
|
161 | + * |
|
162 | + * @param int $level |
|
163 | + * @param string $message |
|
164 | + * @param array $context |
|
165 | + * @return mixed |
|
166 | + * @since 7.0.0 |
|
167 | + * @deprecated 20.0.0 use \Psr\Log\LoggerInterface::log |
|
168 | + */ |
|
169 | + public function log(int $level, string $message, array $context = []); |
|
170 | 170 | |
171 | - /** |
|
172 | - * Logs an exception very detailed |
|
173 | - * An additional message can we written to the log by adding it to the |
|
174 | - * context. |
|
175 | - * |
|
176 | - * <code> |
|
177 | - * $logger->logException($ex, [ |
|
178 | - * 'message' => 'Exception during background job execution' |
|
179 | - * ]); |
|
180 | - * </code> |
|
181 | - * |
|
182 | - * @param \Exception|\Throwable $exception |
|
183 | - * @param array $context |
|
184 | - * @return void |
|
185 | - * @since 8.2.0 |
|
186 | - * @deprecated 20.0.0 use the `exception` entry in the context of any method in \Psr\Log\LoggerInterface |
|
187 | - */ |
|
188 | - public function logException(\Throwable $exception, array $context = []); |
|
171 | + /** |
|
172 | + * Logs an exception very detailed |
|
173 | + * An additional message can we written to the log by adding it to the |
|
174 | + * context. |
|
175 | + * |
|
176 | + * <code> |
|
177 | + * $logger->logException($ex, [ |
|
178 | + * 'message' => 'Exception during background job execution' |
|
179 | + * ]); |
|
180 | + * </code> |
|
181 | + * |
|
182 | + * @param \Exception|\Throwable $exception |
|
183 | + * @param array $context |
|
184 | + * @return void |
|
185 | + * @since 8.2.0 |
|
186 | + * @deprecated 20.0.0 use the `exception` entry in the context of any method in \Psr\Log\LoggerInterface |
|
187 | + */ |
|
188 | + public function logException(\Throwable $exception, array $context = []); |
|
189 | 189 | } |
@@ -32,13 +32,13 @@ |
||
32 | 32 | * @since 8.0.0 |
33 | 33 | */ |
34 | 34 | interface IExtension { |
35 | - public const METHOD_STREAM = 'stream'; |
|
36 | - public const METHOD_MAIL = 'email'; |
|
37 | - public const METHOD_NOTIFICATION = 'notification'; |
|
35 | + public const METHOD_STREAM = 'stream'; |
|
36 | + public const METHOD_MAIL = 'email'; |
|
37 | + public const METHOD_NOTIFICATION = 'notification'; |
|
38 | 38 | |
39 | - public const PRIORITY_VERYLOW = 10; |
|
40 | - public const PRIORITY_LOW = 20; |
|
41 | - public const PRIORITY_MEDIUM = 30; |
|
42 | - public const PRIORITY_HIGH = 40; |
|
43 | - public const PRIORITY_VERYHIGH = 50; |
|
39 | + public const PRIORITY_VERYLOW = 10; |
|
40 | + public const PRIORITY_LOW = 20; |
|
41 | + public const PRIORITY_MEDIUM = 30; |
|
42 | + public const PRIORITY_HIGH = 40; |
|
43 | + public const PRIORITY_VERYHIGH = 50; |
|
44 | 44 | } |
@@ -33,115 +33,115 @@ |
||
33 | 33 | |
34 | 34 | class WeatherStatusController extends OCSController { |
35 | 35 | |
36 | - /** @var string */ |
|
37 | - private $userId; |
|
36 | + /** @var string */ |
|
37 | + private $userId; |
|
38 | 38 | |
39 | - /** @var ILogger */ |
|
40 | - private $logger; |
|
39 | + /** @var ILogger */ |
|
40 | + private $logger; |
|
41 | 41 | |
42 | - /** @var WeatherStatusService */ |
|
43 | - private $service; |
|
42 | + /** @var WeatherStatusService */ |
|
43 | + private $service; |
|
44 | 44 | |
45 | - public function __construct(string $appName, |
|
46 | - IRequest $request, |
|
47 | - ILogger $logger, |
|
48 | - WeatherStatusService $service, |
|
49 | - ?string $userId) { |
|
50 | - parent::__construct($appName, $request); |
|
51 | - $this->userId = $userId; |
|
52 | - $this->logger = $logger; |
|
53 | - $this->service = $service; |
|
54 | - } |
|
45 | + public function __construct(string $appName, |
|
46 | + IRequest $request, |
|
47 | + ILogger $logger, |
|
48 | + WeatherStatusService $service, |
|
49 | + ?string $userId) { |
|
50 | + parent::__construct($appName, $request); |
|
51 | + $this->userId = $userId; |
|
52 | + $this->logger = $logger; |
|
53 | + $this->service = $service; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @NoAdminRequired |
|
58 | - * |
|
59 | - * Try to use the address set in user personal settings as weather location |
|
60 | - * |
|
61 | - * @return DataResponse with success state and address information |
|
62 | - */ |
|
63 | - public function usePersonalAddress(): DataResponse { |
|
64 | - return new DataResponse($this->service->usePersonalAddress()); |
|
65 | - } |
|
56 | + /** |
|
57 | + * @NoAdminRequired |
|
58 | + * |
|
59 | + * Try to use the address set in user personal settings as weather location |
|
60 | + * |
|
61 | + * @return DataResponse with success state and address information |
|
62 | + */ |
|
63 | + public function usePersonalAddress(): DataResponse { |
|
64 | + return new DataResponse($this->service->usePersonalAddress()); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @NoAdminRequired |
|
69 | - * |
|
70 | - * Change the weather status mode. There are currently 2 modes: |
|
71 | - * - ask the browser |
|
72 | - * - use the user defined address |
|
73 | - * |
|
74 | - * @param int $mode New mode |
|
75 | - * @return DataResponse success state |
|
76 | - */ |
|
77 | - public function setMode(int $mode): DataResponse { |
|
78 | - return new DataResponse($this->service->setMode($mode)); |
|
79 | - } |
|
67 | + /** |
|
68 | + * @NoAdminRequired |
|
69 | + * |
|
70 | + * Change the weather status mode. There are currently 2 modes: |
|
71 | + * - ask the browser |
|
72 | + * - use the user defined address |
|
73 | + * |
|
74 | + * @param int $mode New mode |
|
75 | + * @return DataResponse success state |
|
76 | + */ |
|
77 | + public function setMode(int $mode): DataResponse { |
|
78 | + return new DataResponse($this->service->setMode($mode)); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @NoAdminRequired |
|
83 | - * |
|
84 | - * Set address and resolve it to get coordinates |
|
85 | - * or directly set coordinates and get address with reverse geocoding |
|
86 | - * |
|
87 | - * @param string|null $address Any approximative or exact address |
|
88 | - * @param float|null $lat Latitude in decimal degree format |
|
89 | - * @param float|null $lon Longitude in decimal degree format |
|
90 | - * @return DataResponse with success state and address information |
|
91 | - */ |
|
92 | - public function setLocation(?string $address, ?float $lat, ?float $lon): DataResponse { |
|
93 | - $currentWeather = $this->service->setLocation($address, $lat, $lon); |
|
94 | - return new DataResponse($currentWeather); |
|
95 | - } |
|
81 | + /** |
|
82 | + * @NoAdminRequired |
|
83 | + * |
|
84 | + * Set address and resolve it to get coordinates |
|
85 | + * or directly set coordinates and get address with reverse geocoding |
|
86 | + * |
|
87 | + * @param string|null $address Any approximative or exact address |
|
88 | + * @param float|null $lat Latitude in decimal degree format |
|
89 | + * @param float|null $lon Longitude in decimal degree format |
|
90 | + * @return DataResponse with success state and address information |
|
91 | + */ |
|
92 | + public function setLocation(?string $address, ?float $lat, ?float $lon): DataResponse { |
|
93 | + $currentWeather = $this->service->setLocation($address, $lat, $lon); |
|
94 | + return new DataResponse($currentWeather); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @NoAdminRequired |
|
99 | - * |
|
100 | - * Get stored user location |
|
101 | - * |
|
102 | - * @return DataResponse which contains coordinates, formatted address and current weather status mode |
|
103 | - */ |
|
104 | - public function getLocation(): DataResponse { |
|
105 | - $location = $this->service->getLocation(); |
|
106 | - return new DataResponse($location); |
|
107 | - } |
|
97 | + /** |
|
98 | + * @NoAdminRequired |
|
99 | + * |
|
100 | + * Get stored user location |
|
101 | + * |
|
102 | + * @return DataResponse which contains coordinates, formatted address and current weather status mode |
|
103 | + */ |
|
104 | + public function getLocation(): DataResponse { |
|
105 | + $location = $this->service->getLocation(); |
|
106 | + return new DataResponse($location); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @NoAdminRequired |
|
111 | - * |
|
112 | - * Get forecast for current location |
|
113 | - * |
|
114 | - * @return DataResponse which contains success state and filtered forecast data |
|
115 | - */ |
|
116 | - public function getForecast(): DataResponse { |
|
117 | - $forecast = $this->service->getForecast(); |
|
118 | - if (isset($forecast['success']) && $forecast['success'] === false) { |
|
119 | - return new DataResponse($forecast, Http::STATUS_NOT_FOUND); |
|
120 | - } else { |
|
121 | - return new DataResponse($forecast); |
|
122 | - } |
|
123 | - } |
|
109 | + /** |
|
110 | + * @NoAdminRequired |
|
111 | + * |
|
112 | + * Get forecast for current location |
|
113 | + * |
|
114 | + * @return DataResponse which contains success state and filtered forecast data |
|
115 | + */ |
|
116 | + public function getForecast(): DataResponse { |
|
117 | + $forecast = $this->service->getForecast(); |
|
118 | + if (isset($forecast['success']) && $forecast['success'] === false) { |
|
119 | + return new DataResponse($forecast, Http::STATUS_NOT_FOUND); |
|
120 | + } else { |
|
121 | + return new DataResponse($forecast); |
|
122 | + } |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @NoAdminRequired |
|
127 | - * |
|
128 | - * Get favorites list |
|
129 | - * |
|
130 | - * @return DataResponse which contains the favorite list |
|
131 | - */ |
|
132 | - public function getFavorites(): DataResponse { |
|
133 | - return new DataResponse($this->service->getFavorites()); |
|
134 | - } |
|
125 | + /** |
|
126 | + * @NoAdminRequired |
|
127 | + * |
|
128 | + * Get favorites list |
|
129 | + * |
|
130 | + * @return DataResponse which contains the favorite list |
|
131 | + */ |
|
132 | + public function getFavorites(): DataResponse { |
|
133 | + return new DataResponse($this->service->getFavorites()); |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * @NoAdminRequired |
|
138 | - * |
|
139 | - * Set favorites list |
|
140 | - * |
|
141 | - * @param array $favorites |
|
142 | - * @return DataResponse success state |
|
143 | - */ |
|
144 | - public function setFavorites(array $favorites): DataResponse { |
|
145 | - return new DataResponse($this->service->setFavorites($favorites)); |
|
146 | - } |
|
136 | + /** |
|
137 | + * @NoAdminRequired |
|
138 | + * |
|
139 | + * Set favorites list |
|
140 | + * |
|
141 | + * @param array $favorites |
|
142 | + * @return DataResponse success state |
|
143 | + */ |
|
144 | + public function setFavorites(array $favorites): DataResponse { |
|
145 | + return new DataResponse($this->service->setFavorites($favorites)); |
|
146 | + } |
|
147 | 147 | } |
@@ -37,62 +37,62 @@ |
||
37 | 37 | use function in_array; |
38 | 38 | |
39 | 39 | class ShareInteractionListener implements IEventListener { |
40 | - private const SUPPORTED_SHARE_TYPES = [ |
|
41 | - IShare::TYPE_USER, |
|
42 | - IShare::TYPE_EMAIL, |
|
43 | - IShare::TYPE_REMOTE, |
|
44 | - ]; |
|
40 | + private const SUPPORTED_SHARE_TYPES = [ |
|
41 | + IShare::TYPE_USER, |
|
42 | + IShare::TYPE_EMAIL, |
|
43 | + IShare::TYPE_REMOTE, |
|
44 | + ]; |
|
45 | 45 | |
46 | - /** @var IEventDispatcher */ |
|
47 | - private $dispatcher; |
|
46 | + /** @var IEventDispatcher */ |
|
47 | + private $dispatcher; |
|
48 | 48 | |
49 | - /** @var IUserManager */ |
|
50 | - private $userManager; |
|
49 | + /** @var IUserManager */ |
|
50 | + private $userManager; |
|
51 | 51 | |
52 | - /** @var ILogger */ |
|
53 | - private $logger; |
|
52 | + /** @var ILogger */ |
|
53 | + private $logger; |
|
54 | 54 | |
55 | - public function __construct(IEventDispatcher $dispatcher, |
|
56 | - IUserManager $userManager, |
|
57 | - ILogger $logger) { |
|
58 | - $this->dispatcher = $dispatcher; |
|
59 | - $this->userManager = $userManager; |
|
60 | - $this->logger = $logger; |
|
61 | - } |
|
55 | + public function __construct(IEventDispatcher $dispatcher, |
|
56 | + IUserManager $userManager, |
|
57 | + ILogger $logger) { |
|
58 | + $this->dispatcher = $dispatcher; |
|
59 | + $this->userManager = $userManager; |
|
60 | + $this->logger = $logger; |
|
61 | + } |
|
62 | 62 | |
63 | - public function handle(Event $event): void { |
|
64 | - if (!($event instanceof ShareCreatedEvent)) { |
|
65 | - // Unrelated |
|
66 | - return; |
|
67 | - } |
|
63 | + public function handle(Event $event): void { |
|
64 | + if (!($event instanceof ShareCreatedEvent)) { |
|
65 | + // Unrelated |
|
66 | + return; |
|
67 | + } |
|
68 | 68 | |
69 | - $share = $event->getShare(); |
|
70 | - if (!in_array($share->getShareType(), self::SUPPORTED_SHARE_TYPES, true)) { |
|
71 | - $this->logger->debug('Share type does not allow to emit interaction event'); |
|
72 | - return; |
|
73 | - } |
|
74 | - $actor = $this->userManager->get($share->getSharedBy()); |
|
75 | - $sharedWith = $this->userManager->get($share->getSharedWith()); |
|
76 | - if ($actor === null) { |
|
77 | - $this->logger->warning('Share was not created by a user, can\'t emit interaction event'); |
|
78 | - return; |
|
79 | - } |
|
80 | - $interactionEvent = new ContactInteractedWithEvent($actor); |
|
81 | - switch ($share->getShareType()) { |
|
82 | - case IShare::TYPE_USER: |
|
83 | - $interactionEvent->setUid($share->getSharedWith()); |
|
84 | - if ($sharedWith !== null) { |
|
85 | - $interactionEvent->setFederatedCloudId($sharedWith->getCloudId()); |
|
86 | - } |
|
87 | - break; |
|
88 | - case IShare::TYPE_EMAIL: |
|
89 | - $interactionEvent->setEmail($share->getSharedWith()); |
|
90 | - break; |
|
91 | - case IShare::TYPE_REMOTE: |
|
92 | - $interactionEvent->setFederatedCloudId($share->getSharedWith()); |
|
93 | - break; |
|
94 | - } |
|
69 | + $share = $event->getShare(); |
|
70 | + if (!in_array($share->getShareType(), self::SUPPORTED_SHARE_TYPES, true)) { |
|
71 | + $this->logger->debug('Share type does not allow to emit interaction event'); |
|
72 | + return; |
|
73 | + } |
|
74 | + $actor = $this->userManager->get($share->getSharedBy()); |
|
75 | + $sharedWith = $this->userManager->get($share->getSharedWith()); |
|
76 | + if ($actor === null) { |
|
77 | + $this->logger->warning('Share was not created by a user, can\'t emit interaction event'); |
|
78 | + return; |
|
79 | + } |
|
80 | + $interactionEvent = new ContactInteractedWithEvent($actor); |
|
81 | + switch ($share->getShareType()) { |
|
82 | + case IShare::TYPE_USER: |
|
83 | + $interactionEvent->setUid($share->getSharedWith()); |
|
84 | + if ($sharedWith !== null) { |
|
85 | + $interactionEvent->setFederatedCloudId($sharedWith->getCloudId()); |
|
86 | + } |
|
87 | + break; |
|
88 | + case IShare::TYPE_EMAIL: |
|
89 | + $interactionEvent->setEmail($share->getSharedWith()); |
|
90 | + break; |
|
91 | + case IShare::TYPE_REMOTE: |
|
92 | + $interactionEvent->setFederatedCloudId($share->getSharedWith()); |
|
93 | + break; |
|
94 | + } |
|
95 | 95 | |
96 | - $this->dispatcher->dispatchTyped($interactionEvent); |
|
97 | - } |
|
96 | + $this->dispatcher->dispatchTyped($interactionEvent); |
|
97 | + } |
|
98 | 98 | } |