@@ -237,7 +237,7 @@ |
||
| 237 | 237 | */ |
| 238 | 238 | public function val(string $sKey, $xValue) |
| 239 | 239 | { |
| 240 | - $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 240 | + $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -29,145 +29,145 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | class Container |
| 31 | 31 | { |
| 32 | - use Traits\AppTrait; |
|
| 33 | - use Traits\PsrTrait; |
|
| 34 | - use Traits\RequestTrait; |
|
| 35 | - use Traits\ResponseTrait; |
|
| 36 | - use Traits\PluginTrait; |
|
| 37 | - use Traits\CallableTrait; |
|
| 38 | - use Traits\ViewTrait; |
|
| 39 | - use Traits\UtilTrait; |
|
| 40 | - use Traits\MetadataTrait; |
|
| 41 | - use Traits\DiAutoTrait; |
|
| 32 | +use Traits\AppTrait; |
|
| 33 | +use Traits\PsrTrait; |
|
| 34 | +use Traits\RequestTrait; |
|
| 35 | +use Traits\ResponseTrait; |
|
| 36 | +use Traits\PluginTrait; |
|
| 37 | +use Traits\CallableTrait; |
|
| 38 | +use Traits\ViewTrait; |
|
| 39 | +use Traits\UtilTrait; |
|
| 40 | +use Traits\MetadataTrait; |
|
| 41 | +use Traits\DiAutoTrait; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * The library Dependency Injection Container |
| 45 | 45 | * |
| 46 | 46 | * @var PimpleContainer |
| 47 | 47 | */ |
| 48 | - private $xLibContainer; |
|
| 48 | +private $xLibContainer; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * The application or framework Dependency Injection Container |
| 52 | 52 | * |
| 53 | 53 | * @var ContainerInterface |
| 54 | 54 | */ |
| 55 | - private $xAppContainer = null; |
|
| 55 | +private $xAppContainer = null; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | +/** |
|
| 58 | 58 | * The class constructor |
| 59 | 59 | */ |
| 60 | - public function __construct() |
|
| 61 | - { |
|
| 62 | - $this->xLibContainer = new PimpleContainer(); |
|
| 60 | +public function __construct() |
|
| 61 | +{ |
|
| 62 | +$this->xLibContainer = new PimpleContainer(); |
|
| 63 | 63 | |
| 64 | - $this->val(Container::class, $this); |
|
| 64 | +$this->val(Container::class, $this); |
|
| 65 | 65 | |
| 66 | - // Register the null logger by default |
|
| 67 | - $this->setLogger(new NullLogger()); |
|
| 66 | +// Register the null logger by default |
|
| 67 | +$this->setLogger(new NullLogger()); |
|
| 68 | 68 | |
| 69 | - // Template directory |
|
| 70 | - $sTemplateDir = realpath(__DIR__ . '/../../templates'); |
|
| 71 | - $this->val('jaxon.core.dir.template', $sTemplateDir); |
|
| 69 | +// Template directory |
|
| 70 | +$sTemplateDir = realpath(__DIR__ . '/../../templates'); |
|
| 71 | +$this->val('jaxon.core.dir.template', $sTemplateDir); |
|
| 72 | 72 | |
| 73 | - // Translation directory |
|
| 74 | - $sTranslationDir = realpath(__DIR__ . '/../../translations'); |
|
| 75 | - $this->val('jaxon.core.dir.translation', $sTranslationDir); |
|
| 73 | +// Translation directory |
|
| 74 | +$sTranslationDir = realpath(__DIR__ . '/../../translations'); |
|
| 75 | +$this->val('jaxon.core.dir.translation', $sTranslationDir); |
|
| 76 | 76 | |
| 77 | - $this->registerAll(); |
|
| 78 | - $this->setEventHandlers(); |
|
| 79 | - } |
|
| 77 | +$this->registerAll(); |
|
| 78 | +$this->setEventHandlers(); |
|
| 79 | +} |
|
| 80 | 80 | |
| 81 | - /** |
|
| 81 | +/** |
|
| 82 | 82 | * The container for parameters |
| 83 | 83 | * |
| 84 | 84 | * @return Container |
| 85 | 85 | */ |
| 86 | - protected function cn(): Container |
|
| 87 | - { |
|
| 88 | - return $this; |
|
| 89 | - } |
|
| 86 | +protected function cn(): Container |
|
| 87 | +{ |
|
| 88 | +return $this; |
|
| 89 | +} |
|
| 90 | 90 | |
| 91 | - /** |
|
| 91 | +/** |
|
| 92 | 92 | * Register the values into the container |
| 93 | 93 | * |
| 94 | 94 | * @return void |
| 95 | 95 | */ |
| 96 | - private function registerAll() |
|
| 97 | - { |
|
| 98 | - $this->registerApp(); |
|
| 99 | - $this->registerPsr(); |
|
| 100 | - $this->registerRequests(); |
|
| 101 | - $this->registerResponses(); |
|
| 102 | - $this->registerPlugins(); |
|
| 103 | - $this->registerCallables(); |
|
| 104 | - $this->registerViews(); |
|
| 105 | - $this->registerUtils(); |
|
| 106 | - $this->registerMetadataReader(); |
|
| 107 | - } |
|
| 96 | +private function registerAll() |
|
| 97 | +{ |
|
| 98 | +$this->registerApp(); |
|
| 99 | +$this->registerPsr(); |
|
| 100 | +$this->registerRequests(); |
|
| 101 | +$this->registerResponses(); |
|
| 102 | +$this->registerPlugins(); |
|
| 103 | +$this->registerCallables(); |
|
| 104 | +$this->registerViews(); |
|
| 105 | +$this->registerUtils(); |
|
| 106 | +$this->registerMetadataReader(); |
|
| 107 | +} |
|
| 108 | 108 | |
| 109 | - /** |
|
| 109 | +/** |
|
| 110 | 110 | * Set the logger |
| 111 | 111 | * |
| 112 | 112 | * @param LoggerInterface|Closure $xLogger |
| 113 | 113 | * |
| 114 | 114 | * @return void |
| 115 | 115 | */ |
| 116 | - public function setLogger(LoggerInterface|Closure $xLogger) |
|
| 117 | - { |
|
| 118 | - is_a($xLogger, LoggerInterface::class) ? |
|
| 119 | - $this->val(LoggerInterface::class, $xLogger) : |
|
| 120 | - $this->set(LoggerInterface::class, $xLogger); |
|
| 121 | - } |
|
| 116 | +public function setLogger(LoggerInterface|Closure $xLogger) |
|
| 117 | +{ |
|
| 118 | +is_a($xLogger, LoggerInterface::class) ? |
|
| 119 | +$this->val(LoggerInterface::class, $xLogger) : |
|
| 120 | +$this->set(LoggerInterface::class, $xLogger); |
|
| 121 | +} |
|
| 122 | 122 | |
| 123 | - /** |
|
| 123 | +/** |
|
| 124 | 124 | * Get the logger |
| 125 | 125 | * |
| 126 | 126 | * @return LoggerInterface |
| 127 | 127 | */ |
| 128 | - public function getLogger(): LoggerInterface |
|
| 129 | - { |
|
| 130 | - return $this->get(LoggerInterface::class); |
|
| 131 | - } |
|
| 128 | +public function getLogger(): LoggerInterface |
|
| 129 | +{ |
|
| 130 | +return $this->get(LoggerInterface::class); |
|
| 131 | +} |
|
| 132 | 132 | |
| 133 | - /** |
|
| 133 | +/** |
|
| 134 | 134 | * Set the container provided by the integrated framework |
| 135 | 135 | * |
| 136 | 136 | * @param ContainerInterface $xContainer The container implementation |
| 137 | 137 | * |
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | - public function setContainer(ContainerInterface $xContainer) |
|
| 141 | - { |
|
| 142 | - $this->xAppContainer = $xContainer; |
|
| 143 | - } |
|
| 140 | +public function setContainer(ContainerInterface $xContainer) |
|
| 141 | +{ |
|
| 142 | +$this->xAppContainer = $xContainer; |
|
| 143 | +} |
|
| 144 | 144 | |
| 145 | - /** |
|
| 145 | +/** |
|
| 146 | 146 | * Check if a class is defined in the container |
| 147 | 147 | * |
| 148 | 148 | * @param string $sClass The full class name |
| 149 | 149 | * |
| 150 | 150 | * @return bool |
| 151 | 151 | */ |
| 152 | - public function h(string $sClass): bool |
|
| 153 | - { |
|
| 154 | - return $this->xLibContainer->offsetExists($sClass); |
|
| 155 | - } |
|
| 152 | +public function h(string $sClass): bool |
|
| 153 | +{ |
|
| 154 | +return $this->xLibContainer->offsetExists($sClass); |
|
| 155 | +} |
|
| 156 | 156 | |
| 157 | - /** |
|
| 157 | +/** |
|
| 158 | 158 | * Check if a class is defined in the container |
| 159 | 159 | * |
| 160 | 160 | * @param string $sClass The full class name |
| 161 | 161 | * |
| 162 | 162 | * @return bool |
| 163 | 163 | */ |
| 164 | - public function has(string $sClass): bool |
|
| 165 | - { |
|
| 166 | - return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ? |
|
| 167 | - true : $this->xLibContainer->offsetExists($sClass); |
|
| 168 | - } |
|
| 164 | +public function has(string $sClass): bool |
|
| 165 | +{ |
|
| 166 | +return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ? |
|
| 167 | +true : $this->xLibContainer->offsetExists($sClass); |
|
| 168 | +} |
|
| 169 | 169 | |
| 170 | - /** |
|
| 170 | +/** |
|
| 171 | 171 | * Get a class instance |
| 172 | 172 | * |
| 173 | 173 | * @template T |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return T |
| 177 | 177 | */ |
| 178 | - public function g(string $sClass): mixed |
|
| 179 | - { |
|
| 180 | - return $this->xLibContainer->offsetGet($sClass); |
|
| 181 | - } |
|
| 178 | +public function g(string $sClass): mixed |
|
| 179 | +{ |
|
| 180 | +return $this->xLibContainer->offsetGet($sClass); |
|
| 181 | +} |
|
| 182 | 182 | |
| 183 | - /** |
|
| 183 | +/** |
|
| 184 | 184 | * Get a class instance |
| 185 | 185 | * |
| 186 | 186 | * @template T |
@@ -189,24 +189,24 @@ discard block |
||
| 189 | 189 | * @return T |
| 190 | 190 | * @throws SetupException |
| 191 | 191 | */ |
| 192 | - public function get(string $sClass): mixed |
|
| 193 | - { |
|
| 194 | - try |
|
| 195 | - { |
|
| 196 | - return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ? |
|
| 197 | - $this->xAppContainer->get($sClass) : $this->xLibContainer->offsetGet($sClass); |
|
| 198 | - } |
|
| 199 | - catch(Throwable $e) |
|
| 200 | - { |
|
| 201 | - $xLogger = $this->g(LoggerInterface::class); |
|
| 202 | - $xTranslator = $this->g(Translator::class); |
|
| 203 | - $sMessage = $e->getMessage() . ': ' . $xTranslator->trans('errors.class.container', ['name' => $sClass]); |
|
| 204 | - $xLogger->error($e->getMessage(), ['message' => $sMessage]); |
|
| 205 | - throw new SetupException($sMessage); |
|
| 206 | - } |
|
| 207 | - } |
|
| 192 | +public function get(string $sClass): mixed |
|
| 193 | +{ |
|
| 194 | +try |
|
| 195 | +{ |
|
| 196 | +return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ? |
|
| 197 | + $this->xAppContainer->get($sClass) : $this->xLibContainer->offsetGet($sClass); |
|
| 198 | +} |
|
| 199 | +catch(Throwable $e) |
|
| 200 | +{ |
|
| 201 | +$xLogger = $this->g(LoggerInterface::class); |
|
| 202 | +$xTranslator = $this->g(Translator::class); |
|
| 203 | +$sMessage = $e->getMessage() . ': ' . $xTranslator->trans('errors.class.container', ['name' => $sClass]); |
|
| 204 | +$xLogger->error($e->getMessage(), ['message' => $sMessage]); |
|
| 205 | +throw new SetupException($sMessage); |
|
| 206 | +} |
|
| 207 | +} |
|
| 208 | 208 | |
| 209 | - /** |
|
| 209 | +/** |
|
| 210 | 210 | * Save a closure in the container |
| 211 | 211 | * |
| 212 | 212 | * @param string|class-string $sClass The full class name |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return void |
| 217 | 217 | */ |
| 218 | - public function set(string $sClass, Closure $xClosure, bool $bIsSingleton = true) |
|
| 219 | - { |
|
| 220 | - // Wrap the user closure into a new closure, so it can take this container as a parameter. |
|
| 221 | - $xClosure = fn() => $xClosure($this); |
|
| 222 | - $this->xLibContainer->offsetSet($sClass, $bIsSingleton ? |
|
| 223 | - $xClosure : $this->xLibContainer->factory($xClosure)); |
|
| 224 | - } |
|
| 218 | +public function set(string $sClass, Closure $xClosure, bool $bIsSingleton = true) |
|
| 219 | +{ |
|
| 220 | +// Wrap the user closure into a new closure, so it can take this container as a parameter. |
|
| 221 | +$xClosure = fn() => $xClosure($this); |
|
| 222 | +$this->xLibContainer->offsetSet($sClass, $bIsSingleton ? |
|
| 223 | +$xClosure : $this->xLibContainer->factory($xClosure)); |
|
| 224 | +} |
|
| 225 | 225 | |
| 226 | - /** |
|
| 226 | +/** |
|
| 227 | 227 | * Save a value in the container |
| 228 | 228 | * |
| 229 | 229 | * @param string|class-string $sKey The key |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return void |
| 233 | 233 | */ |
| 234 | - public function val(string $sKey, $xValue) |
|
| 235 | - { |
|
| 236 | - $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 237 | - } |
|
| 234 | +public function val(string $sKey, $xValue) |
|
| 235 | +{ |
|
| 236 | +$this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 237 | +} |
|
| 238 | 238 | |
| 239 | - /** |
|
| 239 | +/** |
|
| 240 | 240 | * Set an alias in the container |
| 241 | 241 | * |
| 242 | 242 | * @param string|class-string $sAlias The alias name |
@@ -244,32 +244,32 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return void |
| 246 | 246 | */ |
| 247 | - public function alias(string $sAlias, string $sClass) |
|
| 248 | - { |
|
| 249 | - $this->set($sAlias, function($di) use ($sClass) { |
|
| 250 | - return $di->get($sClass); |
|
| 251 | - }); |
|
| 252 | - } |
|
| 247 | +public function alias(string $sAlias, string $sClass) |
|
| 248 | +{ |
|
| 249 | +$this->set($sAlias, function($di) use ($sClass) { |
|
| 250 | +return $di->get($sClass); |
|
| 251 | +}); |
|
| 252 | +} |
|
| 253 | 253 | |
| 254 | - /** |
|
| 254 | +/** |
|
| 255 | 255 | * Get the session manager |
| 256 | 256 | * |
| 257 | 257 | * @return SessionInterface|null |
| 258 | 258 | */ |
| 259 | - public function getSessionManager(): ?SessionInterface |
|
| 260 | - { |
|
| 261 | - return $this->h(SessionInterface::class) ? $this->g(SessionInterface::class) : null; |
|
| 262 | - } |
|
| 259 | +public function getSessionManager(): ?SessionInterface |
|
| 260 | +{ |
|
| 261 | +return $this->h(SessionInterface::class) ? $this->g(SessionInterface::class) : null; |
|
| 262 | +} |
|
| 263 | 263 | |
| 264 | - /** |
|
| 264 | +/** |
|
| 265 | 265 | * Set the session manager |
| 266 | 266 | * |
| 267 | 267 | * @param Closure $xClosure A closure to create the session manager instance |
| 268 | 268 | * |
| 269 | 269 | * @return void |
| 270 | 270 | */ |
| 271 | - public function setSessionManager(Closure $xClosure) |
|
| 272 | - { |
|
| 273 | - $this->set(SessionInterface::class, $xClosure); |
|
| 274 | - } |
|
| 271 | +public function setSessionManager(Closure $xClosure) |
|
| 272 | +{ |
|
| 273 | +$this->set(SessionInterface::class, $xClosure); |
|
| 274 | +} |
|
| 275 | 275 | } |
@@ -91,15 +91,15 @@ |
||
| 91 | 91 | return $this->xManager->getErrorMessage(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add a response command to the array of commands |
|
| 96 | - * |
|
| 97 | - * @param string $sName The command name |
|
| 98 | - * @param array|JsonSerializable $aArgs The command arguments |
|
| 99 | - * @param bool $bRemoveEmpty |
|
| 100 | - * |
|
| 101 | - * @return Command |
|
| 102 | - */ |
|
| 94 | + /** |
|
| 95 | + * Add a response command to the array of commands |
|
| 96 | + * |
|
| 97 | + * @param string $sName The command name |
|
| 98 | + * @param array|JsonSerializable $aArgs The command arguments |
|
| 99 | + * @param bool $bRemoveEmpty |
|
| 100 | + * |
|
| 101 | + * @return Command |
|
| 102 | + */ |
|
| 103 | 103 | public function addCommand(string $sName, array|JsonSerializable $aArgs = [], |
| 104 | 104 | bool $bRemoveEmpty = false): Command |
| 105 | 105 | { |
@@ -6,53 +6,53 @@ |
||
| 6 | 6 | |
| 7 | 7 | abstract class PageComponent extends NodeComponent |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * The current page number. |
| 11 | 11 | * |
| 12 | 12 | * @var int |
| 13 | 13 | */ |
| 14 | - private int $currentPage = 1; |
|
| 14 | +private int $currentPage = 1; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * Get the total number of items to paginate. |
| 18 | 18 | * |
| 19 | 19 | * @return int |
| 20 | 20 | */ |
| 21 | - abstract protected function count(): int; |
|
| 21 | +abstract protected function count(): int; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Get the max number of items per page. |
| 25 | 25 | * |
| 26 | 26 | * @return int |
| 27 | 27 | */ |
| 28 | - abstract protected function limit(): int; |
|
| 28 | +abstract protected function limit(): int; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * Get the paginator for the component. |
| 32 | 32 | * |
| 33 | 33 | * @param int $pageNumber |
| 34 | 34 | * |
| 35 | 35 | * @return Paginator |
| 36 | 36 | */ |
| 37 | - protected function paginator(int $pageNumber): Paginator |
|
| 38 | - { |
|
| 39 | - return $this->cl(Component\Pagination::class) |
|
| 40 | - // Use the js class name as component item identifier. |
|
| 41 | - ->item($this->rq()->_class()) |
|
| 42 | - ->paginator($pageNumber > 0 ? $pageNumber : 1, $this->limit(), $this->count()) |
|
| 43 | - // This callback will receive the final value of the current page number. |
|
| 44 | - ->page(function(int $currentPage) { |
|
| 45 | - $this->currentPage = $currentPage; |
|
| 46 | - }); |
|
| 47 | - } |
|
| 37 | +protected function paginator(int $pageNumber): Paginator |
|
| 38 | +{ |
|
| 39 | +return $this->cl(Component\Pagination::class) |
|
| 40 | +// Use the js class name as component item identifier. |
|
| 41 | +->item($this->rq()->_class()) |
|
| 42 | +->paginator($pageNumber > 0 ? $pageNumber : 1, $this->limit(), $this->count()) |
|
| 43 | +// This callback will receive the final value of the current page number. |
|
| 44 | +->page(function(int $currentPage) { |
|
| 45 | + $this->currentPage = $currentPage; |
|
| 46 | +}); |
|
| 47 | +} |
|
| 48 | 48 | |
| 49 | - /** |
|
| 49 | +/** |
|
| 50 | 50 | * Get the current page number |
| 51 | 51 | * |
| 52 | 52 | * @return int |
| 53 | 53 | */ |
| 54 | - protected function currentPage(): int |
|
| 55 | - { |
|
| 56 | - return $this->currentPage; |
|
| 57 | - } |
|
| 54 | +protected function currentPage(): int |
|
| 55 | +{ |
|
| 56 | +return $this->currentPage; |
|
| 57 | +} |
|
| 58 | 58 | } |
@@ -6,81 +6,81 @@ |
||
| 6 | 6 | |
| 7 | 7 | trait PageDatabagTrait |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * The current page number. |
| 11 | 11 | * |
| 12 | 12 | * @var int |
| 13 | 13 | */ |
| 14 | - private int $currentPage = 1; |
|
| 14 | +private int $currentPage = 1; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * Get the pagination databag name. |
| 18 | 18 | * |
| 19 | 19 | * @return string |
| 20 | 20 | */ |
| 21 | - abstract protected function bagName(): string; |
|
| 21 | +abstract protected function bagName(): string; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Get the pagination databag attribute. |
| 25 | 25 | * |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - abstract protected function bagAttr(): string; |
|
| 28 | +abstract protected function bagAttr(): string; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * Get the page number. |
| 32 | 32 | * |
| 33 | 33 | * @param int $pageNumber |
| 34 | 34 | * |
| 35 | 35 | * @return int |
| 36 | 36 | */ |
| 37 | - private function getPageNumber(int $pageNumber): int |
|
| 38 | - { |
|
| 39 | - // If no page number is provided, then get the value from the databag. |
|
| 40 | - return $pageNumber > 0 ? $pageNumber : |
|
| 41 | - (int)$this->bag($this->bagName())->get($this->bagAttr(), 1); |
|
| 42 | - } |
|
| 37 | +private function getPageNumber(int $pageNumber): int |
|
| 38 | +{ |
|
| 39 | +// If no page number is provided, then get the value from the databag. |
|
| 40 | +return $pageNumber > 0 ? $pageNumber : |
|
| 41 | +(int)$this->bag($this->bagName())->get($this->bagAttr(), 1); |
|
| 42 | +} |
|
| 43 | 43 | |
| 44 | - /** |
|
| 44 | +/** |
|
| 45 | 45 | * Set the page number. |
| 46 | 46 | * |
| 47 | 47 | * @param int $currentPage |
| 48 | 48 | * |
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | - private function setCurrentPage(int $currentPage): void |
|
| 52 | - { |
|
| 53 | - // Save the current page in the databag. |
|
| 54 | - $this->bag($this->bagName())->set($this->bagAttr(), $currentPage); |
|
| 55 | - $this->currentPage = $currentPage; |
|
| 56 | - } |
|
| 51 | +private function setCurrentPage(int $currentPage): void |
|
| 52 | +{ |
|
| 53 | +// Save the current page in the databag. |
|
| 54 | +$this->bag($this->bagName())->set($this->bagAttr(), $currentPage); |
|
| 55 | +$this->currentPage = $currentPage; |
|
| 56 | +} |
|
| 57 | 57 | |
| 58 | - /** |
|
| 58 | +/** |
|
| 59 | 59 | * Get the paginator for the component. |
| 60 | 60 | * |
| 61 | 61 | * @param int $pageNumber |
| 62 | 62 | * |
| 63 | 63 | * @return Paginator |
| 64 | 64 | */ |
| 65 | - protected function paginator(int $pageNumber): Paginator |
|
| 66 | - { |
|
| 67 | - return $this->cl(Component\Pagination::class) |
|
| 68 | - // Use the js class name as component item identifier. |
|
| 69 | - ->item($this->rq()->_class()) |
|
| 70 | - ->paginator($this->getPageNumber($pageNumber), $this->limit(), $this->count()) |
|
| 71 | - // This callback will receive the final value of the current page number. |
|
| 72 | - ->page(function(int $currentPage) { |
|
| 73 | - $this->setCurrentPage($currentPage); |
|
| 74 | - }); |
|
| 75 | - } |
|
| 65 | +protected function paginator(int $pageNumber): Paginator |
|
| 66 | +{ |
|
| 67 | +return $this->cl(Component\Pagination::class) |
|
| 68 | +// Use the js class name as component item identifier. |
|
| 69 | +->item($this->rq()->_class()) |
|
| 70 | +->paginator($this->getPageNumber($pageNumber), $this->limit(), $this->count()) |
|
| 71 | +// This callback will receive the final value of the current page number. |
|
| 72 | +->page(function(int $currentPage) { |
|
| 73 | + $this->setCurrentPage($currentPage); |
|
| 74 | +}); |
|
| 75 | +} |
|
| 76 | 76 | |
| 77 | - /** |
|
| 77 | +/** |
|
| 78 | 78 | * Get the current page number |
| 79 | 79 | * |
| 80 | 80 | * @return int |
| 81 | 81 | */ |
| 82 | - protected function currentPage(): int |
|
| 83 | - { |
|
| 84 | - return $this->currentPage; |
|
| 85 | - } |
|
| 82 | +protected function currentPage(): int |
|
| 83 | +{ |
|
| 84 | +return $this->currentPage; |
|
| 85 | +} |
|
| 86 | 86 | } |
@@ -21,5 +21,5 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function jaxon(): Jaxon |
| 23 | 23 | { |
| 24 | - return Jaxon::getInstance(); |
|
| 24 | +return Jaxon::getInstance(); |
|
| 25 | 25 | } |
@@ -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 | } |
@@ -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 | } |