@@ -31,73 +31,73 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | trait ServicesTrait |
| 33 | 33 | { |
| 34 | - use DiTrait; |
|
| 34 | +use DiTrait; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * @return Translator |
| 38 | 38 | */ |
| 39 | - public function translator(): Translator |
|
| 40 | - { |
|
| 41 | - return $this->di()->g(Translator::class); |
|
| 42 | - } |
|
| 39 | +public function translator(): Translator |
|
| 40 | +{ |
|
| 41 | +return $this->di()->g(Translator::class); |
|
| 42 | +} |
|
| 43 | 43 | |
| 44 | - /** |
|
| 44 | +/** |
|
| 45 | 45 | * @return LoggerInterface |
| 46 | 46 | */ |
| 47 | - public function logger(): LoggerInterface |
|
| 48 | - { |
|
| 49 | - return $this->di()->getLogger(); |
|
| 50 | - } |
|
| 47 | +public function logger(): LoggerInterface |
|
| 48 | +{ |
|
| 49 | +return $this->di()->getLogger(); |
|
| 50 | +} |
|
| 51 | 51 | |
| 52 | - /** |
|
| 52 | +/** |
|
| 53 | 53 | * @return Bootstrap |
| 54 | 54 | */ |
| 55 | - protected function getBootstrap(): Bootstrap |
|
| 56 | - { |
|
| 57 | - return $this->di()->getBootstrap(); |
|
| 58 | - } |
|
| 55 | +protected function getBootstrap(): Bootstrap |
|
| 56 | +{ |
|
| 57 | +return $this->di()->getBootstrap(); |
|
| 58 | +} |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * @return PluginManager |
| 62 | 62 | */ |
| 63 | - protected function getPluginManager(): PluginManager |
|
| 64 | - { |
|
| 65 | - return $this->di()->getPluginManager(); |
|
| 66 | - } |
|
| 63 | +protected function getPluginManager(): PluginManager |
|
| 64 | +{ |
|
| 65 | +return $this->di()->getPluginManager(); |
|
| 66 | +} |
|
| 67 | 67 | |
| 68 | - /** |
|
| 68 | +/** |
|
| 69 | 69 | * @return RequestHandler |
| 70 | 70 | */ |
| 71 | - protected function getRequestHandler(): RequestHandler |
|
| 72 | - { |
|
| 73 | - return $this->di()->getRequestHandler(); |
|
| 74 | - } |
|
| 71 | +protected function getRequestHandler(): RequestHandler |
|
| 72 | +{ |
|
| 73 | +return $this->di()->getRequestHandler(); |
|
| 74 | +} |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | +/** |
|
| 77 | 77 | * @return ResponseManager |
| 78 | 78 | */ |
| 79 | - protected function getResponseManager(): ResponseManager |
|
| 80 | - { |
|
| 81 | - return $this->di()->getResponseManager(); |
|
| 82 | - } |
|
| 79 | +protected function getResponseManager(): ResponseManager |
|
| 80 | +{ |
|
| 81 | +return $this->di()->getResponseManager(); |
|
| 82 | +} |
|
| 83 | 83 | |
| 84 | - /** |
|
| 84 | +/** |
|
| 85 | 85 | * @return PackageManager |
| 86 | 86 | */ |
| 87 | - protected function getPackageManager(): PackageManager |
|
| 88 | - { |
|
| 89 | - return $this->di()->getPackageManager(); |
|
| 90 | - } |
|
| 87 | +protected function getPackageManager(): PackageManager |
|
| 88 | +{ |
|
| 89 | +return $this->di()->getPackageManager(); |
|
| 90 | +} |
|
| 91 | 91 | |
| 92 | - /** |
|
| 92 | +/** |
|
| 93 | 93 | * @return CodeGenerator |
| 94 | 94 | */ |
| 95 | - protected function getCodeGenerator(): CodeGenerator |
|
| 96 | - { |
|
| 97 | - return $this->di()->getCodeGenerator(); |
|
| 98 | - } |
|
| 95 | +protected function getCodeGenerator(): CodeGenerator |
|
| 96 | +{ |
|
| 97 | +return $this->di()->getCodeGenerator(); |
|
| 98 | +} |
|
| 99 | 99 | |
| 100 | - /** |
|
| 100 | +/** |
|
| 101 | 101 | * Add a view renderer with an id |
| 102 | 102 | * |
| 103 | 103 | * @param string $sRenderer The renderer name |
@@ -106,70 +106,70 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function addViewRenderer(string $sRenderer, string $sExtension, Closure $xClosure): void |
|
| 110 | - { |
|
| 111 | - $this->view()->setDefaultRenderer($sRenderer, $sExtension, $xClosure); |
|
| 112 | - } |
|
| 109 | +public function addViewRenderer(string $sRenderer, string $sExtension, Closure $xClosure): void |
|
| 110 | +{ |
|
| 111 | +$this->view()->setDefaultRenderer($sRenderer, $sExtension, $xClosure); |
|
| 112 | +} |
|
| 113 | 113 | |
| 114 | - /** |
|
| 114 | +/** |
|
| 115 | 115 | * @param LoggerInterface|Closure $xLogger |
| 116 | 116 | * |
| 117 | 117 | * @return void |
| 118 | 118 | */ |
| 119 | - public function setLogger(LoggerInterface|Closure $xLogger): void |
|
| 120 | - { |
|
| 121 | - $this->di()->setLogger($xLogger); |
|
| 122 | - } |
|
| 119 | +public function setLogger(LoggerInterface|Closure $xLogger): void |
|
| 120 | +{ |
|
| 121 | +$this->di()->setLogger($xLogger); |
|
| 122 | +} |
|
| 123 | 123 | |
| 124 | - /** |
|
| 124 | +/** |
|
| 125 | 125 | * Set the session manager |
| 126 | 126 | * |
| 127 | 127 | * @param Closure $xClosure A closure to create the session manager instance |
| 128 | 128 | * |
| 129 | 129 | * @return void |
| 130 | 130 | */ |
| 131 | - public function setSessionManager(Closure $xClosure): void |
|
| 132 | - { |
|
| 133 | - $this->di()->setSessionManager($xClosure); |
|
| 134 | - } |
|
| 131 | +public function setSessionManager(Closure $xClosure): void |
|
| 132 | +{ |
|
| 133 | +$this->di()->setSessionManager($xClosure); |
|
| 134 | +} |
|
| 135 | 135 | |
| 136 | - /** |
|
| 136 | +/** |
|
| 137 | 137 | * @return UploadHandlerInterface|null |
| 138 | 138 | */ |
| 139 | - public function upload(): ?UploadHandlerInterface |
|
| 140 | - { |
|
| 141 | - return $this->di()->getUploadHandler(); |
|
| 142 | - } |
|
| 139 | +public function upload(): ?UploadHandlerInterface |
|
| 140 | +{ |
|
| 141 | +return $this->di()->getUploadHandler(); |
|
| 142 | +} |
|
| 143 | 143 | |
| 144 | - /** |
|
| 144 | +/** |
|
| 145 | 145 | * @return PsrFactory |
| 146 | 146 | */ |
| 147 | - public function psr(): PsrFactory |
|
| 148 | - { |
|
| 149 | - return $this->di()->getPsrFactory(); |
|
| 150 | - } |
|
| 147 | +public function psr(): PsrFactory |
|
| 148 | +{ |
|
| 149 | +return $this->di()->getPsrFactory(); |
|
| 150 | +} |
|
| 151 | 151 | |
| 152 | - /** |
|
| 152 | +/** |
|
| 153 | 153 | * @return TemplateEngine |
| 154 | 154 | */ |
| 155 | - public function template(): TemplateEngine |
|
| 156 | - { |
|
| 157 | - return $this->di()->getTemplateEngine(); |
|
| 158 | - } |
|
| 155 | +public function template(): TemplateEngine |
|
| 156 | +{ |
|
| 157 | +return $this->di()->getTemplateEngine(); |
|
| 158 | +} |
|
| 159 | 159 | |
| 160 | - /** |
|
| 160 | +/** |
|
| 161 | 161 | * @return ViewRenderer |
| 162 | 162 | */ |
| 163 | - public function view(): ViewRenderer |
|
| 164 | - { |
|
| 165 | - return $this->di()->getViewRenderer(); |
|
| 166 | - } |
|
| 163 | +public function view(): ViewRenderer |
|
| 164 | +{ |
|
| 165 | +return $this->di()->getViewRenderer(); |
|
| 166 | +} |
|
| 167 | 167 | |
| 168 | - /** |
|
| 168 | +/** |
|
| 169 | 169 | * @return SessionInterface|null |
| 170 | 170 | */ |
| 171 | - public function session(): ?SessionInterface |
|
| 172 | - { |
|
| 173 | - return $this->di()->getSessionManager(); |
|
| 174 | - } |
|
| 171 | +public function session(): ?SessionInterface |
|
| 172 | +{ |
|
| 173 | +return $this->di()->getSessionManager(); |
|
| 174 | +} |
|
| 175 | 175 | } |
@@ -28,27 +28,27 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | trait PluginTrait |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * @return PluginManager |
| 33 | 33 | */ |
| 34 | - abstract public function getPluginManager(): PluginManager; |
|
| 34 | +abstract public function getPluginManager(): PluginManager; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * @return PackageManager |
| 38 | 38 | */ |
| 39 | - abstract public function getPackageManager(): PackageManager; |
|
| 39 | +abstract public function getPackageManager(): PackageManager; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 41 | +/** |
|
| 42 | 42 | * @return CodeGenerator |
| 43 | 43 | */ |
| 44 | - abstract public function getCodeGenerator(): CodeGenerator; |
|
| 44 | +abstract public function getCodeGenerator(): CodeGenerator; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * @return Bootstrap |
| 48 | 48 | */ |
| 49 | - abstract protected function getBootstrap(): Bootstrap; |
|
| 49 | +abstract protected function getBootstrap(): Bootstrap; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * Register request handlers, including functions, callable classes and directories. |
| 53 | 53 | * |
| 54 | 54 | * @param string $sType The type of request handler being registered |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | * @return void |
| 66 | 66 | * @throws SetupException |
| 67 | 67 | */ |
| 68 | - public function register(string $sType, string $sName, $xOptions = []): void |
|
| 69 | - { |
|
| 70 | - $this->getPluginManager()->registerCallable($sType, $sName, $xOptions); |
|
| 71 | - } |
|
| 68 | +public function register(string $sType, string $sName, $xOptions = []): void |
|
| 69 | +{ |
|
| 70 | +$this->getPluginManager()->registerCallable($sType, $sName, $xOptions); |
|
| 71 | +} |
|
| 72 | 72 | |
| 73 | - /** |
|
| 73 | +/** |
|
| 74 | 74 | * Register a plugin |
| 75 | 75 | * |
| 76 | 76 | * Below is a table for priorities and their description: |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | * @return void |
| 86 | 86 | * @throws SetupException |
| 87 | 87 | */ |
| 88 | - public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000) |
|
| 89 | - { |
|
| 90 | - $this->getPluginManager()->registerPlugin($sClassName, $sPluginName, $nPriority); |
|
| 91 | - } |
|
| 88 | +public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000) |
|
| 89 | +{ |
|
| 90 | +$this->getPluginManager()->registerPlugin($sClassName, $sPluginName, $nPriority); |
|
| 91 | +} |
|
| 92 | 92 | |
| 93 | - /** |
|
| 93 | +/** |
|
| 94 | 94 | * Register a package |
| 95 | 95 | * |
| 96 | 96 | * @param string $sClassName The package class |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @return void |
| 100 | 100 | * @throws SetupException |
| 101 | 101 | */ |
| 102 | - public function registerPackage(string $sClassName, array $xPkgOptions = []) |
|
| 103 | - { |
|
| 104 | - $this->getPackageManager()->registerPackage($sClassName, $xPkgOptions); |
|
| 105 | - } |
|
| 102 | +public function registerPackage(string $sClassName, array $xPkgOptions = []) |
|
| 103 | +{ |
|
| 104 | +$this->getPackageManager()->registerPackage($sClassName, $xPkgOptions); |
|
| 105 | +} |
|
| 106 | 106 | |
| 107 | - /** |
|
| 107 | +/** |
|
| 108 | 108 | * Find a response plugin by name or class name |
| 109 | 109 | * |
| 110 | 110 | * @template R of ResponsePluginInterface |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return ($sName is class-string ? R : ResponsePluginInterface)|null |
| 114 | 114 | */ |
| 115 | - public function plugin(string $sName): ResponsePluginInterface|null |
|
| 116 | - { |
|
| 117 | - return $this->getPluginManager()->getResponsePlugin($sName); |
|
| 118 | - } |
|
| 115 | +public function plugin(string $sName): ResponsePluginInterface|null |
|
| 116 | +{ |
|
| 117 | +return $this->getPluginManager()->getResponsePlugin($sName); |
|
| 118 | +} |
|
| 119 | 119 | |
| 120 | - /** |
|
| 120 | +/** |
|
| 121 | 121 | * Get a package instance |
| 122 | 122 | * |
| 123 | 123 | * @template P of AbstractPackage |
@@ -125,52 +125,52 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return P|null |
| 127 | 127 | */ |
| 128 | - public function package(string $sClassName): ?AbstractPackage |
|
| 129 | - { |
|
| 130 | - return $this->getPackageManager()->getPackage($sClassName); |
|
| 131 | - } |
|
| 128 | +public function package(string $sClassName): ?AbstractPackage |
|
| 129 | +{ |
|
| 130 | +return $this->getPackageManager()->getPackage($sClassName); |
|
| 131 | +} |
|
| 132 | 132 | |
| 133 | - /** |
|
| 133 | +/** |
|
| 134 | 134 | * Get the HTML tags to include Jaxon javascript files into the page. |
| 135 | 135 | * |
| 136 | 136 | * @return string |
| 137 | 137 | */ |
| 138 | - public function getJs(): string |
|
| 139 | - { |
|
| 140 | - return $this->getCodeGenerator()->getJs(); |
|
| 141 | - } |
|
| 138 | +public function getJs(): string |
|
| 139 | +{ |
|
| 140 | +return $this->getCodeGenerator()->getJs(); |
|
| 141 | +} |
|
| 142 | 142 | |
| 143 | - /** |
|
| 143 | +/** |
|
| 144 | 144 | * Get the HTML tags to include Jaxon javascript files into the page. |
| 145 | 145 | * |
| 146 | 146 | * @return string the javascript code |
| 147 | 147 | */ |
| 148 | - public function js(): string |
|
| 149 | - { |
|
| 150 | - return $this->getCodeGenerator()->getJs(); |
|
| 151 | - } |
|
| 148 | +public function js(): string |
|
| 149 | +{ |
|
| 150 | +return $this->getCodeGenerator()->getJs(); |
|
| 151 | +} |
|
| 152 | 152 | |
| 153 | - /** |
|
| 153 | +/** |
|
| 154 | 154 | * Get the HTML tags to include Jaxon CSS code and files into the page. |
| 155 | 155 | * |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - public function getCss(): string |
|
| 159 | - { |
|
| 160 | - return $this->getCodeGenerator()->getCss(); |
|
| 161 | - } |
|
| 158 | +public function getCss(): string |
|
| 159 | +{ |
|
| 160 | +return $this->getCodeGenerator()->getCss(); |
|
| 161 | +} |
|
| 162 | 162 | |
| 163 | - /** |
|
| 163 | +/** |
|
| 164 | 164 | * Get the HTML tags to include Jaxon CSS code and files into the page. |
| 165 | 165 | * |
| 166 | 166 | * @return string |
| 167 | 167 | */ |
| 168 | - public function css(): string |
|
| 169 | - { |
|
| 170 | - return $this->getCodeGenerator()->getCss(); |
|
| 171 | - } |
|
| 168 | +public function css(): string |
|
| 169 | +{ |
|
| 170 | +return $this->getCodeGenerator()->getCss(); |
|
| 171 | +} |
|
| 172 | 172 | |
| 173 | - /** |
|
| 173 | +/** |
|
| 174 | 174 | * Returns the js header and wrapper code to be printed into the page |
| 175 | 175 | * |
| 176 | 176 | * The javascript code returned by this function depends on the plugins |
@@ -182,12 +182,12 @@ discard block |
||
| 182 | 182 | * @return string |
| 183 | 183 | * @throws UriException |
| 184 | 184 | */ |
| 185 | - public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string |
|
| 186 | - { |
|
| 187 | - return $this->getCodeGenerator()->getScript($bIncludeJs, $bIncludeCss); |
|
| 188 | - } |
|
| 185 | +public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string |
|
| 186 | +{ |
|
| 187 | +return $this->getCodeGenerator()->getScript($bIncludeJs, $bIncludeCss); |
|
| 188 | +} |
|
| 189 | 189 | |
| 190 | - /** |
|
| 190 | +/** |
|
| 191 | 191 | * Returns the js header and wrapper code to be printed into the page |
| 192 | 192 | * |
| 193 | 193 | * @param bool $bIncludeJs Also get the js code |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | * @return string the javascript code |
| 197 | 197 | * @throws UriException |
| 198 | 198 | */ |
| 199 | - public function script(bool $bIncludeJs = false, bool $bIncludeCss = false): string |
|
| 200 | - { |
|
| 201 | - return $this->getCodeGenerator()->getScript($bIncludeJs, $bIncludeCss); |
|
| 202 | - } |
|
| 199 | +public function script(bool $bIncludeJs = false, bool $bIncludeCss = false): string |
|
| 200 | +{ |
|
| 201 | +return $this->getCodeGenerator()->getScript($bIncludeJs, $bIncludeCss); |
|
| 202 | +} |
|
| 203 | 203 | } |
@@ -32,110 +32,110 @@ |
||
| 32 | 32 | |
| 33 | 33 | final class Jaxon |
| 34 | 34 | { |
| 35 | - use Traits\ConfigTrait; |
|
| 36 | - use Traits\ServicesTrait; |
|
| 37 | - use Traits\PluginTrait; |
|
| 38 | - use Traits\RequestTrait; |
|
| 39 | - use Traits\ResponseTrait; |
|
| 40 | - use Traits\SendResponseTrait; |
|
| 41 | - |
|
| 42 | - /** |
|
| 35 | +use Traits\ConfigTrait; |
|
| 36 | +use Traits\ServicesTrait; |
|
| 37 | +use Traits\PluginTrait; |
|
| 38 | +use Traits\RequestTrait; |
|
| 39 | +use Traits\ResponseTrait; |
|
| 40 | +use Traits\SendResponseTrait; |
|
| 41 | + |
|
| 42 | +/** |
|
| 43 | 43 | * @var Jaxon|null |
| 44 | 44 | */ |
| 45 | - private static $xInstance = null; |
|
| 45 | +private static $xInstance = null; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * The constructor |
| 49 | 49 | * |
| 50 | 50 | * @param Container $xContainer |
| 51 | 51 | * @param ComponentContainer $xComponentContainer |
| 52 | 52 | */ |
| 53 | - private function __construct(Container $xContainer, ComponentContainer $xComponentContainer) |
|
| 54 | - { |
|
| 55 | - $this->xContainer = $xContainer; |
|
| 56 | - $this->xComponentContainer = $xComponentContainer; |
|
| 57 | - } |
|
| 53 | +private function __construct(Container $xContainer, ComponentContainer $xComponentContainer) |
|
| 54 | +{ |
|
| 55 | +$this->xContainer = $xContainer; |
|
| 56 | +$this->xComponentContainer = $xComponentContainer; |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * @return Jaxon |
| 61 | 61 | */ |
| 62 | - private static function createInstance(): Jaxon |
|
| 63 | - { |
|
| 64 | - $xContainer = new Container(); |
|
| 65 | - $xComponentContainer = new ComponentContainer($xContainer); |
|
| 66 | - self::$xInstance = new Jaxon($xContainer, $xComponentContainer); |
|
| 62 | +private static function createInstance(): Jaxon |
|
| 63 | +{ |
|
| 64 | +$xContainer = new Container(); |
|
| 65 | +$xComponentContainer = new ComponentContainer($xContainer); |
|
| 66 | +self::$xInstance = new Jaxon($xContainer, $xComponentContainer); |
|
| 67 | 67 | |
| 68 | - // Save the Jaxon and container instances |
|
| 69 | - $xContainer->val(Jaxon::class, self::$xInstance); |
|
| 70 | - $xContainer->val(ComponentContainer::class, $xComponentContainer); |
|
| 68 | +// Save the Jaxon and container instances |
|
| 69 | +$xContainer->val(Jaxon::class, self::$xInstance); |
|
| 70 | +$xContainer->val(ComponentContainer::class, $xComponentContainer); |
|
| 71 | 71 | |
| 72 | - // Make the helpers functions available in the global namespace. |
|
| 73 | - self::$xInstance->callback()->boot(function() { |
|
| 74 | - self::$xInstance->config()->globals(); |
|
| 75 | - }); |
|
| 72 | +// Make the helpers functions available in the global namespace. |
|
| 73 | +self::$xInstance->callback()->boot(function() { |
|
| 74 | +self::$xInstance->config()->globals(); |
|
| 75 | +}); |
|
| 76 | 76 | |
| 77 | - return self::$xInstance; |
|
| 78 | - } |
|
| 77 | +return self::$xInstance; |
|
| 78 | +} |
|
| 79 | 79 | |
| 80 | - /** |
|
| 80 | +/** |
|
| 81 | 81 | * @return Jaxon |
| 82 | 82 | */ |
| 83 | - public static function getInstance(): Jaxon |
|
| 84 | - { |
|
| 85 | - return self::$xInstance ?: self::$xInstance = self::createInstance(); |
|
| 86 | - } |
|
| 83 | +public static function getInstance(): Jaxon |
|
| 84 | +{ |
|
| 85 | +return self::$xInstance ?: self::$xInstance = self::createInstance(); |
|
| 86 | +} |
|
| 87 | 87 | |
| 88 | - /** |
|
| 88 | +/** |
|
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | - public function getVersion(): string |
|
| 92 | - { |
|
| 93 | - return \Jaxon\Jaxon::VERSION; |
|
| 94 | - } |
|
| 91 | +public function getVersion(): string |
|
| 92 | +{ |
|
| 93 | +return \Jaxon\Jaxon::VERSION; |
|
| 94 | +} |
|
| 95 | 95 | |
| 96 | - /** |
|
| 96 | +/** |
|
| 97 | 97 | * @return ConfigManager |
| 98 | 98 | */ |
| 99 | - public function config(): ConfigManager |
|
| 100 | - { |
|
| 101 | - return $this->xContainer->config(); |
|
| 102 | - } |
|
| 99 | +public function config(): ConfigManager |
|
| 100 | +{ |
|
| 101 | +return $this->xContainer->config(); |
|
| 102 | +} |
|
| 103 | 103 | |
| 104 | - /** |
|
| 104 | +/** |
|
| 105 | 105 | * Set the ajax endpoint URI |
| 106 | 106 | * |
| 107 | 107 | * @param string $sUri The ajax endpoint URI |
| 108 | 108 | * |
| 109 | 109 | * @return void |
| 110 | 110 | */ |
| 111 | - public function setUri(string $sUri): void |
|
| 112 | - { |
|
| 113 | - $this->config()->setOption('core.request.uri', $sUri); |
|
| 114 | - } |
|
| 111 | +public function setUri(string $sUri): void |
|
| 112 | +{ |
|
| 113 | +$this->config()->setOption('core.request.uri', $sUri); |
|
| 114 | +} |
|
| 115 | 115 | |
| 116 | - /** |
|
| 116 | +/** |
|
| 117 | 117 | * @return AppInterface |
| 118 | 118 | */ |
| 119 | - public function app(): AppInterface |
|
| 120 | - { |
|
| 121 | - return $this->xContainer->getApp(); |
|
| 122 | - } |
|
| 119 | +public function app(): AppInterface |
|
| 120 | +{ |
|
| 121 | +return $this->xContainer->getApp(); |
|
| 122 | +} |
|
| 123 | 123 | |
| 124 | - /** |
|
| 124 | +/** |
|
| 125 | 125 | * Get the callback manager |
| 126 | 126 | * |
| 127 | 127 | * @return CallbackManager |
| 128 | 128 | */ |
| 129 | - public function callback(): CallbackManager |
|
| 130 | - { |
|
| 131 | - return $this->xContainer->callback(); |
|
| 132 | - } |
|
| 129 | +public function callback(): CallbackManager |
|
| 130 | +{ |
|
| 131 | +return $this->xContainer->callback(); |
|
| 132 | +} |
|
| 133 | 133 | |
| 134 | - /** |
|
| 134 | +/** |
|
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | - public function reset(): void |
|
| 138 | - { |
|
| 139 | - self::$xInstance = null; |
|
| 140 | - } |
|
| 137 | +public function reset(): void |
|
| 138 | +{ |
|
| 139 | +self::$xInstance = null; |
|
| 140 | +} |
|
| 141 | 141 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function addCodeGenerator(string $sClassName, int $nPriority): void |
| 111 | 111 | { |
| 112 | - while(isset($this->aCodeGenerators[$nPriority])) |
|
| 112 | + while (isset($this->aCodeGenerators[$nPriority])) |
|
| 113 | 113 | { |
| 114 | 114 | $nPriority++; |
| 115 | 115 | } |
@@ -162,33 +162,33 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void |
| 164 | 164 | { |
| 165 | - if(!is_subclass_of($xGenerator, AbstractPlugin::class) || |
|
| 165 | + if (!is_subclass_of($xGenerator, AbstractPlugin::class) || |
|
| 166 | 166 | $this->xAssetManager->shallIncludeAssets($xGenerator)) |
| 167 | 167 | { |
| 168 | 168 | // HTML tags for CSS |
| 169 | - if(($sCss = trim($xGenerator->getCss(), " \n")) !== '') |
|
| 169 | + if (($sCss = trim($xGenerator->getCss(), " \n")) !== '') |
|
| 170 | 170 | { |
| 171 | 171 | $this->aCss[] = $sCss; |
| 172 | 172 | } |
| 173 | 173 | // HTML tags for js |
| 174 | - if(($sJs = trim($xGenerator->getJs(), " \n")) !== '') |
|
| 174 | + if (($sJs = trim($xGenerator->getJs(), " \n")) !== '') |
|
| 175 | 175 | { |
| 176 | 176 | $this->aJs[] = $sJs; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Additional js codes |
| 181 | - if(($xJsCode = $xGenerator->getJsCode()) !== null) |
|
| 181 | + if (($xJsCode = $xGenerator->getJsCode()) !== null) |
|
| 182 | 182 | { |
| 183 | - if(($sJs = trim($xJsCode->sJs, " \n")) !== '') |
|
| 183 | + if (($sJs = trim($xJsCode->sJs, " \n")) !== '') |
|
| 184 | 184 | { |
| 185 | 185 | $this->aCodeJs[] = $sJs; |
| 186 | 186 | } |
| 187 | - if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '') |
|
| 187 | + if (($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '') |
|
| 188 | 188 | { |
| 189 | 189 | $this->aCodeJsBefore[] = $sJsBefore; |
| 190 | 190 | } |
| 191 | - if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '') |
|
| 191 | + if (($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '') |
|
| 192 | 192 | { |
| 193 | 193 | $this->aCodeJsAfter[] = $sJsAfter; |
| 194 | 194 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | private function generateCodes(): void |
| 206 | 206 | { |
| 207 | - if($this->bGenerated) |
|
| 207 | + if ($this->bGenerated) |
|
| 208 | 208 | { |
| 209 | 209 | return; |
| 210 | 210 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $this->xAssetManager = $this->di->getAssetManager(); |
| 220 | 220 | |
| 221 | 221 | $this->sJsOptions = $this->xAssetManager->getJsOptions(); |
| 222 | - foreach($this->aCodeGenerators as $sClassName) |
|
| 222 | + foreach ($this->aCodeGenerators as $sClassName) |
|
| 223 | 223 | { |
| 224 | 224 | $this->generatePluginCodes($this->getCodeGenerator($sClassName)); |
| 225 | 225 | } |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | public function getJsScript(): string |
| 266 | 266 | { |
| 267 | 267 | $aJsScripts = []; |
| 268 | - foreach($this->aCodeGenerators as $sClassName) |
|
| 268 | + foreach ($this->aCodeGenerators as $sClassName) |
|
| 269 | 269 | { |
| 270 | 270 | $xGenerator = $this->getCodeGenerator($sClassName); |
| 271 | 271 | // Javascript code |
| 272 | - if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '') |
|
| 272 | + if (($sJsScript = trim($xGenerator->getScript(), " \n")) !== '') |
|
| 273 | 273 | { |
| 274 | 274 | $aJsScripts[] = $sJsScript; |
| 275 | 275 | } |
@@ -286,38 +286,36 @@ discard block |
||
| 286 | 286 | private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array |
| 287 | 287 | { |
| 288 | 288 | $aCodes = []; |
| 289 | - if($bIncludeCss) |
|
| 289 | + if ($bIncludeCss) |
|
| 290 | 290 | { |
| 291 | 291 | $aCodes[] = $this->getCss(); |
| 292 | 292 | } |
| 293 | - if($bIncludeJs) |
|
| 293 | + if ($bIncludeJs) |
|
| 294 | 294 | { |
| 295 | 295 | $aCodes[] = $this->getJs(); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : |
|
| 299 | - $this->xAssetManager->createJsFiles($this); |
|
| 298 | + $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : $this->xAssetManager->createJsFiles($this); |
|
| 300 | 299 | // Wrap the js code into the corresponding HTML tag. |
| 301 | 300 | $aCodes[] = $sUrl !== '' ? |
| 302 | - $this->render('include.js', ['sUrl' => $sUrl]) : |
|
| 303 | - $this->render('wrapper.js', ['sScript' => $this->getJsScript()]); |
|
| 301 | + $this->render('include.js', ['sUrl' => $sUrl]) : $this->render('wrapper.js', ['sScript' => $this->getJsScript()]); |
|
| 304 | 302 | |
| 305 | 303 | // Wrap the js codes into HTML tags. |
| 306 | - if(count($this->aCodeJsBefore) > 0) |
|
| 304 | + if (count($this->aCodeJsBefore) > 0) |
|
| 307 | 305 | { |
| 308 | 306 | $sScript = implode("\n\n", $this->aCodeJsBefore); |
| 309 | 307 | $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]); |
| 310 | 308 | } |
| 311 | - if(count($this->aCodeJs) > 0) |
|
| 309 | + if (count($this->aCodeJs) > 0) |
|
| 312 | 310 | { |
| 313 | 311 | $sScript = implode("\n\n", $this->aCodeJs); |
| 314 | 312 | $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]); |
| 315 | 313 | } |
| 316 | - if(count($this->aCodeJsFiles) > 0) |
|
| 314 | + if (count($this->aCodeJsFiles) > 0) |
|
| 317 | 315 | { |
| 318 | 316 | $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]); |
| 319 | 317 | } |
| 320 | - if(count($this->aCodeJsAfter) > 0) |
|
| 318 | + if (count($this->aCodeJsAfter) > 0) |
|
| 321 | 319 | { |
| 322 | 320 | $sScript = implode("\n\n", $this->aCodeJsAfter); |
| 323 | 321 | $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]); |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class Logger |
| 9 | 9 | { |
| 10 | - use LoggerTrait; |
|
| 10 | +use LoggerTrait; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * @param LoggerInterface $logger |
| 14 | 14 | */ |
| 15 | - public function __construct(private LoggerInterface $logger) |
|
| 16 | - {} |
|
| 15 | +public function __construct(private LoggerInterface $logger) |
|
| 16 | +{} |
|
| 17 | 17 | |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * Logs with an arbitrary level. |
| 20 | 20 | * |
| 21 | 21 | * @param mixed $level |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | - public function log($level, string|\Stringable $message, array $context = []): void |
|
| 28 | - { |
|
| 29 | - $this->logger->log($level, $message, $context); |
|
| 30 | - } |
|
| 27 | +public function log($level, string|\Stringable $message, array $context = []): void |
|
| 28 | +{ |
|
| 29 | +$this->logger->log($level, $message, $context); |
|
| 30 | +} |
|
| 31 | 31 | } |
@@ -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 | ?> |
@@ -6,24 +6,24 @@ |
||
| 6 | 6 | jaxon.config.defaultMethod = '<?php echo $this->sDefaultMethod ?>'; |
| 7 | 7 | jaxon.config.responseType = '<?php echo $this->sResponseType ?>'; |
| 8 | 8 | |
| 9 | -<?php if($this->nResponseQueueSize > 0): ?> |
|
| 9 | +<?php if ($this->nResponseQueueSize > 0): ?> |
|
| 10 | 10 | jaxon.config.responseQueueSize = <?php echo $this->nResponseQueueSize ?>; |
| 11 | 11 | <?php endif ?> |
| 12 | 12 | |
| 13 | -<?php if($this->bLoggingEnabled): ?> |
|
| 13 | +<?php if ($this->bLoggingEnabled): ?> |
|
| 14 | 14 | jaxon.debug.logger = '<?php echo Jaxon\rq(Jaxon\App\Component\Logger::class)->_class() ?>'; |
| 15 | 15 | <?php endif ?> |
| 16 | 16 | |
| 17 | -<?php if($this->bDebug): ?> |
|
| 17 | +<?php if ($this->bDebug): ?> |
|
| 18 | 18 | jaxon.debug.active = true; |
| 19 | -<?php if($this->sDebugOutputID): ?> |
|
| 19 | +<?php if ($this->sDebugOutputID): ?> |
|
| 20 | 20 | jaxon.debug.outputID = '<?php echo $this->sDebugOutputID ?>'; |
| 21 | 21 | <?php endif ?> |
| 22 | -<?php if($this->bVerboseDebug): ?> |
|
| 22 | +<?php if ($this->bVerboseDebug): ?> |
|
| 23 | 23 | jaxon.debug.verbose.active = true; |
| 24 | 24 | <?php endif ?> |
| 25 | 25 | <?php endif ?> |
| 26 | 26 | |
| 27 | -<?php if($this->sCsrfMetaName): ?> |
|
| 27 | +<?php if ($this->sCsrfMetaName): ?> |
|
| 28 | 28 | jaxon.setCsrf('<?php echo $this->sCsrfMetaName ?>'); |
| 29 | 29 | <?php endif ?> |