@@ -33,33 +33,33 @@ |
||
33 | 33 | * @since 8.1.0 |
34 | 34 | */ |
35 | 35 | class StreamResponse extends Response implements ICallbackResponse { |
36 | - /** @var string */ |
|
37 | - private $filePath; |
|
36 | + /** @var string */ |
|
37 | + private $filePath; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string|resource $filePath the path to the file or a file handle which should be streamed |
|
41 | - * @since 8.1.0 |
|
42 | - */ |
|
43 | - public function __construct ($filePath) { |
|
44 | - $this->filePath = $filePath; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param string|resource $filePath the path to the file or a file handle which should be streamed |
|
41 | + * @since 8.1.0 |
|
42 | + */ |
|
43 | + public function __construct ($filePath) { |
|
44 | + $this->filePath = $filePath; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Streams the file using readfile |
|
50 | - * |
|
51 | - * @param IOutput $output a small wrapper that handles output |
|
52 | - * @since 8.1.0 |
|
53 | - */ |
|
54 | - public function callback (IOutput $output) { |
|
55 | - // handle caching |
|
56 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
57 | - if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
|
58 | - $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
59 | - } elseif ($output->setReadfile($this->filePath) === false) { |
|
60 | - $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
48 | + /** |
|
49 | + * Streams the file using readfile |
|
50 | + * |
|
51 | + * @param IOutput $output a small wrapper that handles output |
|
52 | + * @since 8.1.0 |
|
53 | + */ |
|
54 | + public function callback (IOutput $output) { |
|
55 | + // handle caching |
|
56 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
57 | + if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
|
58 | + $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
59 | + } elseif ($output->setReadfile($this->filePath) === false) { |
|
60 | + $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -32,22 +32,22 @@ |
||
32 | 32 | */ |
33 | 33 | class DownloadResponse extends \OCP\AppFramework\Http\Response { |
34 | 34 | |
35 | - private $filename; |
|
36 | - private $contentType; |
|
37 | - |
|
38 | - /** |
|
39 | - * Creates a response that prompts the user to download the file |
|
40 | - * @param string $filename the name that the downloaded file should have |
|
41 | - * @param string $contentType the mimetype that the downloaded file should have |
|
42 | - * @since 7.0.0 |
|
43 | - */ |
|
44 | - public function __construct($filename, $contentType) { |
|
45 | - $this->filename = $filename; |
|
46 | - $this->contentType = $contentType; |
|
47 | - |
|
48 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
49 | - $this->addHeader('Content-Type', $contentType); |
|
50 | - } |
|
35 | + private $filename; |
|
36 | + private $contentType; |
|
37 | + |
|
38 | + /** |
|
39 | + * Creates a response that prompts the user to download the file |
|
40 | + * @param string $filename the name that the downloaded file should have |
|
41 | + * @param string $contentType the mimetype that the downloaded file should have |
|
42 | + * @since 7.0.0 |
|
43 | + */ |
|
44 | + public function __construct($filename, $contentType) { |
|
45 | + $this->filename = $filename; |
|
46 | + $this->contentType = $contentType; |
|
47 | + |
|
48 | + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
49 | + $this->addHeader('Content-Type', $contentType); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | } |
@@ -44,69 +44,69 @@ |
||
44 | 44 | abstract class Middleware { |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * This is being run in normal order before the controller is being |
|
49 | - * called which allows several modifications and checks |
|
50 | - * |
|
51 | - * @param Controller $controller the controller that is being called |
|
52 | - * @param string $methodName the name of the method that will be called on |
|
53 | - * the controller |
|
54 | - * @since 6.0.0 |
|
55 | - */ |
|
56 | - public function beforeController($controller, $methodName){ |
|
47 | + /** |
|
48 | + * This is being run in normal order before the controller is being |
|
49 | + * called which allows several modifications and checks |
|
50 | + * |
|
51 | + * @param Controller $controller the controller that is being called |
|
52 | + * @param string $methodName the name of the method that will be called on |
|
53 | + * the controller |
|
54 | + * @since 6.0.0 |
|
55 | + */ |
|
56 | + public function beforeController($controller, $methodName){ |
|
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * This is being run when either the beforeController method or the |
|
63 | - * controller method itself is throwing an exception. The middleware is |
|
64 | - * asked in reverse order to handle the exception and to return a response. |
|
65 | - * If the response is null, it is assumed that the exception could not be |
|
66 | - * handled and the error will be thrown again |
|
67 | - * |
|
68 | - * @param Controller $controller the controller that is being called |
|
69 | - * @param string $methodName the name of the method that will be called on |
|
70 | - * the controller |
|
71 | - * @param \Exception $exception the thrown exception |
|
72 | - * @throws \Exception the passed in exception if it can't handle it |
|
73 | - * @return Response a Response object in case that the exception was handled |
|
74 | - * @since 6.0.0 |
|
75 | - */ |
|
76 | - public function afterException($controller, $methodName, \Exception $exception){ |
|
77 | - throw $exception; |
|
78 | - } |
|
61 | + /** |
|
62 | + * This is being run when either the beforeController method or the |
|
63 | + * controller method itself is throwing an exception. The middleware is |
|
64 | + * asked in reverse order to handle the exception and to return a response. |
|
65 | + * If the response is null, it is assumed that the exception could not be |
|
66 | + * handled and the error will be thrown again |
|
67 | + * |
|
68 | + * @param Controller $controller the controller that is being called |
|
69 | + * @param string $methodName the name of the method that will be called on |
|
70 | + * the controller |
|
71 | + * @param \Exception $exception the thrown exception |
|
72 | + * @throws \Exception the passed in exception if it can't handle it |
|
73 | + * @return Response a Response object in case that the exception was handled |
|
74 | + * @since 6.0.0 |
|
75 | + */ |
|
76 | + public function afterException($controller, $methodName, \Exception $exception){ |
|
77 | + throw $exception; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * This is being run after a successful controllermethod call and allows |
|
83 | - * the manipulation of a Response object. The middleware is run in reverse order |
|
84 | - * |
|
85 | - * @param Controller $controller the controller that is being called |
|
86 | - * @param string $methodName the name of the method that will be called on |
|
87 | - * the controller |
|
88 | - * @param Response $response the generated response from the controller |
|
89 | - * @return Response a Response object |
|
90 | - * @since 6.0.0 |
|
91 | - */ |
|
92 | - public function afterController($controller, $methodName, Response $response){ |
|
93 | - return $response; |
|
94 | - } |
|
81 | + /** |
|
82 | + * This is being run after a successful controllermethod call and allows |
|
83 | + * the manipulation of a Response object. The middleware is run in reverse order |
|
84 | + * |
|
85 | + * @param Controller $controller the controller that is being called |
|
86 | + * @param string $methodName the name of the method that will be called on |
|
87 | + * the controller |
|
88 | + * @param Response $response the generated response from the controller |
|
89 | + * @return Response a Response object |
|
90 | + * @since 6.0.0 |
|
91 | + */ |
|
92 | + public function afterController($controller, $methodName, Response $response){ |
|
93 | + return $response; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * This is being run after the response object has been rendered and |
|
99 | - * allows the manipulation of the output. The middleware is run in reverse order |
|
100 | - * |
|
101 | - * @param Controller $controller the controller that is being called |
|
102 | - * @param string $methodName the name of the method that will be called on |
|
103 | - * the controller |
|
104 | - * @param string $output the generated output from a response |
|
105 | - * @return string the output that should be printed |
|
106 | - * @since 6.0.0 |
|
107 | - */ |
|
108 | - public function beforeOutput($controller, $methodName, $output){ |
|
109 | - return $output; |
|
110 | - } |
|
97 | + /** |
|
98 | + * This is being run after the response object has been rendered and |
|
99 | + * allows the manipulation of the output. The middleware is run in reverse order |
|
100 | + * |
|
101 | + * @param Controller $controller the controller that is being called |
|
102 | + * @param string $methodName the name of the method that will be called on |
|
103 | + * the controller |
|
104 | + * @param string $output the generated output from a response |
|
105 | + * @return string the output that should be printed |
|
106 | + * @since 6.0.0 |
|
107 | + */ |
|
108 | + public function beforeOutput($controller, $methodName, $output){ |
|
109 | + return $output; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | } |
@@ -35,63 +35,63 @@ |
||
35 | 35 | */ |
36 | 36 | class Http { |
37 | 37 | |
38 | - const STATUS_CONTINUE = 100; |
|
39 | - const STATUS_SWITCHING_PROTOCOLS = 101; |
|
40 | - const STATUS_PROCESSING = 102; |
|
41 | - const STATUS_OK = 200; |
|
42 | - const STATUS_CREATED = 201; |
|
43 | - const STATUS_ACCEPTED = 202; |
|
44 | - const STATUS_NON_AUTHORATIVE_INFORMATION = 203; |
|
45 | - const STATUS_NO_CONTENT = 204; |
|
46 | - const STATUS_RESET_CONTENT = 205; |
|
47 | - const STATUS_PARTIAL_CONTENT = 206; |
|
48 | - const STATUS_MULTI_STATUS = 207; |
|
49 | - const STATUS_ALREADY_REPORTED = 208; |
|
50 | - const STATUS_IM_USED = 226; |
|
51 | - const STATUS_MULTIPLE_CHOICES = 300; |
|
52 | - const STATUS_MOVED_PERMANENTLY = 301; |
|
53 | - const STATUS_FOUND = 302; |
|
54 | - const STATUS_SEE_OTHER = 303; |
|
55 | - const STATUS_NOT_MODIFIED = 304; |
|
56 | - const STATUS_USE_PROXY = 305; |
|
57 | - const STATUS_RESERVED = 306; |
|
58 | - const STATUS_TEMPORARY_REDIRECT = 307; |
|
59 | - const STATUS_BAD_REQUEST = 400; |
|
60 | - const STATUS_UNAUTHORIZED = 401; |
|
61 | - const STATUS_PAYMENT_REQUIRED = 402; |
|
62 | - const STATUS_FORBIDDEN = 403; |
|
63 | - const STATUS_NOT_FOUND = 404; |
|
64 | - const STATUS_METHOD_NOT_ALLOWED = 405; |
|
65 | - const STATUS_NOT_ACCEPTABLE = 406; |
|
66 | - const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407; |
|
67 | - const STATUS_REQUEST_TIMEOUT = 408; |
|
68 | - const STATUS_CONFLICT = 409; |
|
69 | - const STATUS_GONE = 410; |
|
70 | - const STATUS_LENGTH_REQUIRED = 411; |
|
71 | - const STATUS_PRECONDITION_FAILED = 412; |
|
72 | - const STATUS_REQUEST_ENTITY_TOO_LARGE = 413; |
|
73 | - const STATUS_REQUEST_URI_TOO_LONG = 414; |
|
74 | - const STATUS_UNSUPPORTED_MEDIA_TYPE = 415; |
|
75 | - const STATUS_REQUEST_RANGE_NOT_SATISFIABLE = 416; |
|
76 | - const STATUS_EXPECTATION_FAILED = 417; |
|
77 | - const STATUS_IM_A_TEAPOT = 418; |
|
78 | - const STATUS_UNPROCESSABLE_ENTITY = 422; |
|
79 | - const STATUS_LOCKED = 423; |
|
80 | - const STATUS_FAILED_DEPENDENCY = 424; |
|
81 | - const STATUS_UPGRADE_REQUIRED = 426; |
|
82 | - const STATUS_PRECONDITION_REQUIRED = 428; |
|
83 | - const STATUS_TOO_MANY_REQUESTS = 429; |
|
84 | - const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; |
|
85 | - const STATUS_INTERNAL_SERVER_ERROR = 500; |
|
86 | - const STATUS_NOT_IMPLEMENTED = 501; |
|
87 | - const STATUS_BAD_GATEWAY = 502; |
|
88 | - const STATUS_SERVICE_UNAVAILABLE = 503; |
|
89 | - const STATUS_GATEWAY_TIMEOUT = 504; |
|
90 | - const STATUS_HTTP_VERSION_NOT_SUPPORTED = 505; |
|
91 | - const STATUS_VARIANT_ALSO_NEGOTIATES = 506; |
|
92 | - const STATUS_INSUFFICIENT_STORAGE = 507; |
|
93 | - const STATUS_LOOP_DETECTED = 508; |
|
94 | - const STATUS_BANDWIDTH_LIMIT_EXCEEDED = 509; |
|
95 | - const STATUS_NOT_EXTENDED = 510; |
|
96 | - const STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511; |
|
38 | + const STATUS_CONTINUE = 100; |
|
39 | + const STATUS_SWITCHING_PROTOCOLS = 101; |
|
40 | + const STATUS_PROCESSING = 102; |
|
41 | + const STATUS_OK = 200; |
|
42 | + const STATUS_CREATED = 201; |
|
43 | + const STATUS_ACCEPTED = 202; |
|
44 | + const STATUS_NON_AUTHORATIVE_INFORMATION = 203; |
|
45 | + const STATUS_NO_CONTENT = 204; |
|
46 | + const STATUS_RESET_CONTENT = 205; |
|
47 | + const STATUS_PARTIAL_CONTENT = 206; |
|
48 | + const STATUS_MULTI_STATUS = 207; |
|
49 | + const STATUS_ALREADY_REPORTED = 208; |
|
50 | + const STATUS_IM_USED = 226; |
|
51 | + const STATUS_MULTIPLE_CHOICES = 300; |
|
52 | + const STATUS_MOVED_PERMANENTLY = 301; |
|
53 | + const STATUS_FOUND = 302; |
|
54 | + const STATUS_SEE_OTHER = 303; |
|
55 | + const STATUS_NOT_MODIFIED = 304; |
|
56 | + const STATUS_USE_PROXY = 305; |
|
57 | + const STATUS_RESERVED = 306; |
|
58 | + const STATUS_TEMPORARY_REDIRECT = 307; |
|
59 | + const STATUS_BAD_REQUEST = 400; |
|
60 | + const STATUS_UNAUTHORIZED = 401; |
|
61 | + const STATUS_PAYMENT_REQUIRED = 402; |
|
62 | + const STATUS_FORBIDDEN = 403; |
|
63 | + const STATUS_NOT_FOUND = 404; |
|
64 | + const STATUS_METHOD_NOT_ALLOWED = 405; |
|
65 | + const STATUS_NOT_ACCEPTABLE = 406; |
|
66 | + const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407; |
|
67 | + const STATUS_REQUEST_TIMEOUT = 408; |
|
68 | + const STATUS_CONFLICT = 409; |
|
69 | + const STATUS_GONE = 410; |
|
70 | + const STATUS_LENGTH_REQUIRED = 411; |
|
71 | + const STATUS_PRECONDITION_FAILED = 412; |
|
72 | + const STATUS_REQUEST_ENTITY_TOO_LARGE = 413; |
|
73 | + const STATUS_REQUEST_URI_TOO_LONG = 414; |
|
74 | + const STATUS_UNSUPPORTED_MEDIA_TYPE = 415; |
|
75 | + const STATUS_REQUEST_RANGE_NOT_SATISFIABLE = 416; |
|
76 | + const STATUS_EXPECTATION_FAILED = 417; |
|
77 | + const STATUS_IM_A_TEAPOT = 418; |
|
78 | + const STATUS_UNPROCESSABLE_ENTITY = 422; |
|
79 | + const STATUS_LOCKED = 423; |
|
80 | + const STATUS_FAILED_DEPENDENCY = 424; |
|
81 | + const STATUS_UPGRADE_REQUIRED = 426; |
|
82 | + const STATUS_PRECONDITION_REQUIRED = 428; |
|
83 | + const STATUS_TOO_MANY_REQUESTS = 429; |
|
84 | + const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; |
|
85 | + const STATUS_INTERNAL_SERVER_ERROR = 500; |
|
86 | + const STATUS_NOT_IMPLEMENTED = 501; |
|
87 | + const STATUS_BAD_GATEWAY = 502; |
|
88 | + const STATUS_SERVICE_UNAVAILABLE = 503; |
|
89 | + const STATUS_GATEWAY_TIMEOUT = 504; |
|
90 | + const STATUS_HTTP_VERSION_NOT_SUPPORTED = 505; |
|
91 | + const STATUS_VARIANT_ALSO_NEGOTIATES = 506; |
|
92 | + const STATUS_INSUFFICIENT_STORAGE = 507; |
|
93 | + const STATUS_LOOP_DETECTED = 508; |
|
94 | + const STATUS_BANDWIDTH_LIMIT_EXCEEDED = 509; |
|
95 | + const STATUS_NOT_EXTENDED = 510; |
|
96 | + const STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511; |
|
97 | 97 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * defaults to 'Authorization, Content-Type, Accept' |
56 | 56 | * @param int $corsMaxAge number in seconds how long a preflighted OPTIONS |
57 | 57 | * request should be cached, defaults to 1728000 seconds |
58 | - * @since 7.0.0 |
|
58 | + * @since 7.0.0 |
|
59 | 59 | */ |
60 | 60 | public function __construct($appName, |
61 | 61 | IRequest $request, |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @NoAdminRequired |
77 | 77 | * @NoCSRFRequired |
78 | 78 | * @PublicPage |
79 | - * @since 7.0.0 |
|
79 | + * @since 7.0.0 |
|
80 | 80 | */ |
81 | 81 | public function preflightedCors() { |
82 | 82 | if(isset($this->request->server['HTTP_ORIGIN'])) { |
@@ -32,13 +32,13 @@ |
||
32 | 32 | */ |
33 | 33 | class MultipleObjectsReturnedException extends \Exception { |
34 | 34 | |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * @param string $msg the error message |
|
38 | - * @since 7.0.0 |
|
39 | - */ |
|
40 | - public function __construct($msg){ |
|
41 | - parent::__construct($msg); |
|
42 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * @param string $msg the error message |
|
38 | + * @since 7.0.0 |
|
39 | + */ |
|
40 | + public function __construct($msg){ |
|
41 | + parent::__construct($msg); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
@@ -32,13 +32,13 @@ |
||
32 | 32 | */ |
33 | 33 | class DoesNotExistException extends \Exception { |
34 | 34 | |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * @param string $msg the error message |
|
38 | - * @since 7.0.0 |
|
39 | - */ |
|
40 | - public function __construct($msg){ |
|
41 | - parent::__construct($msg); |
|
42 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * @param string $msg the error message |
|
38 | + * @since 7.0.0 |
|
39 | + */ |
|
40 | + public function __construct($msg){ |
|
41 | + parent::__construct($msg); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
@@ -31,224 +31,224 @@ |
||
31 | 31 | */ |
32 | 32 | abstract class Entity { |
33 | 33 | |
34 | - public $id; |
|
34 | + public $id; |
|
35 | 35 | |
36 | - private $_updatedFields = array(); |
|
37 | - private $_fieldTypes = array('id' => 'integer'); |
|
36 | + private $_updatedFields = array(); |
|
37 | + private $_fieldTypes = array('id' => 'integer'); |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Simple alternative constructor for building entities from a request |
|
42 | - * @param array $params the array which was obtained via $this->params('key') |
|
43 | - * in the controller |
|
44 | - * @return Entity |
|
45 | - * @since 7.0.0 |
|
46 | - */ |
|
47 | - public static function fromParams(array $params) { |
|
48 | - $instance = new static(); |
|
40 | + /** |
|
41 | + * Simple alternative constructor for building entities from a request |
|
42 | + * @param array $params the array which was obtained via $this->params('key') |
|
43 | + * in the controller |
|
44 | + * @return Entity |
|
45 | + * @since 7.0.0 |
|
46 | + */ |
|
47 | + public static function fromParams(array $params) { |
|
48 | + $instance = new static(); |
|
49 | 49 | |
50 | - foreach($params as $key => $value) { |
|
51 | - $method = 'set' . ucfirst($key); |
|
52 | - $instance->$method($value); |
|
53 | - } |
|
50 | + foreach($params as $key => $value) { |
|
51 | + $method = 'set' . ucfirst($key); |
|
52 | + $instance->$method($value); |
|
53 | + } |
|
54 | 54 | |
55 | - return $instance; |
|
56 | - } |
|
55 | + return $instance; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Maps the keys of the row array to the attributes |
|
61 | - * @param array $row the row to map onto the entity |
|
62 | - * @since 7.0.0 |
|
63 | - */ |
|
64 | - public static function fromRow(array $row){ |
|
65 | - $instance = new static(); |
|
59 | + /** |
|
60 | + * Maps the keys of the row array to the attributes |
|
61 | + * @param array $row the row to map onto the entity |
|
62 | + * @since 7.0.0 |
|
63 | + */ |
|
64 | + public static function fromRow(array $row){ |
|
65 | + $instance = new static(); |
|
66 | 66 | |
67 | - foreach($row as $key => $value){ |
|
68 | - $prop = ucfirst($instance->columnToProperty($key)); |
|
69 | - $setter = 'set' . $prop; |
|
70 | - $instance->$setter($value); |
|
71 | - } |
|
67 | + foreach($row as $key => $value){ |
|
68 | + $prop = ucfirst($instance->columnToProperty($key)); |
|
69 | + $setter = 'set' . $prop; |
|
70 | + $instance->$setter($value); |
|
71 | + } |
|
72 | 72 | |
73 | - $instance->resetUpdatedFields(); |
|
73 | + $instance->resetUpdatedFields(); |
|
74 | 74 | |
75 | - return $instance; |
|
76 | - } |
|
75 | + return $instance; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return array with attribute and type |
|
81 | - * @since 7.0.0 |
|
82 | - */ |
|
83 | - public function getFieldTypes() { |
|
84 | - return $this->_fieldTypes; |
|
85 | - } |
|
79 | + /** |
|
80 | + * @return array with attribute and type |
|
81 | + * @since 7.0.0 |
|
82 | + */ |
|
83 | + public function getFieldTypes() { |
|
84 | + return $this->_fieldTypes; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * Marks the entity as clean needed for setting the id after the insertion |
|
90 | - * @since 7.0.0 |
|
91 | - */ |
|
92 | - public function resetUpdatedFields(){ |
|
93 | - $this->_updatedFields = array(); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Generic setter for properties |
|
98 | - * @since 7.0.0 |
|
99 | - */ |
|
100 | - protected function setter($name, $args) { |
|
101 | - // setters should only work for existing attributes |
|
102 | - if(property_exists($this, $name)){ |
|
103 | - if($this->$name === $args[0]) { |
|
104 | - return; |
|
105 | - } |
|
106 | - $this->markFieldUpdated($name); |
|
107 | - |
|
108 | - // if type definition exists, cast to correct type |
|
109 | - if($args[0] !== null && array_key_exists($name, $this->_fieldTypes)) { |
|
110 | - settype($args[0], $this->_fieldTypes[$name]); |
|
111 | - } |
|
112 | - $this->$name = $args[0]; |
|
113 | - |
|
114 | - } else { |
|
115 | - throw new \BadFunctionCallException($name . |
|
116 | - ' is not a valid attribute'); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Generic getter for properties |
|
122 | - * @since 7.0.0 |
|
123 | - */ |
|
124 | - protected function getter($name) { |
|
125 | - // getters should only work for existing attributes |
|
126 | - if(property_exists($this, $name)){ |
|
127 | - return $this->$name; |
|
128 | - } else { |
|
129 | - throw new \BadFunctionCallException($name . |
|
130 | - ' is not a valid attribute'); |
|
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * Each time a setter is called, push the part after set |
|
137 | - * into an array: for instance setId will save Id in the |
|
138 | - * updated fields array so it can be easily used to create the |
|
139 | - * getter method |
|
140 | - * @since 7.0.0 |
|
141 | - */ |
|
142 | - public function __call($methodName, $args){ |
|
143 | - $attr = lcfirst( substr($methodName, 3) ); |
|
144 | - |
|
145 | - if(strpos($methodName, 'set') === 0){ |
|
146 | - $this->setter($attr, $args); |
|
147 | - } elseif(strpos($methodName, 'get') === 0) { |
|
148 | - return $this->getter($attr); |
|
149 | - } else { |
|
150 | - throw new \BadFunctionCallException($methodName . |
|
151 | - ' does not exist'); |
|
152 | - } |
|
153 | - |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * Mark am attribute as updated |
|
159 | - * @param string $attribute the name of the attribute |
|
160 | - * @since 7.0.0 |
|
161 | - */ |
|
162 | - protected function markFieldUpdated($attribute){ |
|
163 | - $this->_updatedFields[$attribute] = true; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Transform a database columnname to a property |
|
169 | - * @param string $columnName the name of the column |
|
170 | - * @return string the property name |
|
171 | - * @since 7.0.0 |
|
172 | - */ |
|
173 | - public function columnToProperty($columnName){ |
|
174 | - $parts = explode('_', $columnName); |
|
175 | - $property = null; |
|
176 | - |
|
177 | - foreach($parts as $part){ |
|
178 | - if($property === null){ |
|
179 | - $property = $part; |
|
180 | - } else { |
|
181 | - $property .= ucfirst($part); |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - return $property; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * Transform a property to a database column name |
|
191 | - * @param string $property the name of the property |
|
192 | - * @return string the column name |
|
193 | - * @since 7.0.0 |
|
194 | - */ |
|
195 | - public function propertyToColumn($property){ |
|
196 | - $parts = preg_split('/(?=[A-Z])/', $property); |
|
197 | - $column = null; |
|
198 | - |
|
199 | - foreach($parts as $part){ |
|
200 | - if($column === null){ |
|
201 | - $column = $part; |
|
202 | - } else { |
|
203 | - $column .= '_' . lcfirst($part); |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - return $column; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @return array array of updated fields for update query |
|
213 | - * @since 7.0.0 |
|
214 | - */ |
|
215 | - public function getUpdatedFields(){ |
|
216 | - return $this->_updatedFields; |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * Adds type information for a field so that its automatically casted to |
|
222 | - * that value once its being returned from the database |
|
223 | - * @param string $fieldName the name of the attribute |
|
224 | - * @param string $type the type which will be used to call settype() |
|
225 | - * @since 7.0.0 |
|
226 | - */ |
|
227 | - protected function addType($fieldName, $type){ |
|
228 | - $this->_fieldTypes[$fieldName] = $type; |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * Slugify the value of a given attribute |
|
234 | - * Warning: This doesn't result in a unique value |
|
235 | - * @param string $attributeName the name of the attribute, which value should be slugified |
|
236 | - * @return string slugified value |
|
237 | - * @since 7.0.0 |
|
238 | - */ |
|
239 | - public function slugify($attributeName){ |
|
240 | - // toSlug should only work for existing attributes |
|
241 | - if(property_exists($this, $attributeName)){ |
|
242 | - $value = $this->$attributeName; |
|
243 | - // replace everything except alphanumeric with a single '-' |
|
244 | - $value = preg_replace('/[^A-Za-z0-9]+/', '-', $value); |
|
245 | - $value = strtolower($value); |
|
246 | - // trim '-' |
|
247 | - return trim($value, '-'); |
|
248 | - } else { |
|
249 | - throw new \BadFunctionCallException($attributeName . |
|
250 | - ' is not a valid attribute'); |
|
251 | - } |
|
252 | - } |
|
88 | + /** |
|
89 | + * Marks the entity as clean needed for setting the id after the insertion |
|
90 | + * @since 7.0.0 |
|
91 | + */ |
|
92 | + public function resetUpdatedFields(){ |
|
93 | + $this->_updatedFields = array(); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Generic setter for properties |
|
98 | + * @since 7.0.0 |
|
99 | + */ |
|
100 | + protected function setter($name, $args) { |
|
101 | + // setters should only work for existing attributes |
|
102 | + if(property_exists($this, $name)){ |
|
103 | + if($this->$name === $args[0]) { |
|
104 | + return; |
|
105 | + } |
|
106 | + $this->markFieldUpdated($name); |
|
107 | + |
|
108 | + // if type definition exists, cast to correct type |
|
109 | + if($args[0] !== null && array_key_exists($name, $this->_fieldTypes)) { |
|
110 | + settype($args[0], $this->_fieldTypes[$name]); |
|
111 | + } |
|
112 | + $this->$name = $args[0]; |
|
113 | + |
|
114 | + } else { |
|
115 | + throw new \BadFunctionCallException($name . |
|
116 | + ' is not a valid attribute'); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Generic getter for properties |
|
122 | + * @since 7.0.0 |
|
123 | + */ |
|
124 | + protected function getter($name) { |
|
125 | + // getters should only work for existing attributes |
|
126 | + if(property_exists($this, $name)){ |
|
127 | + return $this->$name; |
|
128 | + } else { |
|
129 | + throw new \BadFunctionCallException($name . |
|
130 | + ' is not a valid attribute'); |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * Each time a setter is called, push the part after set |
|
137 | + * into an array: for instance setId will save Id in the |
|
138 | + * updated fields array so it can be easily used to create the |
|
139 | + * getter method |
|
140 | + * @since 7.0.0 |
|
141 | + */ |
|
142 | + public function __call($methodName, $args){ |
|
143 | + $attr = lcfirst( substr($methodName, 3) ); |
|
144 | + |
|
145 | + if(strpos($methodName, 'set') === 0){ |
|
146 | + $this->setter($attr, $args); |
|
147 | + } elseif(strpos($methodName, 'get') === 0) { |
|
148 | + return $this->getter($attr); |
|
149 | + } else { |
|
150 | + throw new \BadFunctionCallException($methodName . |
|
151 | + ' does not exist'); |
|
152 | + } |
|
153 | + |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * Mark am attribute as updated |
|
159 | + * @param string $attribute the name of the attribute |
|
160 | + * @since 7.0.0 |
|
161 | + */ |
|
162 | + protected function markFieldUpdated($attribute){ |
|
163 | + $this->_updatedFields[$attribute] = true; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Transform a database columnname to a property |
|
169 | + * @param string $columnName the name of the column |
|
170 | + * @return string the property name |
|
171 | + * @since 7.0.0 |
|
172 | + */ |
|
173 | + public function columnToProperty($columnName){ |
|
174 | + $parts = explode('_', $columnName); |
|
175 | + $property = null; |
|
176 | + |
|
177 | + foreach($parts as $part){ |
|
178 | + if($property === null){ |
|
179 | + $property = $part; |
|
180 | + } else { |
|
181 | + $property .= ucfirst($part); |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + return $property; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * Transform a property to a database column name |
|
191 | + * @param string $property the name of the property |
|
192 | + * @return string the column name |
|
193 | + * @since 7.0.0 |
|
194 | + */ |
|
195 | + public function propertyToColumn($property){ |
|
196 | + $parts = preg_split('/(?=[A-Z])/', $property); |
|
197 | + $column = null; |
|
198 | + |
|
199 | + foreach($parts as $part){ |
|
200 | + if($column === null){ |
|
201 | + $column = $part; |
|
202 | + } else { |
|
203 | + $column .= '_' . lcfirst($part); |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + return $column; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @return array array of updated fields for update query |
|
213 | + * @since 7.0.0 |
|
214 | + */ |
|
215 | + public function getUpdatedFields(){ |
|
216 | + return $this->_updatedFields; |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * Adds type information for a field so that its automatically casted to |
|
222 | + * that value once its being returned from the database |
|
223 | + * @param string $fieldName the name of the attribute |
|
224 | + * @param string $type the type which will be used to call settype() |
|
225 | + * @since 7.0.0 |
|
226 | + */ |
|
227 | + protected function addType($fieldName, $type){ |
|
228 | + $this->_fieldTypes[$fieldName] = $type; |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * Slugify the value of a given attribute |
|
234 | + * Warning: This doesn't result in a unique value |
|
235 | + * @param string $attributeName the name of the attribute, which value should be slugified |
|
236 | + * @return string slugified value |
|
237 | + * @since 7.0.0 |
|
238 | + */ |
|
239 | + public function slugify($attributeName){ |
|
240 | + // toSlug should only work for existing attributes |
|
241 | + if(property_exists($this, $attributeName)){ |
|
242 | + $value = $this->$attributeName; |
|
243 | + // replace everything except alphanumeric with a single '-' |
|
244 | + $value = preg_replace('/[^A-Za-z0-9]+/', '-', $value); |
|
245 | + $value = strtolower($value); |
|
246 | + // trim '-' |
|
247 | + return trim($value, '-'); |
|
248 | + } else { |
|
249 | + throw new \BadFunctionCallException($attributeName . |
|
250 | + ' is not a valid attribute'); |
|
251 | + } |
|
252 | + } |
|
253 | 253 | |
254 | 254 | } |
@@ -33,32 +33,32 @@ |
||
33 | 33 | */ |
34 | 34 | interface IProviderFactory { |
35 | 35 | |
36 | - /** |
|
37 | - * IProviderFactory constructor. |
|
38 | - * @param IServerContainer $serverContainer |
|
39 | - * @since 9.0.0 |
|
40 | - */ |
|
41 | - public function __construct(IServerContainer $serverContainer); |
|
36 | + /** |
|
37 | + * IProviderFactory constructor. |
|
38 | + * @param IServerContainer $serverContainer |
|
39 | + * @since 9.0.0 |
|
40 | + */ |
|
41 | + public function __construct(IServerContainer $serverContainer); |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $id |
|
45 | - * @return IShareProvider |
|
46 | - * @throws ProviderException |
|
47 | - * @since 9.0.0 |
|
48 | - */ |
|
49 | - public function getProvider($id); |
|
43 | + /** |
|
44 | + * @param string $id |
|
45 | + * @return IShareProvider |
|
46 | + * @throws ProviderException |
|
47 | + * @since 9.0.0 |
|
48 | + */ |
|
49 | + public function getProvider($id); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param int $shareType |
|
53 | - * @return IShareProvider |
|
54 | - * @throws ProviderException |
|
55 | - * @since 9.0.0 |
|
56 | - */ |
|
57 | - public function getProviderForType($shareType); |
|
51 | + /** |
|
52 | + * @param int $shareType |
|
53 | + * @return IShareProvider |
|
54 | + * @throws ProviderException |
|
55 | + * @since 9.0.0 |
|
56 | + */ |
|
57 | + public function getProviderForType($shareType); |
|
58 | 58 | |
59 | - /** |
|
60 | - * @return IShareProvider[] |
|
61 | - * @since 11.0.0 |
|
62 | - */ |
|
63 | - public function getAllProviders(); |
|
59 | + /** |
|
60 | + * @return IShareProvider[] |
|
61 | + * @since 11.0.0 |
|
62 | + */ |
|
63 | + public function getAllProviders(); |
|
64 | 64 | } |