@@ -18,150 +18,150 @@ |
||
| 18 | 18 | |
| 19 | 19 | trait PsrTrait |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - private $sPsrConfig = 'jaxon.psr.config.file'; |
|
| 24 | +private $sPsrConfig = 'jaxon.psr.config.file'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - private $sPsrServerRequest = 'jaxon.psr.server.request'; |
|
| 29 | +private $sPsrServerRequest = 'jaxon.psr.server.request'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * Register the values into the container |
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | - private function registerPsr(): void |
|
| 37 | - { |
|
| 38 | - // The server request |
|
| 39 | - $this->set(Psr17Factory::class, function() { |
|
| 40 | - return new Psr17Factory(); |
|
| 41 | - }); |
|
| 42 | - $this->set(ServerRequestCreator::class, function($di) { |
|
| 43 | - $xPsr17Factory = $di->g(Psr17Factory::class); |
|
| 44 | - return new ServerRequestCreator( |
|
| 45 | - $xPsr17Factory, // ServerRequestFactory |
|
| 46 | - $xPsr17Factory, // UriFactory |
|
| 47 | - $xPsr17Factory, // UploadedFileFactory |
|
| 48 | - $xPsr17Factory, // StreamFactory |
|
| 49 | - ); |
|
| 50 | - }); |
|
| 51 | - $this->set(ServerRequestInterface::class, function($di) { |
|
| 52 | - return $di->g(ServerRequestCreator::class)->fromGlobals(); |
|
| 53 | - }); |
|
| 54 | - // Server request with the Jaxon request parameter as attribute |
|
| 55 | - $this->set($this->sPsrServerRequest, function($di) { |
|
| 56 | - /** @var ParameterReader */ |
|
| 57 | - $xParameterReader = $di->g(ParameterReader::class); |
|
| 58 | - return $xParameterReader->setRequestParameter($di->g(ServerRequestInterface::class)); |
|
| 59 | - }); |
|
| 60 | - // PSR factory |
|
| 61 | - $this->set(PsrFactory::class, function($di) { |
|
| 62 | - return new PsrFactory($di->g(Container::class)); |
|
| 63 | - }); |
|
| 64 | - // PSR request handler |
|
| 65 | - $this->set(PsrRequestHandler::class, function($di) { |
|
| 66 | - return new PsrRequestHandler($di->g(Container::class), $di->g(RequestHandler::class), |
|
| 67 | - $di->g(ResponseManager::class), $di->g(Translator::class)); |
|
| 68 | - }); |
|
| 69 | - // PSR config middleware |
|
| 70 | - $this->set(PsrConfigMiddleware::class, function($di) { |
|
| 71 | - return new PsrConfigMiddleware($di->g(Container::class), $di->g($this->sPsrConfig)); |
|
| 72 | - }); |
|
| 73 | - // PSR ajax middleware |
|
| 74 | - $this->set(PsrAjaxMiddleware::class, function($di) { |
|
| 75 | - return new PsrAjaxMiddleware($di->g(Container::class), $di->g(RequestHandler::class), |
|
| 76 | - $di->g(ResponseManager::class)); |
|
| 77 | - }); |
|
| 78 | - // The PSR response plugin |
|
| 79 | - $this->set(PsrPlugin::class, function($di) { |
|
| 80 | - return new PsrPlugin($di->g(Psr17Factory::class), $di->g(ServerRequestInterface::class)); |
|
| 81 | - }); |
|
| 82 | - } |
|
| 36 | +private function registerPsr(): void |
|
| 37 | +{ |
|
| 38 | +// The server request |
|
| 39 | +$this->set(Psr17Factory::class, function() { |
|
| 40 | +return new Psr17Factory(); |
|
| 41 | +}); |
|
| 42 | +$this->set(ServerRequestCreator::class, function($di) { |
|
| 43 | +$xPsr17Factory = $di->g(Psr17Factory::class); |
|
| 44 | +return new ServerRequestCreator( |
|
| 45 | + $xPsr17Factory, // ServerRequestFactory |
|
| 46 | + $xPsr17Factory, // UriFactory |
|
| 47 | + $xPsr17Factory, // UploadedFileFactory |
|
| 48 | + $xPsr17Factory, // StreamFactory |
|
| 49 | +); |
|
| 50 | +}); |
|
| 51 | +$this->set(ServerRequestInterface::class, function($di) { |
|
| 52 | +return $di->g(ServerRequestCreator::class)->fromGlobals(); |
|
| 53 | +}); |
|
| 54 | +// Server request with the Jaxon request parameter as attribute |
|
| 55 | +$this->set($this->sPsrServerRequest, function($di) { |
|
| 56 | +/** @var ParameterReader */ |
|
| 57 | +$xParameterReader = $di->g(ParameterReader::class); |
|
| 58 | +return $xParameterReader->setRequestParameter($di->g(ServerRequestInterface::class)); |
|
| 59 | +}); |
|
| 60 | +// PSR factory |
|
| 61 | +$this->set(PsrFactory::class, function($di) { |
|
| 62 | +return new PsrFactory($di->g(Container::class)); |
|
| 63 | +}); |
|
| 64 | +// PSR request handler |
|
| 65 | +$this->set(PsrRequestHandler::class, function($di) { |
|
| 66 | +return new PsrRequestHandler($di->g(Container::class), $di->g(RequestHandler::class), |
|
| 67 | + $di->g(ResponseManager::class), $di->g(Translator::class)); |
|
| 68 | +}); |
|
| 69 | +// PSR config middleware |
|
| 70 | +$this->set(PsrConfigMiddleware::class, function($di) { |
|
| 71 | +return new PsrConfigMiddleware($di->g(Container::class), $di->g($this->sPsrConfig)); |
|
| 72 | +}); |
|
| 73 | +// PSR ajax middleware |
|
| 74 | +$this->set(PsrAjaxMiddleware::class, function($di) { |
|
| 75 | +return new PsrAjaxMiddleware($di->g(Container::class), $di->g(RequestHandler::class), |
|
| 76 | + $di->g(ResponseManager::class)); |
|
| 77 | +}); |
|
| 78 | +// The PSR response plugin |
|
| 79 | +$this->set(PsrPlugin::class, function($di) { |
|
| 80 | +return new PsrPlugin($di->g(Psr17Factory::class), $di->g(ServerRequestInterface::class)); |
|
| 81 | +}); |
|
| 82 | +} |
|
| 83 | 83 | |
| 84 | - /** |
|
| 84 | +/** |
|
| 85 | 85 | * Get the request |
| 86 | 86 | * |
| 87 | 87 | * @return array |
| 88 | 88 | */ |
| 89 | - public function getServerParams(): array |
|
| 90 | - { |
|
| 91 | - $xRequest = $this->g(ServerRequestInterface::class); |
|
| 92 | - return $xRequest->getServerParams(); |
|
| 93 | - } |
|
| 89 | +public function getServerParams(): array |
|
| 90 | +{ |
|
| 91 | +$xRequest = $this->g(ServerRequestInterface::class); |
|
| 92 | +return $xRequest->getServerParams(); |
|
| 93 | +} |
|
| 94 | 94 | |
| 95 | - /** |
|
| 95 | +/** |
|
| 96 | 96 | * Get the request with Jaxon parameter as attribute |
| 97 | 97 | * |
| 98 | 98 | * @return ServerRequestInterface |
| 99 | 99 | */ |
| 100 | - public function getRequest(): ServerRequestInterface |
|
| 101 | - { |
|
| 102 | - return $this->g($this->sPsrServerRequest); |
|
| 103 | - } |
|
| 100 | +public function getRequest(): ServerRequestInterface |
|
| 101 | +{ |
|
| 102 | +return $this->g($this->sPsrServerRequest); |
|
| 103 | +} |
|
| 104 | 104 | |
| 105 | - /** |
|
| 105 | +/** |
|
| 106 | 106 | * Return the array of arguments from the GET or POST data |
| 107 | 107 | * |
| 108 | 108 | * @return array |
| 109 | 109 | */ |
| 110 | - public function getRequestArguments(): array |
|
| 111 | - { |
|
| 112 | - return $this->getRequest()->getAttribute('jxncall')['args'] ?? []; |
|
| 113 | - } |
|
| 110 | +public function getRequestArguments(): array |
|
| 111 | +{ |
|
| 112 | +return $this->getRequest()->getAttribute('jxncall')['args'] ?? []; |
|
| 113 | +} |
|
| 114 | 114 | |
| 115 | - /** |
|
| 115 | +/** |
|
| 116 | 116 | * Get the PSR factory |
| 117 | 117 | * |
| 118 | 118 | * @return PsrFactory |
| 119 | 119 | */ |
| 120 | - public function getPsrFactory(): PsrFactory |
|
| 121 | - { |
|
| 122 | - return $this->g(PsrFactory::class); |
|
| 123 | - } |
|
| 120 | +public function getPsrFactory(): PsrFactory |
|
| 121 | +{ |
|
| 122 | +return $this->g(PsrFactory::class); |
|
| 123 | +} |
|
| 124 | 124 | |
| 125 | - /** |
|
| 125 | +/** |
|
| 126 | 126 | * Get the Psr17 factory |
| 127 | 127 | * |
| 128 | 128 | * @return Psr17Factory |
| 129 | 129 | */ |
| 130 | - public function getPsr17Factory(): Psr17Factory |
|
| 131 | - { |
|
| 132 | - return $this->g(Psr17Factory::class); |
|
| 133 | - } |
|
| 130 | +public function getPsr17Factory(): Psr17Factory |
|
| 131 | +{ |
|
| 132 | +return $this->g(Psr17Factory::class); |
|
| 133 | +} |
|
| 134 | 134 | |
| 135 | - /** |
|
| 135 | +/** |
|
| 136 | 136 | * Get the PSR request handler |
| 137 | 137 | * |
| 138 | 138 | * @return PsrRequestHandler |
| 139 | 139 | */ |
| 140 | - public function getPsrRequestHandler(): PsrRequestHandler |
|
| 141 | - { |
|
| 142 | - return $this->g(PsrRequestHandler::class); |
|
| 143 | - } |
|
| 140 | +public function getPsrRequestHandler(): PsrRequestHandler |
|
| 141 | +{ |
|
| 142 | +return $this->g(PsrRequestHandler::class); |
|
| 143 | +} |
|
| 144 | 144 | |
| 145 | - /** |
|
| 145 | +/** |
|
| 146 | 146 | * Get the PSR config middleware |
| 147 | 147 | * |
| 148 | 148 | * @param string $sConfigFile |
| 149 | 149 | * |
| 150 | 150 | * @return PsrConfigMiddleware |
| 151 | 151 | */ |
| 152 | - public function getPsrConfigMiddleware(string $sConfigFile): PsrConfigMiddleware |
|
| 153 | - { |
|
| 154 | - !$this->h($this->sPsrConfig) && $this->val($this->sPsrConfig, $sConfigFile); |
|
| 155 | - return $this->g(PsrConfigMiddleware::class); |
|
| 156 | - } |
|
| 152 | +public function getPsrConfigMiddleware(string $sConfigFile): PsrConfigMiddleware |
|
| 153 | +{ |
|
| 154 | +!$this->h($this->sPsrConfig) && $this->val($this->sPsrConfig, $sConfigFile); |
|
| 155 | +return $this->g(PsrConfigMiddleware::class); |
|
| 156 | +} |
|
| 157 | 157 | |
| 158 | - /** |
|
| 158 | +/** |
|
| 159 | 159 | * Get the PSR ajax request middleware |
| 160 | 160 | * |
| 161 | 161 | * @return PsrAjaxMiddleware |
| 162 | 162 | */ |
| 163 | - public function getPsrAjaxMiddleware(): PsrAjaxMiddleware |
|
| 164 | - { |
|
| 165 | - return $this->g(PsrAjaxMiddleware::class); |
|
| 166 | - } |
|
| 163 | +public function getPsrAjaxMiddleware(): PsrAjaxMiddleware |
|
| 164 | +{ |
|
| 165 | +return $this->g(PsrAjaxMiddleware::class); |
|
| 166 | +} |
|
| 167 | 167 | } |
@@ -8,71 +8,71 @@ |
||
| 8 | 8 | |
| 9 | 9 | abstract class NodeComponent extends Component\AbstractComponent |
| 10 | 10 | { |
| 11 | - use Component\HelperTrait; |
|
| 12 | - use Component\NodeResponseTrait; |
|
| 13 | - use Component\AjaxResponseTrait; |
|
| 14 | - use Component\ComponentTrait; |
|
| 11 | +use Component\HelperTrait; |
|
| 12 | +use Component\NodeResponseTrait; |
|
| 13 | +use Component\AjaxResponseTrait; |
|
| 14 | +use Component\ComponentTrait; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @inheritDoc |
| 18 | 18 | */ |
| 19 | - final protected function initComponent(Container $di, ComponentHelper $xHelper): void |
|
| 20 | - { |
|
| 21 | - $this->setHelper($xHelper); |
|
| 22 | - $this->setNodeResponse($di); |
|
| 23 | - $this->setAjaxResponse($di); |
|
| 24 | - } |
|
| 19 | +final protected function initComponent(Container $di, ComponentHelper $xHelper): void |
|
| 20 | +{ |
|
| 21 | +$this->setHelper($xHelper); |
|
| 22 | +$this->setNodeResponse($di); |
|
| 23 | +$this->setAjaxResponse($di); |
|
| 24 | +} |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @return string|Stringable |
| 28 | 28 | */ |
| 29 | - abstract public function html(): string|Stringable; |
|
| 29 | +abstract public function html(): string|Stringable; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * Called before rendering the component. |
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | - protected function before(): void |
|
| 37 | - {} |
|
| 36 | +protected function before(): void |
|
| 37 | +{} |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * Called after rendering the component. |
| 41 | 41 | * |
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | - protected function after(): void |
|
| 45 | - {} |
|
| 44 | +protected function after(): void |
|
| 45 | +{} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * Set the attached DOM node content with the component HTML code. |
| 49 | 49 | * |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - final public function render(): void |
|
| 53 | - { |
|
| 54 | - $this->before(); |
|
| 55 | - $this->node()->html((string)$this->html()); |
|
| 56 | - $this->after(); |
|
| 57 | - } |
|
| 52 | +final public function render(): void |
|
| 53 | +{ |
|
| 54 | +$this->before(); |
|
| 55 | +$this->node()->html((string)$this->html()); |
|
| 56 | +$this->after(); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * Clear the attached DOM node content. |
| 61 | 61 | * |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - final public function clear(): void |
|
| 65 | - { |
|
| 66 | - $this->node()->clear(); |
|
| 67 | - } |
|
| 64 | +final public function clear(): void |
|
| 65 | +{ |
|
| 66 | +$this->node()->clear(); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Show/hide the attached DOM node. |
| 71 | 71 | * |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | - final public function visible(bool $bVisible): void |
|
| 75 | - { |
|
| 76 | - $bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide(); |
|
| 77 | - } |
|
| 74 | +final public function visible(bool $bVisible): void |
|
| 75 | +{ |
|
| 76 | +$bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide(); |
|
| 77 | +} |
|
| 78 | 78 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | interface ModalInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Show a modal dialog. |
| 21 | 21 | * |
| 22 | 22 | * @param string $sTitle The title of the dialog |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | - public function show(string $sTitle, string $sContent, array $aButtons = [], array $aOptions = []): void; |
|
| 29 | +public function show(string $sTitle, string $sContent, array $aButtons = [], array $aOptions = []): void; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * Hide the modal dialog. |
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | - public function hide(): void; |
|
| 36 | +public function hide(): void; |
|
| 37 | 37 | } |
@@ -6,24 +6,24 @@ |
||
| 6 | 6 | |
| 7 | 7 | trait DialogTrait |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * @return AjaxResponse |
| 11 | 11 | */ |
| 12 | - abstract protected function response(): AjaxResponse; |
|
| 12 | +abstract protected function response(): AjaxResponse; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * @return AlertInterface |
| 16 | 16 | */ |
| 17 | - protected function alert(): AlertInterface |
|
| 18 | - { |
|
| 19 | - return $this->response()->dialog; |
|
| 20 | - } |
|
| 17 | +protected function alert(): AlertInterface |
|
| 18 | +{ |
|
| 19 | +return $this->response()->dialog; |
|
| 20 | +} |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * @return ModalInterface |
| 24 | 24 | */ |
| 25 | - protected function modal(): ModalInterface |
|
| 26 | - { |
|
| 27 | - return $this->response()->dialog; |
|
| 28 | - } |
|
| 25 | +protected function modal(): ModalInterface |
|
| 26 | +{ |
|
| 27 | +return $this->response()->dialog; |
|
| 28 | +} |
|
| 29 | 29 | } |
@@ -16,16 +16,16 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | interface AlertInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Set the title of the next message. |
| 21 | 21 | * |
| 22 | 22 | * @param string $sTitle The title of the message |
| 23 | 23 | * |
| 24 | 24 | * @return AlertInterface |
| 25 | 25 | */ |
| 26 | - public function title(string $sTitle): AlertInterface; |
|
| 26 | +public function title(string $sTitle): AlertInterface; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * Show a success message. |
| 30 | 30 | * |
| 31 | 31 | * @param string $sMessage The text of the message |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | - public function success(string $sMessage, ...$aArgs): void; |
|
| 36 | +public function success(string $sMessage, ...$aArgs): void; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * Show an information message. |
| 40 | 40 | * |
| 41 | 41 | * @param string $sMessage The text of the message |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | - public function info(string $sMessage, ...$aArgs): void; |
|
| 46 | +public function info(string $sMessage, ...$aArgs): void; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * Show a warning message. |
| 50 | 50 | * |
| 51 | 51 | * @param string $sMessage The text of the message |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | - public function warning(string $sMessage, ...$aArgs): void; |
|
| 56 | +public function warning(string $sMessage, ...$aArgs): void; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 58 | +/** |
|
| 59 | 59 | * Show an error message. |
| 60 | 60 | * |
| 61 | 61 | * @param string $sMessage The text of the message |
@@ -63,5 +63,5 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | - public function error(string $sMessage, ...$aArgs): void; |
|
| 66 | +public function error(string $sMessage, ...$aArgs): void; |
|
| 67 | 67 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | class ParameterReader |
| 42 | 42 | { |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * The constructor |
| 45 | 45 | * |
| 46 | 46 | * @param Container $di |
@@ -48,28 +48,28 @@ discard block |
||
| 48 | 48 | * @param ConfigManager $xConfigManager |
| 49 | 49 | * @param UriDetector $xUriDetector |
| 50 | 50 | */ |
| 51 | - public function __construct(private Container $di, private Translator $xTranslator, |
|
| 52 | - private ConfigManager $xConfigManager, private UriDetector $xUriDetector) |
|
| 53 | - {} |
|
| 51 | +public function __construct(private Container $di, private Translator $xTranslator, |
|
| 52 | +private ConfigManager $xConfigManager, private UriDetector $xUriDetector) |
|
| 53 | +{} |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * Decode input data. |
| 57 | 57 | * |
| 58 | 58 | * @param string $sStr |
| 59 | 59 | * |
| 60 | 60 | * @return string |
| 61 | 61 | */ |
| 62 | - private function decodeStr(string $sStr): string |
|
| 63 | - { |
|
| 64 | - $aServerParams = $this->di->getServerParams(); |
|
| 65 | - $sContentType = $aServerParams['CONTENT_TYPE'] ?? $aServerParams['HTTP_CONTENT_TYPE'] ?? ''; |
|
| 66 | - $sType = 'multipart/form-data'; |
|
| 67 | - // Parameters are url encoded when uploading files |
|
| 68 | - return strncmp($sContentType, $sType, strlen($sType)) !== 0 ? |
|
| 69 | - $sStr : urldecode($sStr); |
|
| 70 | - } |
|
| 62 | +private function decodeStr(string $sStr): string |
|
| 63 | +{ |
|
| 64 | +$aServerParams = $this->di->getServerParams(); |
|
| 65 | +$sContentType = $aServerParams['CONTENT_TYPE'] ?? $aServerParams['HTTP_CONTENT_TYPE'] ?? ''; |
|
| 66 | +$sType = 'multipart/form-data'; |
|
| 67 | +// Parameters are url encoded when uploading files |
|
| 68 | +return strncmp($sContentType, $sType, strlen($sType)) !== 0 ? |
|
| 69 | +$sStr : urldecode($sStr); |
|
| 70 | +} |
|
| 71 | 71 | |
| 72 | - /** |
|
| 72 | +/** |
|
| 73 | 73 | * Decode input data. |
| 74 | 74 | * |
| 75 | 75 | * @param string $sStr |
@@ -77,83 +77,83 @@ discard block |
||
| 77 | 77 | * @return string |
| 78 | 78 | * @throws RequestException |
| 79 | 79 | */ |
| 80 | - private function decoderUtf8Str(string $sStr): string |
|
| 81 | - { |
|
| 82 | - $sEncoding = $this->xConfigManager->getOption('core.encoding', ''); |
|
| 83 | - if(function_exists('iconv')) |
|
| 84 | - { |
|
| 85 | - return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr); |
|
| 86 | - } |
|
| 87 | - if(function_exists('mb_convert_encoding')) |
|
| 88 | - { |
|
| 89 | - return mb_convert_encoding($sStr, $sEncoding, "UTF-8"); |
|
| 90 | - } |
|
| 91 | - // By default, no decoding |
|
| 92 | - // return $sStr; |
|
| 93 | - throw new RequestException($this->xTranslator->trans('errors.request.conversion')); |
|
| 94 | - } |
|
| 80 | +private function decoderUtf8Str(string $sStr): string |
|
| 81 | +{ |
|
| 82 | +$sEncoding = $this->xConfigManager->getOption('core.encoding', ''); |
|
| 83 | +if(function_exists('iconv')) |
|
| 84 | +{ |
|
| 85 | +return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr); |
|
| 86 | +} |
|
| 87 | +if(function_exists('mb_convert_encoding')) |
|
| 88 | +{ |
|
| 89 | +return mb_convert_encoding($sStr, $sEncoding, "UTF-8"); |
|
| 90 | +} |
|
| 91 | +// By default, no decoding |
|
| 92 | +// return $sStr; |
|
| 93 | +throw new RequestException($this->xTranslator->trans('errors.request.conversion')); |
|
| 94 | +} |
|
| 95 | 95 | |
| 96 | - /** |
|
| 96 | +/** |
|
| 97 | 97 | * Choose the function to use to decode input data. |
| 98 | 98 | * |
| 99 | 99 | * @param string $sParam |
| 100 | 100 | * |
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | - private function decodeRequestParameter(string $sParam): string |
|
| 104 | - { |
|
| 105 | - $sParam = $this->decodeStr($sParam); |
|
| 106 | - if(!$this->xConfigManager->getOption('core.decode_utf8')) |
|
| 107 | - { |
|
| 108 | - return $sParam; |
|
| 109 | - } |
|
| 110 | - $this->xConfigManager->setOption('core.decode_utf8', false); |
|
| 111 | - return $this->decoderUtf8Str($sParam); |
|
| 112 | - } |
|
| 103 | +private function decodeRequestParameter(string $sParam): string |
|
| 104 | +{ |
|
| 105 | +$sParam = $this->decodeStr($sParam); |
|
| 106 | +if(!$this->xConfigManager->getOption('core.decode_utf8')) |
|
| 107 | +{ |
|
| 108 | +return $sParam; |
|
| 109 | +} |
|
| 110 | +$this->xConfigManager->setOption('core.decode_utf8', false); |
|
| 111 | +return $this->decoderUtf8Str($sParam); |
|
| 112 | +} |
|
| 113 | 113 | |
| 114 | - /** |
|
| 114 | +/** |
|
| 115 | 115 | * @param ServerRequestInterface $xRequest |
| 116 | 116 | * |
| 117 | 117 | * @return ServerRequestInterface |
| 118 | 118 | */ |
| 119 | - public function setRequestParameter(ServerRequestInterface $xRequest): ServerRequestInterface |
|
| 120 | - { |
|
| 121 | - $aBody = $xRequest->getParsedBody(); |
|
| 122 | - $aParams = is_array($aBody) ? $aBody : $xRequest->getQueryParams(); |
|
| 123 | - // Check if Jaxon call parameters are present. |
|
| 124 | - if(isset($aParams['jxncall']) && is_string($aParams['jxncall'])) |
|
| 125 | - { |
|
| 126 | - $xRequest = $xRequest->withAttribute('jxncall', json_decode($this |
|
| 127 | - ->decodeRequestParameter($aParams['jxncall']), true)); |
|
| 128 | - } |
|
| 129 | - // Check if Jaxon bags parameters are present. |
|
| 130 | - if(isset($aParams['jxnbags']) && is_string($aParams['jxnbags'])) |
|
| 131 | - { |
|
| 132 | - $xRequest = $xRequest->withAttribute('jxnbags', json_decode($this |
|
| 133 | - ->decodeRequestParameter($aParams['jxnbags']), true)); |
|
| 134 | - } |
|
| 135 | - return $xRequest; |
|
| 136 | - } |
|
| 119 | +public function setRequestParameter(ServerRequestInterface $xRequest): ServerRequestInterface |
|
| 120 | +{ |
|
| 121 | +$aBody = $xRequest->getParsedBody(); |
|
| 122 | +$aParams = is_array($aBody) ? $aBody : $xRequest->getQueryParams(); |
|
| 123 | +// Check if Jaxon call parameters are present. |
|
| 124 | +if(isset($aParams['jxncall']) && is_string($aParams['jxncall'])) |
|
| 125 | +{ |
|
| 126 | +$xRequest = $xRequest->withAttribute('jxncall', json_decode($this |
|
| 127 | + ->decodeRequestParameter($aParams['jxncall']), true)); |
|
| 128 | +} |
|
| 129 | +// Check if Jaxon bags parameters are present. |
|
| 130 | +if(isset($aParams['jxnbags']) && is_string($aParams['jxnbags'])) |
|
| 131 | +{ |
|
| 132 | +$xRequest = $xRequest->withAttribute('jxnbags', json_decode($this |
|
| 133 | + ->decodeRequestParameter($aParams['jxnbags']), true)); |
|
| 134 | +} |
|
| 135 | +return $xRequest; |
|
| 136 | +} |
|
| 137 | 137 | |
| 138 | - /** |
|
| 138 | +/** |
|
| 139 | 139 | * Get the URI of the current request |
| 140 | 140 | * |
| 141 | 141 | * @throws UriException |
| 142 | 142 | */ |
| 143 | - public function uri(): string |
|
| 144 | - { |
|
| 145 | - return $this->xUriDetector->detect($this->di->getServerParams()); |
|
| 146 | - } |
|
| 143 | +public function uri(): string |
|
| 144 | +{ |
|
| 145 | +return $this->xUriDetector->detect($this->di->getServerParams()); |
|
| 146 | +} |
|
| 147 | 147 | |
| 148 | - /** |
|
| 148 | +/** |
|
| 149 | 149 | * Make the specified URL suitable for redirect |
| 150 | 150 | * |
| 151 | 151 | * @param string $sURL The relative or fully qualified URL |
| 152 | 152 | * |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - public function parseUrl(string $sURL): string |
|
| 156 | - { |
|
| 157 | - return $this->xUriDetector->redirect($sURL, $this->di->getServerParams()); |
|
| 158 | - } |
|
| 155 | +public function parseUrl(string $sURL): string |
|
| 156 | +{ |
|
| 157 | +return $this->xUriDetector->redirect($sURL, $this->di->getServerParams()); |
|
| 158 | +} |
|
| 159 | 159 | } |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | private function decoderUtf8Str(string $sStr): string |
| 81 | 81 | { |
| 82 | 82 | $sEncoding = $this->xConfigManager->getOption('core.encoding', ''); |
| 83 | - if(function_exists('iconv')) |
|
| 83 | + if (function_exists('iconv')) |
|
| 84 | 84 | { |
| 85 | 85 | return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr); |
| 86 | 86 | } |
| 87 | - if(function_exists('mb_convert_encoding')) |
|
| 87 | + if (function_exists('mb_convert_encoding')) |
|
| 88 | 88 | { |
| 89 | 89 | return mb_convert_encoding($sStr, $sEncoding, "UTF-8"); |
| 90 | 90 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | private function decodeRequestParameter(string $sParam): string |
| 104 | 104 | { |
| 105 | 105 | $sParam = $this->decodeStr($sParam); |
| 106 | - if(!$this->xConfigManager->getOption('core.decode_utf8')) |
|
| 106 | + if (!$this->xConfigManager->getOption('core.decode_utf8')) |
|
| 107 | 107 | { |
| 108 | 108 | return $sParam; |
| 109 | 109 | } |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | $aBody = $xRequest->getParsedBody(); |
| 122 | 122 | $aParams = is_array($aBody) ? $aBody : $xRequest->getQueryParams(); |
| 123 | 123 | // Check if Jaxon call parameters are present. |
| 124 | - if(isset($aParams['jxncall']) && is_string($aParams['jxncall'])) |
|
| 124 | + if (isset($aParams['jxncall']) && is_string($aParams['jxncall'])) |
|
| 125 | 125 | { |
| 126 | 126 | $xRequest = $xRequest->withAttribute('jxncall', json_decode($this |
| 127 | 127 | ->decodeRequestParameter($aParams['jxncall']), true)); |
| 128 | 128 | } |
| 129 | 129 | // Check if Jaxon bags parameters are present. |
| 130 | - if(isset($aParams['jxnbags']) && is_string($aParams['jxnbags'])) |
|
| 130 | + if (isset($aParams['jxnbags']) && is_string($aParams['jxnbags'])) |
|
| 131 | 131 | { |
| 132 | 132 | $xRequest = $xRequest->withAttribute('jxnbags', json_decode($this |
| 133 | 133 | ->decodeRequestParameter($aParams['jxnbags']), true)); |
@@ -26,142 +26,142 @@ |
||
| 26 | 26 | |
| 27 | 27 | class AssetManager |
| 28 | 28 | { |
| 29 | - use ConfigTrait; |
|
| 29 | +use ConfigTrait; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * Default library URL |
| 33 | 33 | * |
| 34 | 34 | * @var string |
| 35 | 35 | */ |
| 36 | - const JS_LIB_URL = 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist'; |
|
| 36 | +const JS_LIB_URL = 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist'; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * The constructor |
| 40 | 40 | * |
| 41 | 41 | * @param ConfigManager $xConfigManager |
| 42 | 42 | * @param MinifierInterface $xMinifier |
| 43 | 43 | */ |
| 44 | - public function __construct(private ConfigManager $xConfigManager, |
|
| 45 | - private MinifierInterface $xMinifier) |
|
| 46 | - {} |
|
| 44 | +public function __construct(private ConfigManager $xConfigManager, |
|
| 45 | +private MinifierInterface $xMinifier) |
|
| 46 | +{} |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * @return ConfigManager |
| 50 | 50 | */ |
| 51 | - protected function config(): ConfigManager |
|
| 52 | - { |
|
| 53 | - return $this->xConfigManager; |
|
| 54 | - } |
|
| 51 | +protected function config(): ConfigManager |
|
| 52 | +{ |
|
| 53 | +return $this->xConfigManager; |
|
| 54 | +} |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * Get app js options |
| 58 | 58 | * |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | - public function getJsOptions(): string |
|
| 62 | - { |
|
| 63 | - return $this->getLibOption('js.app.options', ''); |
|
| 64 | - } |
|
| 61 | +public function getJsOptions(): string |
|
| 62 | +{ |
|
| 63 | +return $this->getLibOption('js.app.options', ''); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Check if the assets of this plugin shall be included in Jaxon generated code. |
| 68 | 68 | * |
| 69 | 69 | * @param AbstractPlugin $xPlugin |
| 70 | 70 | * |
| 71 | 71 | * @return bool |
| 72 | 72 | */ |
| 73 | - public function shallIncludeAssets(AbstractPlugin $xPlugin): bool |
|
| 74 | - { |
|
| 75 | - $sPluginOptionName = 'assets.include.' . $xPlugin->getName(); |
|
| 76 | - if($this->hasLibOption($sPluginOptionName)) |
|
| 77 | - { |
|
| 78 | - return $this->getLibOption($sPluginOptionName); |
|
| 79 | - } |
|
| 80 | - return $this->getLibOption('assets.include.all', true); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 73 | +public function shallIncludeAssets(AbstractPlugin $xPlugin): bool |
|
| 74 | +{ |
|
| 75 | +$sPluginOptionName = 'assets.include.' . $xPlugin->getName(); |
|
| 76 | +if($this->hasLibOption($sPluginOptionName)) |
|
| 77 | +{ |
|
| 78 | +return $this->getLibOption($sPluginOptionName); |
|
| 79 | +} |
|
| 80 | +return $this->getLibOption('assets.include.all', true); |
|
| 81 | +} |
|
| 82 | + |
|
| 83 | +/** |
|
| 84 | 84 | * Get the HTML tags to include Jaxon javascript files into the page |
| 85 | 85 | * |
| 86 | 86 | * @return array |
| 87 | 87 | */ |
| 88 | - public function getJsLibFiles(): array |
|
| 89 | - { |
|
| 90 | - $sJsExtension = $this->getLibOption('js.app.minify') ? '.min.js' : '.js'; |
|
| 91 | - // The URI for the javascript library files |
|
| 92 | - $sJsLibUri = $this->getLibOption('js.lib.uri', self::JS_LIB_URL); |
|
| 93 | - $sJsLibUri = rtrim($sJsLibUri, '/'); |
|
| 94 | - |
|
| 95 | - // Add component files to the javascript file array; |
|
| 96 | - $aJsFiles = [ |
|
| 97 | - $this->getLibOption('js.lib.jq', "$sJsLibUri/libs/chibi/chibi$sJsExtension"), |
|
| 98 | - "$sJsLibUri/jaxon.core$sJsExtension", |
|
| 99 | - ]; |
|
| 100 | - if($this->getLibOption('core.debug.on')) |
|
| 101 | - { |
|
| 102 | - $sLanguage = $this->getLibOption('core.language'); |
|
| 103 | - $aJsFiles[] = "$sJsLibUri/jaxon.debug$sJsExtension"; |
|
| 104 | - $aJsFiles[] = "$sJsLibUri/lang/jaxon.$sLanguage$sJsExtension"; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - return $aJsFiles; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 88 | +public function getJsLibFiles(): array |
|
| 89 | +{ |
|
| 90 | +$sJsExtension = $this->getLibOption('js.app.minify') ? '.min.js' : '.js'; |
|
| 91 | +// The URI for the javascript library files |
|
| 92 | +$sJsLibUri = $this->getLibOption('js.lib.uri', self::JS_LIB_URL); |
|
| 93 | +$sJsLibUri = rtrim($sJsLibUri, '/'); |
|
| 94 | + |
|
| 95 | +// Add component files to the javascript file array; |
|
| 96 | +$aJsFiles = [ |
|
| 97 | +$this->getLibOption('js.lib.jq', "$sJsLibUri/libs/chibi/chibi$sJsExtension"), |
|
| 98 | +"$sJsLibUri/jaxon.core$sJsExtension", |
|
| 99 | +]; |
|
| 100 | +if($this->getLibOption('core.debug.on')) |
|
| 101 | +{ |
|
| 102 | +$sLanguage = $this->getLibOption('core.language'); |
|
| 103 | +$aJsFiles[] = "$sJsLibUri/jaxon.debug$sJsExtension"; |
|
| 104 | +$aJsFiles[] = "$sJsLibUri/lang/jaxon.$sLanguage$sJsExtension"; |
|
| 105 | +} |
|
| 106 | + |
|
| 107 | +return $aJsFiles; |
|
| 108 | +} |
|
| 109 | + |
|
| 110 | +/** |
|
| 111 | 111 | * Get the javascript file name |
| 112 | 112 | * |
| 113 | 113 | * @return bool |
| 114 | 114 | */ |
| 115 | - public function shallCreateJsFiles(): bool |
|
| 116 | - { |
|
| 117 | - // Check config options |
|
| 118 | - // - The js.app.export option must be set to true |
|
| 119 | - // - The js.app.uri and js.app.dir options must be set to non null values |
|
| 120 | - if(!$this->getLibOption('js.app.export', false) || |
|
| 121 | - !$this->getLibOption('js.app.uri') || !$this->getLibOption('js.app.dir')) |
|
| 122 | - { |
|
| 123 | - return false; |
|
| 124 | - } |
|
| 125 | - return true; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 115 | +public function shallCreateJsFiles(): bool |
|
| 116 | +{ |
|
| 117 | +// Check config options |
|
| 118 | +// - The js.app.export option must be set to true |
|
| 119 | +// - The js.app.uri and js.app.dir options must be set to non null values |
|
| 120 | +if(!$this->getLibOption('js.app.export', false) || |
|
| 121 | +!$this->getLibOption('js.app.uri') || !$this->getLibOption('js.app.dir')) |
|
| 122 | +{ |
|
| 123 | +return false; |
|
| 124 | +} |
|
| 125 | +return true; |
|
| 126 | +} |
|
| 127 | + |
|
| 128 | +/** |
|
| 129 | 129 | * Write javascript files and return the corresponding URI |
| 130 | 130 | * |
| 131 | 131 | * @param CodeGenerator $xCodeGenerator |
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function createJsFiles(CodeGenerator $xCodeGenerator): string |
|
| 136 | - { |
|
| 137 | - // Check dir access |
|
| 138 | - $sJsFileName = $this->getLibOption('js.app.file') ?: $xCodeGenerator->getHash(); |
|
| 139 | - $sJsDirectory = rtrim($this->getLibOption('js.app.dir'), '\/') . DIRECTORY_SEPARATOR; |
|
| 140 | - // - The js.app.dir must be writable |
|
| 141 | - if(!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
| 142 | - { |
|
| 143 | - return ''; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - $sJsFilePath = $sJsDirectory . $sJsFileName . '.js'; |
|
| 147 | - $sJsMinFilePath = $sJsDirectory . $sJsFileName . '.min.js'; |
|
| 148 | - $sJsFileUri = rtrim($this->getLibOption('js.app.uri'), '/') . "/$sJsFileName"; |
|
| 149 | - |
|
| 150 | - if(!is_file($sJsFilePath) && |
|
| 151 | - !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
|
| 152 | - { |
|
| 153 | - return ''; |
|
| 154 | - } |
|
| 155 | - if(!$this->getLibOption('js.app.minify', false)) |
|
| 156 | - { |
|
| 157 | - return $sJsFileUri . '.js'; |
|
| 158 | - } |
|
| 159 | - if(!is_file($sJsMinFilePath) && |
|
| 160 | - !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
|
| 161 | - { |
|
| 162 | - // If the file cannot be minified, return the plain js file. |
|
| 163 | - return $sJsFileUri . '.js'; |
|
| 164 | - } |
|
| 165 | - return $sJsFileUri . '.min.js'; |
|
| 166 | - } |
|
| 135 | +public function createJsFiles(CodeGenerator $xCodeGenerator): string |
|
| 136 | +{ |
|
| 137 | +// Check dir access |
|
| 138 | +$sJsFileName = $this->getLibOption('js.app.file') ?: $xCodeGenerator->getHash(); |
|
| 139 | +$sJsDirectory = rtrim($this->getLibOption('js.app.dir'), '\/') . DIRECTORY_SEPARATOR; |
|
| 140 | +// - The js.app.dir must be writable |
|
| 141 | +if(!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
| 142 | +{ |
|
| 143 | +return ''; |
|
| 144 | +} |
|
| 145 | + |
|
| 146 | +$sJsFilePath = $sJsDirectory . $sJsFileName . '.js'; |
|
| 147 | +$sJsMinFilePath = $sJsDirectory . $sJsFileName . '.min.js'; |
|
| 148 | +$sJsFileUri = rtrim($this->getLibOption('js.app.uri'), '/') . "/$sJsFileName"; |
|
| 149 | + |
|
| 150 | +if(!is_file($sJsFilePath) && |
|
| 151 | +!@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
|
| 152 | +{ |
|
| 153 | +return ''; |
|
| 154 | +} |
|
| 155 | +if(!$this->getLibOption('js.app.minify', false)) |
|
| 156 | +{ |
|
| 157 | +return $sJsFileUri . '.js'; |
|
| 158 | +} |
|
| 159 | +if(!is_file($sJsMinFilePath) && |
|
| 160 | +!$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
|
| 161 | +{ |
|
| 162 | +// If the file cannot be minified, return the plain js file. |
|
| 163 | +return $sJsFileUri . '.js'; |
|
| 164 | +} |
|
| 165 | +return $sJsFileUri . '.min.js'; |
|
| 166 | +} |
|
| 167 | 167 | } |
@@ -13,89 +13,89 @@ |
||
| 13 | 13 | |
| 14 | 14 | class DatabagPlugin extends AbstractResponsePlugin |
| 15 | 15 | { |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @const The plugin name |
| 18 | 18 | */ |
| 19 | - public const NAME = 'bags'; |
|
| 19 | +public const NAME = 'bags'; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @var Databag |
| 23 | 23 | */ |
| 24 | - protected $xDatabag = null; |
|
| 24 | +protected $xDatabag = null; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * The constructor |
| 28 | 28 | */ |
| 29 | - public function __construct(protected Container $di) |
|
| 30 | - {} |
|
| 29 | +public function __construct(protected Container $di) |
|
| 30 | +{} |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - private function initDatabag(): void |
|
| 36 | - { |
|
| 37 | - if($this->xDatabag !== null) |
|
| 38 | - { |
|
| 39 | - return; |
|
| 40 | - } |
|
| 35 | +private function initDatabag(): void |
|
| 36 | +{ |
|
| 37 | +if($this->xDatabag !== null) |
|
| 38 | +{ |
|
| 39 | +return; |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - // Get the databag contents from the HTTP request parameters. |
|
| 43 | - $aBags = $this->di->getRequest()->getAttribute('jxnbags', []); |
|
| 44 | - $this->xDatabag = new Databag($this, $this->readData($aBags)); |
|
| 45 | - } |
|
| 42 | +// Get the databag contents from the HTTP request parameters. |
|
| 43 | +$aBags = $this->di->getRequest()->getAttribute('jxnbags', []); |
|
| 44 | +$this->xDatabag = new Databag($this, $this->readData($aBags)); |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * @inheritDoc |
| 49 | 49 | */ |
| 50 | - public function getName(): string |
|
| 51 | - { |
|
| 52 | - return self::NAME; |
|
| 53 | - } |
|
| 50 | +public function getName(): string |
|
| 51 | +{ |
|
| 52 | +return self::NAME; |
|
| 53 | +} |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * @param mixed $xData |
| 57 | 57 | * |
| 58 | 58 | * @return array |
| 59 | 59 | */ |
| 60 | - private function readData($xData): array |
|
| 61 | - { |
|
| 62 | - // Todo: clean input data. |
|
| 63 | - // Todo: verify the checksums. |
|
| 64 | - return is_string($xData) ? |
|
| 65 | - (json_decode($xData, true) ?: []) : |
|
| 66 | - (is_array($xData) ? $xData : []); |
|
| 67 | - } |
|
| 60 | +private function readData($xData): array |
|
| 61 | +{ |
|
| 62 | +// Todo: clean input data. |
|
| 63 | +// Todo: verify the checksums. |
|
| 64 | +return is_string($xData) ? |
|
| 65 | +(json_decode($xData, true) ?: []) : |
|
| 66 | +(is_array($xData) ? $xData : []); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * @inheritDoc |
| 71 | 71 | */ |
| 72 | - public function getHash(): string |
|
| 73 | - { |
|
| 74 | - // Use the version number as hash |
|
| 75 | - return '4.0.0'; |
|
| 76 | - } |
|
| 72 | +public function getHash(): string |
|
| 73 | +{ |
|
| 74 | +// Use the version number as hash |
|
| 75 | +return '4.0.0'; |
|
| 76 | +} |
|
| 77 | 77 | |
| 78 | - /** |
|
| 78 | +/** |
|
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | - public function writeCommand(): void |
|
| 82 | - { |
|
| 83 | - $this->initDatabag(); |
|
| 84 | - if($this->xDatabag->touched()) |
|
| 85 | - { |
|
| 86 | - // Todo: calculate the checksums. |
|
| 87 | - $this->addCommand('databag.set', ['values' => $this->xDatabag]); |
|
| 88 | - } |
|
| 89 | - } |
|
| 81 | +public function writeCommand(): void |
|
| 82 | +{ |
|
| 83 | +$this->initDatabag(); |
|
| 84 | +if($this->xDatabag->touched()) |
|
| 85 | +{ |
|
| 86 | +// Todo: calculate the checksums. |
|
| 87 | +$this->addCommand('databag.set', ['values' => $this->xDatabag]); |
|
| 88 | +} |
|
| 89 | +} |
|
| 90 | 90 | |
| 91 | - /** |
|
| 91 | +/** |
|
| 92 | 92 | * @param string $sName |
| 93 | 93 | * |
| 94 | 94 | * @return DatabagContext |
| 95 | 95 | */ |
| 96 | - public function bag(string $sName): DatabagContext |
|
| 97 | - { |
|
| 98 | - $this->initDatabag(); |
|
| 99 | - return new DatabagContext($this->xDatabag, $sName); |
|
| 100 | - } |
|
| 96 | +public function bag(string $sName): DatabagContext |
|
| 97 | +{ |
|
| 98 | +$this->initDatabag(); |
|
| 99 | +return new DatabagContext($this->xDatabag, $sName); |
|
| 100 | +} |
|
| 101 | 101 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | private function initDatabag(): void |
| 36 | 36 | { |
| 37 | - if($this->xDatabag !== null) |
|
| 37 | + if ($this->xDatabag !== null) |
|
| 38 | 38 | { |
| 39 | 39 | return; |
| 40 | 40 | } |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | // Todo: clean input data. |
| 63 | 63 | // Todo: verify the checksums. |
| 64 | 64 | return is_string($xData) ? |
| 65 | - (json_decode($xData, true) ?: []) : |
|
| 66 | - (is_array($xData) ? $xData : []); |
|
| 65 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
| 67 | 66 | } |
| 68 | 67 | |
| 69 | 68 | /** |
@@ -81,7 +80,7 @@ discard block |
||
| 81 | 80 | public function writeCommand(): void |
| 82 | 81 | { |
| 83 | 82 | $this->initDatabag(); |
| 84 | - if($this->xDatabag->touched()) |
|
| 83 | + if ($this->xDatabag->touched()) |
|
| 85 | 84 | { |
| 86 | 85 | // Todo: calculate the checksums. |
| 87 | 86 | $this->addCommand('databag.set', ['values' => $this->xDatabag]); |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | rc: (name, method, parameters, options = {}) => jaxon.request({ type: 'class', name, method }, { parameters, ...options}), |
| 3 | 3 | rf: (name, parameters, options = {}) => jaxon.request({ type: 'func', name }, { parameters, ...options}), |
| 4 | 4 | <?php |
| 5 | -foreach($this->aCallableNames as $nIndex => $sName): |
|
| 5 | +foreach ($this->aCallableNames as $nIndex => $sName): |
|
| 6 | 6 | echo " c$nIndex: '$sName',\n"; |
| 7 | 7 | endforeach |
| 8 | 8 | ?> |