@@ -16,8 +16,8 @@ |
||
| 16 | 16 | |
| 17 | 17 | class Exception extends \Exception |
| 18 | 18 | { |
| 19 | - public function __construct(string $sMessage) |
|
| 20 | - { |
|
| 21 | - parent::__construct($sMessage); |
|
| 22 | - } |
|
| 19 | +public function __construct(string $sMessage) |
|
| 20 | +{ |
|
| 21 | +parent::__construct($sMessage); |
|
| 22 | +} |
|
| 23 | 23 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function cl(string $sClassName): mixed |
| 34 | 34 | { |
| 35 | - return \Jaxon\cl($sClassName); |
|
| 35 | +return \Jaxon\cl($sClassName); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | function rq(string $sClassName = ''): JxnCall |
| 46 | 46 | { |
| 47 | - return \Jaxon\rq($sClassName); |
|
| 47 | +return \Jaxon\rq($sClassName); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function jo(string $sJsObject = ''): JsObjectCall |
| 58 | 58 | { |
| 59 | - return \Jaxon\jo($sJsObject); |
|
| 59 | +return \Jaxon\jo($sJsObject); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function jq(string $sPath = '', $xContext = null): JqSelectorCall |
| 71 | 71 | { |
| 72 | - return \Jaxon\jq($sPath, $xContext); |
|
| 72 | +return \Jaxon\jq($sPath, $xContext); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function je(string $sElementId = ''): JsSelectorCall |
| 83 | 83 | { |
| 84 | - return \Jaxon\je($sElementId); |
|
| 84 | +return \Jaxon\je($sElementId); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -91,5 +91,5 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | function attr(): HtmlAttrHelper |
| 93 | 93 | { |
| 94 | - return \Jaxon\attr(); |
|
| 94 | +return \Jaxon\attr(); |
|
| 95 | 95 | } |
@@ -15,56 +15,56 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | class Target implements TargetInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * The target type for function. |
| 20 | 20 | * |
| 21 | 21 | * @var string |
| 22 | 22 | */ |
| 23 | - const TYPE_FUNCTION = 'TargetFunction'; |
|
| 23 | +const TYPE_FUNCTION = 'TargetFunction'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 25 | +/** |
|
| 26 | 26 | * The target type for class. |
| 27 | 27 | * |
| 28 | 28 | * @var string |
| 29 | 29 | */ |
| 30 | - const TYPE_CLASS = 'TargetClass'; |
|
| 30 | +const TYPE_CLASS = 'TargetClass'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * The target type. |
| 34 | 34 | * |
| 35 | 35 | * @var string |
| 36 | 36 | */ |
| 37 | - private $sType = ''; |
|
| 37 | +private $sType = ''; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * The target function name. |
| 41 | 41 | * |
| 42 | 42 | * @var string |
| 43 | 43 | */ |
| 44 | - private $sFunctionName = ''; |
|
| 44 | +private $sFunctionName = ''; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * The target class name. |
| 48 | 48 | * |
| 49 | 49 | * @var string |
| 50 | 50 | */ |
| 51 | - private $sClassName = ''; |
|
| 51 | +private $sClassName = ''; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | +/** |
|
| 54 | 54 | * The target method name. |
| 55 | 55 | * |
| 56 | 56 | * @var string |
| 57 | 57 | */ |
| 58 | - private $sMethodName = ''; |
|
| 58 | +private $sMethodName = ''; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * The target method args. |
| 62 | 62 | * |
| 63 | 63 | * @var array |
| 64 | 64 | */ |
| 65 | - private $aMethodArgs = []; |
|
| 65 | +private $aMethodArgs = []; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * The constructor |
| 69 | 69 | * |
| 70 | 70 | * @param string $sType The target type |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * @param string $sMethodName The method name |
| 74 | 74 | * @param array $aMethodArgs The method args |
| 75 | 75 | */ |
| 76 | - private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = []) |
|
| 77 | - { |
|
| 78 | - $this->sType = $sType; |
|
| 79 | - $this->sFunctionName = $sFunctionName; |
|
| 80 | - $this->sClassName = $sClassName; |
|
| 81 | - $this->sMethodName = $sMethodName; |
|
| 82 | - $this->aMethodArgs = $aMethodArgs; |
|
| 83 | - } |
|
| 76 | +private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = []) |
|
| 77 | +{ |
|
| 78 | +$this->sType = $sType; |
|
| 79 | +$this->sFunctionName = $sFunctionName; |
|
| 80 | +$this->sClassName = $sClassName; |
|
| 81 | +$this->sMethodName = $sMethodName; |
|
| 82 | +$this->aMethodArgs = $aMethodArgs; |
|
| 83 | +} |
|
| 84 | 84 | |
| 85 | - /** |
|
| 85 | +/** |
|
| 86 | 86 | * Create a target of type Function |
| 87 | 87 | * |
| 88 | 88 | * @param string $sFunctionName The function name |
| 89 | 89 | * |
| 90 | 90 | * @return Target |
| 91 | 91 | */ |
| 92 | - public static function makeFunction(string $sFunctionName): Target |
|
| 93 | - { |
|
| 94 | - return new Target(self::TYPE_FUNCTION, $sFunctionName, '', ''); |
|
| 95 | - } |
|
| 92 | +public static function makeFunction(string $sFunctionName): Target |
|
| 93 | +{ |
|
| 94 | +return new Target(self::TYPE_FUNCTION, $sFunctionName, '', ''); |
|
| 95 | +} |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | +/** |
|
| 98 | 98 | * Create a target of type Class |
| 99 | 99 | * |
| 100 | 100 | * @param string $sClassName The class name |
@@ -102,88 +102,88 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return Target |
| 104 | 104 | */ |
| 105 | - public static function makeClass(string $sClassName, string $sMethodName): Target |
|
| 106 | - { |
|
| 107 | - return new Target(self::TYPE_CLASS, '', $sClassName, $sMethodName); |
|
| 108 | - } |
|
| 105 | +public static function makeClass(string $sClassName, string $sMethodName): Target |
|
| 106 | +{ |
|
| 107 | +return new Target(self::TYPE_CLASS, '', $sClassName, $sMethodName); |
|
| 108 | +} |
|
| 109 | 109 | |
| 110 | - /** |
|
| 110 | +/** |
|
| 111 | 111 | * Check if the target type is Function. |
| 112 | 112 | * |
| 113 | 113 | * @return bool |
| 114 | 114 | */ |
| 115 | - public function isFunction(): bool |
|
| 116 | - { |
|
| 117 | - return $this->sType === self::TYPE_FUNCTION; |
|
| 118 | - } |
|
| 115 | +public function isFunction(): bool |
|
| 116 | +{ |
|
| 117 | +return $this->sType === self::TYPE_FUNCTION; |
|
| 118 | +} |
|
| 119 | 119 | |
| 120 | - /** |
|
| 120 | +/** |
|
| 121 | 121 | * Check if the target type is Class. |
| 122 | 122 | * |
| 123 | 123 | * @return bool |
| 124 | 124 | */ |
| 125 | - public function isClass(): bool |
|
| 126 | - { |
|
| 127 | - return $this->sType === self::TYPE_CLASS; |
|
| 128 | - } |
|
| 125 | +public function isClass(): bool |
|
| 126 | +{ |
|
| 127 | +return $this->sType === self::TYPE_CLASS; |
|
| 128 | +} |
|
| 129 | 129 | |
| 130 | - /** |
|
| 130 | +/** |
|
| 131 | 131 | * The target function name. |
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function getFunctionName(): string |
|
| 136 | - { |
|
| 137 | - return $this->sFunctionName; |
|
| 138 | - } |
|
| 135 | +public function getFunctionName(): string |
|
| 136 | +{ |
|
| 137 | +return $this->sFunctionName; |
|
| 138 | +} |
|
| 139 | 139 | |
| 140 | - /** |
|
| 140 | +/** |
|
| 141 | 141 | * The target class name. |
| 142 | 142 | * |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | - public function getClassName(): string |
|
| 146 | - { |
|
| 147 | - return $this->sClassName; |
|
| 148 | - } |
|
| 145 | +public function getClassName(): string |
|
| 146 | +{ |
|
| 147 | +return $this->sClassName; |
|
| 148 | +} |
|
| 149 | 149 | |
| 150 | - /** |
|
| 150 | +/** |
|
| 151 | 151 | * The target method name. |
| 152 | 152 | * |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - public function getMethodName(): string |
|
| 156 | - { |
|
| 157 | - return $this->sMethodName; |
|
| 158 | - } |
|
| 155 | +public function getMethodName(): string |
|
| 156 | +{ |
|
| 157 | +return $this->sMethodName; |
|
| 158 | +} |
|
| 159 | 159 | |
| 160 | - /** |
|
| 160 | +/** |
|
| 161 | 161 | * Set the target method name. |
| 162 | 162 | * |
| 163 | 163 | * @param array $aMethodArgs |
| 164 | 164 | */ |
| 165 | - public function setMethodArgs(array $aMethodArgs): void |
|
| 166 | - { |
|
| 167 | - $this->aMethodArgs = $aMethodArgs; |
|
| 168 | - } |
|
| 165 | +public function setMethodArgs(array $aMethodArgs): void |
|
| 166 | +{ |
|
| 167 | +$this->aMethodArgs = $aMethodArgs; |
|
| 168 | +} |
|
| 169 | 169 | |
| 170 | - /** |
|
| 170 | +/** |
|
| 171 | 171 | * The target method name. |
| 172 | 172 | * |
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | - public function method(): string |
|
| 176 | - { |
|
| 177 | - return $this->sMethodName; |
|
| 178 | - } |
|
| 175 | +public function method(): string |
|
| 176 | +{ |
|
| 177 | +return $this->sMethodName; |
|
| 178 | +} |
|
| 179 | 179 | |
| 180 | - /** |
|
| 180 | +/** |
|
| 181 | 181 | * The target method args. |
| 182 | 182 | * |
| 183 | 183 | * @return array |
| 184 | 184 | */ |
| 185 | - public function args(): array |
|
| 186 | - { |
|
| 187 | - return $this->aMethodArgs; |
|
| 188 | - } |
|
| 185 | +public function args(): array |
|
| 186 | +{ |
|
| 187 | +return $this->aMethodArgs; |
|
| 188 | +} |
|
| 189 | 189 | } |
@@ -4,17 +4,17 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface TargetInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * The target method name. |
| 9 | 9 | * |
| 10 | 10 | * @return string |
| 11 | 11 | */ |
| 12 | - public function method(): string; |
|
| 12 | +public function method(): string; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * The target method args. |
| 16 | 16 | * |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | - public function args(): array; |
|
| 19 | +public function args(): array; |
|
| 20 | 20 | } |
@@ -29,73 +29,73 @@ |
||
| 29 | 29 | |
| 30 | 30 | class Validator |
| 31 | 31 | { |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * The config manager |
| 34 | 34 | * |
| 35 | 35 | * @var ConfigManager |
| 36 | 36 | */ |
| 37 | - protected $xConfigManager; |
|
| 37 | +protected $xConfigManager; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * The translator |
| 41 | 41 | * |
| 42 | 42 | * @var Translator |
| 43 | 43 | */ |
| 44 | - protected $xTranslator; |
|
| 44 | +protected $xTranslator; |
|
| 45 | 45 | |
| 46 | - public function __construct(ConfigManager $xConfigManager, Translator $xTranslator) |
|
| 47 | - { |
|
| 48 | - // Set the config manager |
|
| 49 | - $this->xConfigManager = $xConfigManager; |
|
| 50 | - // Set the translator |
|
| 51 | - $this->xTranslator = $xTranslator; |
|
| 52 | - } |
|
| 46 | +public function __construct(ConfigManager $xConfigManager, Translator $xTranslator) |
|
| 47 | +{ |
|
| 48 | +// Set the config manager |
|
| 49 | +$this->xConfigManager = $xConfigManager; |
|
| 50 | +// Set the translator |
|
| 51 | +$this->xTranslator = $xTranslator; |
|
| 52 | +} |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | +/** |
|
| 55 | 55 | * Validate a function name |
| 56 | 56 | * |
| 57 | 57 | * @param string $sName The function name |
| 58 | 58 | * |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function validateFunction(string $sName): bool |
|
| 62 | - { |
|
| 63 | - return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $sName) > 0; |
|
| 64 | - } |
|
| 61 | +public function validateFunction(string $sName): bool |
|
| 62 | +{ |
|
| 63 | +return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $sName) > 0; |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Validate a class name |
| 68 | 68 | * |
| 69 | 69 | * @param string $sName The class name |
| 70 | 70 | * |
| 71 | 71 | * @return bool |
| 72 | 72 | */ |
| 73 | - public function validateJsObject(string $sName): bool |
|
| 74 | - { |
|
| 75 | - return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\.[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 76 | - } |
|
| 73 | +public function validateJsObject(string $sName): bool |
|
| 74 | +{ |
|
| 75 | +return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\.[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 76 | +} |
|
| 77 | 77 | |
| 78 | - /** |
|
| 78 | +/** |
|
| 79 | 79 | * Validate a class name |
| 80 | 80 | * |
| 81 | 81 | * @param string $sName The class name |
| 82 | 82 | * |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - public function validateClass(string $sName): bool |
|
| 86 | - { |
|
| 87 | - return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 88 | - } |
|
| 85 | +public function validateClass(string $sName): bool |
|
| 86 | +{ |
|
| 87 | +return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 88 | +} |
|
| 89 | 89 | |
| 90 | - /** |
|
| 90 | +/** |
|
| 91 | 91 | * Validate a method name |
| 92 | 92 | * |
| 93 | 93 | * @param string $sName The function name |
| 94 | 94 | * |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - public function validateMethod(string $sName): bool |
|
| 98 | - { |
|
| 99 | - return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sName) > 0; |
|
| 100 | - } |
|
| 97 | +public function validateMethod(string $sName): bool |
|
| 98 | +{ |
|
| 99 | +return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sName) > 0; |
|
| 100 | +} |
|
| 101 | 101 | } |
@@ -25,54 +25,54 @@ |
||
| 25 | 25 | |
| 26 | 26 | class PsrAjaxMiddleware implements MiddlewareInterface |
| 27 | 27 | { |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * @var Container |
| 30 | 30 | */ |
| 31 | - private $di; |
|
| 31 | +private $di; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * @var RequestHandler |
| 35 | 35 | */ |
| 36 | - private $xRequestHandler; |
|
| 36 | +private $xRequestHandler; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @var ResponseManager |
| 40 | 40 | */ |
| 41 | - private $xResponseManager; |
|
| 41 | +private $xResponseManager; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * The constructor |
| 45 | 45 | * |
| 46 | 46 | * @param Container $di |
| 47 | 47 | * @param RequestHandler $xRequestHandler |
| 48 | 48 | * @param ResponseManager $xResponseManager |
| 49 | 49 | */ |
| 50 | - public function __construct(Container $di, RequestHandler $xRequestHandler, ResponseManager $xResponseManager) |
|
| 51 | - { |
|
| 52 | - $this->di = $di; |
|
| 53 | - $this->xRequestHandler = $xRequestHandler; |
|
| 54 | - $this->xResponseManager = $xResponseManager; |
|
| 55 | - } |
|
| 50 | +public function __construct(Container $di, RequestHandler $xRequestHandler, ResponseManager $xResponseManager) |
|
| 51 | +{ |
|
| 52 | +$this->di = $di; |
|
| 53 | +$this->xRequestHandler = $xRequestHandler; |
|
| 54 | +$this->xResponseManager = $xResponseManager; |
|
| 55 | +} |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | +/** |
|
| 58 | 58 | * @inheritDoc |
| 59 | 59 | * @throws RequestException |
| 60 | 60 | */ |
| 61 | - public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 62 | - { |
|
| 63 | - // Save the request in the container. This will override the default request, |
|
| 64 | - // and the other classes will get this request from there. |
|
| 65 | - $this->di->val(ServerRequestInterface::class, $request); |
|
| 61 | +public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 62 | +{ |
|
| 63 | +// Save the request in the container. This will override the default request, |
|
| 64 | +// and the other classes will get this request from there. |
|
| 65 | +$this->di->val(ServerRequestInterface::class, $request); |
|
| 66 | 66 | |
| 67 | - if(!$this->xRequestHandler->canProcessRequest()) |
|
| 68 | - { |
|
| 69 | - // Unable to find a plugin to process the request |
|
| 70 | - return $handler->handle($request); |
|
| 71 | - } |
|
| 67 | +if(!$this->xRequestHandler->canProcessRequest()) |
|
| 68 | +{ |
|
| 69 | +// Unable to find a plugin to process the request |
|
| 70 | +return $handler->handle($request); |
|
| 71 | +} |
|
| 72 | 72 | |
| 73 | - // Process the request |
|
| 74 | - $this->xRequestHandler->processRequest(); |
|
| 75 | - // Return a Psr7 response |
|
| 76 | - return $this->xResponseManager->getResponse()->toPsr(); |
|
| 77 | - } |
|
| 73 | +// Process the request |
|
| 74 | +$this->xRequestHandler->processRequest(); |
|
| 75 | +// Return a Psr7 response |
|
| 76 | +return $this->xResponseManager->getResponse()->toPsr(); |
|
| 77 | +} |
|
| 78 | 78 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | // and the other classes will get this request from there. |
| 65 | 65 | $this->di->val(ServerRequestInterface::class, $request); |
| 66 | 66 | |
| 67 | - if(!$this->xRequestHandler->canProcessRequest()) |
|
| 67 | + if (!$this->xRequestHandler->canProcessRequest()) |
|
| 68 | 68 | { |
| 69 | 69 | // Unable to find a plugin to process the request |
| 70 | 70 | return $handler->handle($request); |
@@ -23,37 +23,37 @@ |
||
| 23 | 23 | |
| 24 | 24 | class PsrConfigMiddleware implements MiddlewareInterface |
| 25 | 25 | { |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @var Container |
| 28 | 28 | */ |
| 29 | - protected $di; |
|
| 29 | +protected $di; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * @var string |
| 33 | 33 | */ |
| 34 | - protected $sConfigFile; |
|
| 34 | +protected $sConfigFile; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * The constructor |
| 38 | 38 | * |
| 39 | 39 | * @param Container $di |
| 40 | 40 | * @param string $sConfigFile |
| 41 | 41 | */ |
| 42 | - public function __construct(Container $di, string $sConfigFile) |
|
| 43 | - { |
|
| 44 | - $this->di = $di; |
|
| 45 | - $this->sConfigFile = $sConfigFile; |
|
| 46 | - } |
|
| 42 | +public function __construct(Container $di, string $sConfigFile) |
|
| 43 | +{ |
|
| 44 | +$this->di = $di; |
|
| 45 | +$this->sConfigFile = $sConfigFile; |
|
| 46 | +} |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * @inheritDoc |
| 50 | 50 | * @throws SetupException |
| 51 | 51 | */ |
| 52 | - public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 53 | - { |
|
| 54 | - // Load the config |
|
| 55 | - $this->di->getApp()->setup($this->sConfigFile); |
|
| 56 | - // Next |
|
| 57 | - return $handler->handle($request); |
|
| 58 | - } |
|
| 52 | +public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 53 | +{ |
|
| 54 | +// Load the config |
|
| 55 | +$this->di->getApp()->setup($this->sConfigFile); |
|
| 56 | +// Next |
|
| 57 | +return $handler->handle($request); |
|
| 58 | +} |
|
| 59 | 59 | } |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | class PsrRequestHandler implements RequestHandlerInterface |
| 27 | 27 | { |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * @var Container |
| 30 | 30 | */ |
| 31 | - private $di; |
|
| 31 | +private $di; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * @var RequestHandler |
| 35 | 35 | */ |
| 36 | - private $xRequestHandler; |
|
| 36 | +private $xRequestHandler; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @var ResponseManager |
| 40 | 40 | */ |
| 41 | - private $xResponseManager; |
|
| 41 | +private $xResponseManager; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * @var Translator |
| 45 | 45 | */ |
| 46 | - private $xTranslator; |
|
| 46 | +private $xTranslator; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * The constructor |
| 50 | 50 | * |
| 51 | 51 | * @param Container $di |
@@ -53,34 +53,34 @@ discard block |
||
| 53 | 53 | * @param ResponseManager $xResponseManager |
| 54 | 54 | * @param Translator $xTranslator |
| 55 | 55 | */ |
| 56 | - public function __construct(Container $di, RequestHandler $xRequestHandler, |
|
| 57 | - ResponseManager $xResponseManager, Translator $xTranslator) |
|
| 58 | - { |
|
| 59 | - $this->di = $di; |
|
| 60 | - $this->xRequestHandler = $xRequestHandler; |
|
| 61 | - $this->xResponseManager = $xResponseManager; |
|
| 62 | - $this->xTranslator = $xTranslator; |
|
| 63 | - } |
|
| 56 | +public function __construct(Container $di, RequestHandler $xRequestHandler, |
|
| 57 | +ResponseManager $xResponseManager, Translator $xTranslator) |
|
| 58 | +{ |
|
| 59 | +$this->di = $di; |
|
| 60 | +$this->xRequestHandler = $xRequestHandler; |
|
| 61 | +$this->xResponseManager = $xResponseManager; |
|
| 62 | +$this->xTranslator = $xTranslator; |
|
| 63 | +} |
|
| 64 | 64 | |
| 65 | - /** |
|
| 65 | +/** |
|
| 66 | 66 | * @inheritDoc |
| 67 | 67 | * @throws RequestException |
| 68 | 68 | */ |
| 69 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 70 | - { |
|
| 71 | - // Save the request in the container. This will override the default request, |
|
| 72 | - // and the other classes will get this request from there. |
|
| 73 | - $this->di->val(ServerRequestInterface::class, $request); |
|
| 69 | +public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 70 | +{ |
|
| 71 | +// Save the request in the container. This will override the default request, |
|
| 72 | +// and the other classes will get this request from there. |
|
| 73 | +$this->di->val(ServerRequestInterface::class, $request); |
|
| 74 | 74 | |
| 75 | - if(!$this->xRequestHandler->canProcessRequest()) |
|
| 76 | - { |
|
| 77 | - // Unable to find a plugin to process the request |
|
| 78 | - throw new RequestException($this->xTranslator->trans('errors.request.plugin')); |
|
| 79 | - } |
|
| 75 | +if(!$this->xRequestHandler->canProcessRequest()) |
|
| 76 | +{ |
|
| 77 | +// Unable to find a plugin to process the request |
|
| 78 | +throw new RequestException($this->xTranslator->trans('errors.request.plugin')); |
|
| 79 | +} |
|
| 80 | 80 | |
| 81 | - // Process the request |
|
| 82 | - $this->xRequestHandler->processRequest(); |
|
| 83 | - // Return a Psr7 response |
|
| 84 | - return $this->xResponseManager->getResponse()->toPsr(); |
|
| 85 | - } |
|
| 81 | +// Process the request |
|
| 82 | +$this->xRequestHandler->processRequest(); |
|
| 83 | +// Return a Psr7 response |
|
| 84 | +return $this->xResponseManager->getResponse()->toPsr(); |
|
| 85 | +} |
|
| 86 | 86 | } |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | // and the other classes will get this request from there. |
| 73 | 73 | $this->di->val(ServerRequestInterface::class, $request); |
| 74 | 74 | |
| 75 | - if(!$this->xRequestHandler->canProcessRequest()) |
|
| 75 | + if (!$this->xRequestHandler->canProcessRequest()) |
|
| 76 | 76 | { |
| 77 | 77 | // Unable to find a plugin to process the request |
| 78 | 78 | throw new RequestException($this->xTranslator->trans('errors.request.plugin')); |
@@ -22,50 +22,50 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | class PsrFactory |
| 24 | 24 | { |
| 25 | - /** |
|
| 25 | +/** |
|
| 26 | 26 | * The container |
| 27 | 27 | * |
| 28 | 28 | * @var Container |
| 29 | 29 | */ |
| 30 | - protected $di; |
|
| 30 | +protected $di; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * The constructor |
| 34 | 34 | * |
| 35 | 35 | * @param Container $di |
| 36 | 36 | */ |
| 37 | - public function __construct(Container $di) |
|
| 38 | - { |
|
| 39 | - $this->di = $di; |
|
| 40 | - } |
|
| 37 | +public function __construct(Container $di) |
|
| 38 | +{ |
|
| 39 | +$this->di = $di; |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - /** |
|
| 42 | +/** |
|
| 43 | 43 | * Set the logger |
| 44 | 44 | * |
| 45 | 45 | * @param LoggerInterface $xLogger |
| 46 | 46 | * |
| 47 | 47 | * @return $this |
| 48 | 48 | */ |
| 49 | - public function logger(LoggerInterface $xLogger): PsrFactory |
|
| 50 | - { |
|
| 51 | - $this->di->setLogger($xLogger); |
|
| 52 | - return $this; |
|
| 53 | - } |
|
| 49 | +public function logger(LoggerInterface $xLogger): PsrFactory |
|
| 50 | +{ |
|
| 51 | +$this->di->setLogger($xLogger); |
|
| 52 | +return $this; |
|
| 53 | +} |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * Set the container |
| 57 | 57 | * |
| 58 | 58 | * @param ContainerInterface $xContainer |
| 59 | 59 | * |
| 60 | 60 | * @return $this |
| 61 | 61 | */ |
| 62 | - public function container(ContainerInterface $xContainer): PsrFactory |
|
| 63 | - { |
|
| 64 | - $this->di->setContainer($xContainer); |
|
| 65 | - return $this; |
|
| 66 | - } |
|
| 62 | +public function container(ContainerInterface $xContainer): PsrFactory |
|
| 63 | +{ |
|
| 64 | +$this->di->setContainer($xContainer); |
|
| 65 | +return $this; |
|
| 66 | +} |
|
| 67 | 67 | |
| 68 | - /** |
|
| 68 | +/** |
|
| 69 | 69 | * Add a view renderer with an id |
| 70 | 70 | * |
| 71 | 71 | * @param string $sRenderer The renderer name |
@@ -74,41 +74,41 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return $this |
| 76 | 76 | */ |
| 77 | - public function view(string $sRenderer, string $sExtension, Closure $xClosure): PsrFactory |
|
| 78 | - { |
|
| 79 | - $this->di->getViewRenderer()->setDefaultRenderer($sRenderer, $sExtension, $xClosure); |
|
| 80 | - return $this; |
|
| 81 | - } |
|
| 77 | +public function view(string $sRenderer, string $sExtension, Closure $xClosure): PsrFactory |
|
| 78 | +{ |
|
| 79 | +$this->di->getViewRenderer()->setDefaultRenderer($sRenderer, $sExtension, $xClosure); |
|
| 80 | +return $this; |
|
| 81 | +} |
|
| 82 | 82 | |
| 83 | - /** |
|
| 83 | +/** |
|
| 84 | 84 | * Get the Jaxon ajax PSR request handler |
| 85 | 85 | * |
| 86 | 86 | * @return PsrRequestHandler |
| 87 | 87 | */ |
| 88 | - public function handler(): PsrRequestHandler |
|
| 89 | - { |
|
| 90 | - return $this->di->getPsrRequestHandler(); |
|
| 91 | - } |
|
| 88 | +public function handler(): PsrRequestHandler |
|
| 89 | +{ |
|
| 90 | +return $this->di->getPsrRequestHandler(); |
|
| 91 | +} |
|
| 92 | 92 | |
| 93 | - /** |
|
| 93 | +/** |
|
| 94 | 94 | * Get the Jaxon config PSR middleware |
| 95 | 95 | * |
| 96 | 96 | * @param string $sConfigFile |
| 97 | 97 | * |
| 98 | 98 | * @return PsrConfigMiddleware |
| 99 | 99 | */ |
| 100 | - public function config(string $sConfigFile): PsrConfigMiddleware |
|
| 101 | - { |
|
| 102 | - return $this->di->getPsrConfigMiddleware($sConfigFile); |
|
| 103 | - } |
|
| 100 | +public function config(string $sConfigFile): PsrConfigMiddleware |
|
| 101 | +{ |
|
| 102 | +return $this->di->getPsrConfigMiddleware($sConfigFile); |
|
| 103 | +} |
|
| 104 | 104 | |
| 105 | - /** |
|
| 105 | +/** |
|
| 106 | 106 | * Get the Jaxon ajax PSR middleware |
| 107 | 107 | * |
| 108 | 108 | * @return PsrAjaxMiddleware |
| 109 | 109 | */ |
| 110 | - public function ajax(): PsrAjaxMiddleware |
|
| 111 | - { |
|
| 112 | - return $this->di->getPsrAjaxMiddleware(); |
|
| 113 | - } |
|
| 110 | +public function ajax(): PsrAjaxMiddleware |
|
| 111 | +{ |
|
| 112 | +return $this->di->getPsrAjaxMiddleware(); |
|
| 113 | +} |
|
| 114 | 114 | } |