@@ -4,58 +4,58 @@ |
||
| 4 | 4 | |
| 5 | 5 | class DatabagContext |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * @var Databag |
| 9 | 9 | */ |
| 10 | - protected $xDatabag; |
|
| 10 | +protected $xDatabag; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - protected $sName; |
|
| 15 | +protected $sName; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * The constructor |
| 19 | 19 | * |
| 20 | 20 | * @param Databag $xDatabag |
| 21 | 21 | * @param string $sName |
| 22 | 22 | */ |
| 23 | - public function __construct(Databag $xDatabag, string $sName) |
|
| 24 | - { |
|
| 25 | - $this->xDatabag = $xDatabag; |
|
| 26 | - $this->sName = $sName; |
|
| 27 | - } |
|
| 23 | +public function __construct(Databag $xDatabag, string $sName) |
|
| 24 | +{ |
|
| 25 | +$this->xDatabag = $xDatabag; |
|
| 26 | +$this->sName = $sName; |
|
| 27 | +} |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @param string $sKey |
| 31 | 31 | * @param mixed $xValue |
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - public function set(string $sKey, $xValue): void |
|
| 36 | - { |
|
| 37 | - $this->xDatabag->set($this->sName, $sKey, $xValue); |
|
| 38 | - } |
|
| 35 | +public function set(string $sKey, $xValue): void |
|
| 36 | +{ |
|
| 37 | +$this->xDatabag->set($this->sName, $sKey, $xValue); |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @param string $sKey |
| 42 | 42 | * @param mixed $xValue |
| 43 | 43 | * |
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | - public function new(string $sKey, $xValue): void |
|
| 47 | - { |
|
| 48 | - $this->xDatabag->new($this->sName, $sKey, $xValue); |
|
| 49 | - } |
|
| 46 | +public function new(string $sKey, $xValue): void |
|
| 47 | +{ |
|
| 48 | +$this->xDatabag->new($this->sName, $sKey, $xValue); |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * @param string $sKey |
| 53 | 53 | * @param mixed $xValue |
| 54 | 54 | * |
| 55 | 55 | * @return mixed |
| 56 | 56 | */ |
| 57 | - public function get(string $sKey, $xValue = null): mixed |
|
| 58 | - { |
|
| 59 | - return $this->xDatabag->get($this->sName, $sKey, $xValue); |
|
| 60 | - } |
|
| 57 | +public function get(string $sKey, $xValue = null): mixed |
|
| 58 | +{ |
|
| 59 | +return $this->xDatabag->get($this->sName, $sKey, $xValue); |
|
| 60 | +} |
|
| 61 | 61 | } |
@@ -14,41 +14,41 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | trait ComponentTrait |
| 16 | 16 | { |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * Get the component helper |
| 19 | 19 | * |
| 20 | 20 | * @return ComponentHelper |
| 21 | 21 | */ |
| 22 | - abstract protected function helper(): ComponentHelper; |
|
| 22 | +abstract protected function helper(): ComponentHelper; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * Get the Ajax response |
| 26 | 26 | * |
| 27 | 27 | * @return AjaxResponse |
| 28 | 28 | */ |
| 29 | - abstract protected function response(): AjaxResponse; |
|
| 29 | +abstract protected function response(): AjaxResponse; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * Get the Jaxon request target |
| 33 | 33 | * |
| 34 | 34 | * @return TargetInterface|null |
| 35 | 35 | */ |
| 36 | - protected function target(): ?TargetInterface |
|
| 37 | - { |
|
| 38 | - return $this->helper()->xTarget; |
|
| 39 | - } |
|
| 36 | +protected function target(): ?TargetInterface |
|
| 37 | +{ |
|
| 38 | +return $this->helper()->xTarget; |
|
| 39 | +} |
|
| 40 | 40 | |
| 41 | - /** |
|
| 41 | +/** |
|
| 42 | 42 | * Get the temp cache |
| 43 | 43 | * |
| 44 | 44 | * @return Stash |
| 45 | 45 | */ |
| 46 | - protected function stash(): Stash |
|
| 47 | - { |
|
| 48 | - return $this->helper()->xStash; |
|
| 49 | - } |
|
| 46 | +protected function stash(): Stash |
|
| 47 | +{ |
|
| 48 | +return $this->helper()->xStash; |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * Get an instance of a Jaxon class by name |
| 53 | 53 | * |
| 54 | 54 | * @template T |
@@ -57,60 +57,60 @@ discard block |
||
| 57 | 57 | * @return T|null |
| 58 | 58 | * @throws SetupException |
| 59 | 59 | */ |
| 60 | - protected function cl(string $sClassName): mixed |
|
| 61 | - { |
|
| 62 | - return $this->helper()->cl($sClassName); |
|
| 63 | - } |
|
| 60 | +protected function cl(string $sClassName): mixed |
|
| 61 | +{ |
|
| 62 | +return $this->helper()->cl($sClassName); |
|
| 63 | +} |
|
| 64 | 64 | |
| 65 | - /** |
|
| 65 | +/** |
|
| 66 | 66 | * Get the logger |
| 67 | 67 | * |
| 68 | 68 | * @return LoggerInterface |
| 69 | 69 | */ |
| 70 | - protected function logger(): LoggerInterface |
|
| 71 | - { |
|
| 72 | - return $this->helper()->xLogger; |
|
| 73 | - } |
|
| 70 | +protected function logger(): LoggerInterface |
|
| 71 | +{ |
|
| 72 | +return $this->helper()->xLogger; |
|
| 73 | +} |
|
| 74 | 74 | |
| 75 | - /** |
|
| 75 | +/** |
|
| 76 | 76 | * Get the view renderer |
| 77 | 77 | * |
| 78 | 78 | * @return ViewRenderer |
| 79 | 79 | */ |
| 80 | - protected function view(): ViewRenderer |
|
| 81 | - { |
|
| 82 | - return $this->helper()->xViewRenderer; |
|
| 83 | - } |
|
| 80 | +protected function view(): ViewRenderer |
|
| 81 | +{ |
|
| 82 | +return $this->helper()->xViewRenderer; |
|
| 83 | +} |
|
| 84 | 84 | |
| 85 | - /** |
|
| 85 | +/** |
|
| 86 | 86 | * Get the session manager |
| 87 | 87 | * |
| 88 | 88 | * @return SessionInterface |
| 89 | 89 | */ |
| 90 | - protected function session(): SessionInterface |
|
| 91 | - { |
|
| 92 | - return $this->helper()->xSessionManager; |
|
| 93 | - } |
|
| 90 | +protected function session(): SessionInterface |
|
| 91 | +{ |
|
| 92 | +return $this->helper()->xSessionManager; |
|
| 93 | +} |
|
| 94 | 94 | |
| 95 | - /** |
|
| 95 | +/** |
|
| 96 | 96 | * Get the uploaded files |
| 97 | 97 | * |
| 98 | 98 | * @return array |
| 99 | 99 | */ |
| 100 | - protected function files(): array |
|
| 101 | - { |
|
| 102 | - return $this->helper()->xUploadHandler->files(); |
|
| 103 | - } |
|
| 100 | +protected function files(): array |
|
| 101 | +{ |
|
| 102 | +return $this->helper()->xUploadHandler->files(); |
|
| 103 | +} |
|
| 104 | 104 | |
| 105 | - /** |
|
| 105 | +/** |
|
| 106 | 106 | * Get a data bag. |
| 107 | 107 | * |
| 108 | 108 | * @param string $sBagName |
| 109 | 109 | * |
| 110 | 110 | * @return DatabagContext |
| 111 | 111 | */ |
| 112 | - protected function bag(string $sBagName): DatabagContext |
|
| 113 | - { |
|
| 114 | - return $this->response()->bag($sBagName); |
|
| 115 | - } |
|
| 112 | +protected function bag(string $sBagName): DatabagContext |
|
| 113 | +{ |
|
| 114 | +return $this->response()->bag($sBagName); |
|
| 115 | +} |
|
| 116 | 116 | } |
@@ -16,12 +16,12 @@ |
||
| 16 | 16 | |
| 17 | 17 | interface MetadataReaderInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Get the component metadata |
| 21 | 21 | * |
| 22 | 22 | * @param InputData $xInput |
| 23 | 23 | * |
| 24 | 24 | * @return Metadata |
| 25 | 25 | */ |
| 26 | - public function getAttributes(InputData $xInput): Metadata; |
|
| 26 | +public function getAttributes(InputData $xInput): Metadata; |
|
| 27 | 27 | } |
@@ -236,82 +236,82 @@ |
||
| 236 | 236 | $this->aComponentPublicMethods['node'], |
| 237 | 237 | $xReflectionClass->isSubclassOf(FuncComponent::class) => |
| 238 | 238 | $this->aComponentPublicMethods['func'], |
| 239 | - default => [], |
|
| 240 | - }; |
|
| 241 | - return [$aMethods, $aBaseMethods]; |
|
| 242 | - } |
|
| 239 | +default => [], |
|
| 240 | +}; |
|
| 241 | +return [$aMethods, $aBaseMethods]; |
|
| 242 | +} |
|
| 243 | 243 | |
| 244 | - /** |
|
| 244 | +/** |
|
| 245 | 245 | * @param ReflectionClass $xReflectionClass |
| 246 | 246 | * @param array $aMethods |
| 247 | 247 | * @param array $aOptions |
| 248 | 248 | * |
| 249 | 249 | * @return Metadata|null |
| 250 | 250 | */ |
| 251 | - private function getComponentMetadata(ReflectionClass $xReflectionClass, |
|
| 252 | - array $aMethods, array $aOptions): Metadata|null |
|
| 253 | - { |
|
| 254 | - /** @var Config|null */ |
|
| 255 | - $xPackageConfig = $aOptions['config'] ?? null; |
|
| 256 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 257 | - { |
|
| 258 | - return null; |
|
| 259 | - } |
|
| 260 | - $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
|
| 261 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 262 | - { |
|
| 263 | - return null; |
|
| 264 | - } |
|
| 251 | +private function getComponentMetadata(ReflectionClass $xReflectionClass, |
|
| 252 | +array $aMethods, array $aOptions): Metadata|null |
|
| 253 | +{ |
|
| 254 | +/** @var Config|null */ |
|
| 255 | +$xPackageConfig = $aOptions['config'] ?? null; |
|
| 256 | +if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 257 | +{ |
|
| 258 | +return null; |
|
| 259 | +} |
|
| 260 | +$sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
|
| 261 | +if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 262 | +{ |
|
| 263 | +return null; |
|
| 264 | +} |
|
| 265 | 265 | |
| 266 | - // Try to get the class metadata from the cache. |
|
| 267 | - $di = $this->cn(); |
|
| 268 | - $xMetadata = null; |
|
| 269 | - $xMetadataCache = null; |
|
| 270 | - $xConfig = $di->config(); |
|
| 271 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 272 | - { |
|
| 273 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 274 | - { |
|
| 275 | - $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
|
| 276 | - $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
|
| 277 | - } |
|
| 278 | - $xMetadataCache = $di->getMetadataCache(); |
|
| 279 | - $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
|
| 280 | - if($xMetadata !== null) |
|
| 281 | - { |
|
| 282 | - return $xMetadata; |
|
| 283 | - } |
|
| 284 | - } |
|
| 266 | +// Try to get the class metadata from the cache. |
|
| 267 | +$di = $this->cn(); |
|
| 268 | +$xMetadata = null; |
|
| 269 | +$xMetadataCache = null; |
|
| 270 | +$xConfig = $di->config(); |
|
| 271 | +if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 272 | +{ |
|
| 273 | +if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 274 | +{ |
|
| 275 | + $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
|
| 276 | + $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
|
| 277 | +} |
|
| 278 | +$xMetadataCache = $di->getMetadataCache(); |
|
| 279 | +$xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
|
| 280 | +if($xMetadata !== null) |
|
| 281 | +{ |
|
| 282 | + return $xMetadata; |
|
| 283 | +} |
|
| 284 | +} |
|
| 285 | 285 | |
| 286 | - $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
|
| 287 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 288 | - ReflectionProperty::IS_PROTECTED)); |
|
| 286 | +$aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
|
| 287 | +$xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 288 | + ReflectionProperty::IS_PROTECTED)); |
|
| 289 | 289 | |
| 290 | - $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
|
| 291 | - $xInput = new InputData($xReflectionClass, $aMethods, $aProperties); |
|
| 292 | - $xMetadata = $xMetadataReader->getAttributes($xInput); |
|
| 290 | +$xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
|
| 291 | +$xInput = new InputData($xReflectionClass, $aMethods, $aProperties); |
|
| 292 | +$xMetadata = $xMetadataReader->getAttributes($xInput); |
|
| 293 | 293 | |
| 294 | - // Try to save the metadata in the cache |
|
| 295 | - if($xMetadataCache !== null && $xMetadata !== null) |
|
| 296 | - { |
|
| 297 | - $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
|
| 298 | - } |
|
| 294 | +// Try to save the metadata in the cache |
|
| 295 | +if($xMetadataCache !== null && $xMetadata !== null) |
|
| 296 | +{ |
|
| 297 | +$xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
|
| 298 | +} |
|
| 299 | 299 | |
| 300 | - return $xMetadata; |
|
| 301 | - } |
|
| 300 | +return $xMetadata; |
|
| 301 | +} |
|
| 302 | 302 | |
| 303 | - /** |
|
| 303 | +/** |
|
| 304 | 304 | * @param ReflectionClass $xReflectionClass |
| 305 | 305 | * @param array $aOptions |
| 306 | 306 | * |
| 307 | 307 | * @return ComponentOptions |
| 308 | 308 | */ |
| 309 | - private function getComponentOptions(ReflectionClass $xReflectionClass, |
|
| 310 | - array $aOptions): ComponentOptions |
|
| 311 | - { |
|
| 312 | - $aMethods = $this->getPublicMethods($xReflectionClass); |
|
| 313 | - $xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions); |
|
| 309 | +private function getComponentOptions(ReflectionClass $xReflectionClass, |
|
| 310 | +array $aOptions): ComponentOptions |
|
| 311 | +{ |
|
| 312 | +$aMethods = $this->getPublicMethods($xReflectionClass); |
|
| 313 | +$xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions); |
|
| 314 | 314 | |
| 315 | - return new ComponentOptions($aMethods, $aOptions, $xMetadata); |
|
| 316 | - } |
|
| 315 | +return new ComponentOptions($aMethods, $aOptions, $xMetadata); |
|
| 316 | +} |
|
| 317 | 317 | } |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | $xRegistry->updateHash(false); // Disable hash calculation. |
| 152 | 152 | |
| 153 | 153 | $sComponentId = str_replace('\\', '.', $sClassName); |
| 154 | - if(!isset($this->aComponents[$sComponentId])) |
|
| 154 | + if (!isset($this->aComponents[$sComponentId])) |
|
| 155 | 155 | { |
| 156 | 156 | $aOptions = $xRegistry->getNamespaceComponentOptions($sClassName); |
| 157 | - if($aOptions !== null) |
|
| 157 | + if ($aOptions !== null) |
|
| 158 | 158 | { |
| 159 | 159 | $this->saveComponent($sClassName, $aOptions); |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | - if(isset($this->aComponents[$sComponentId])) |
|
| 162 | + if (isset($this->aComponents[$sComponentId])) |
|
| 163 | 163 | { |
| 164 | 164 | return; // The component is found. |
| 165 | 165 | } |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | // The component was not found in a registered namespace. We need to parse all |
| 168 | 168 | // the directories to be able to find a component registered without a namespace. |
| 169 | 169 | $sComponentId = str_replace('\\', '_', $sClassName); |
| 170 | - if(!isset($this->aComponents[$sComponentId])) |
|
| 170 | + if (!isset($this->aComponents[$sComponentId])) |
|
| 171 | 171 | { |
| 172 | 172 | $xRegistry->registerComponentsInDirectories(); |
| 173 | 173 | } |
| 174 | - if(isset($this->aComponents[$sComponentId])) |
|
| 174 | + if (isset($this->aComponents[$sComponentId])) |
|
| 175 | 175 | { |
| 176 | 176 | return; // The component is found. |
| 177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | public function getCallableObjects(): array |
| 190 | 190 | { |
| 191 | 191 | $aCallableObjects = []; |
| 192 | - foreach($this->aComponents as $sComponentId => $_) |
|
| 192 | + foreach ($this->aComponents as $sComponentId => $_) |
|
| 193 | 193 | { |
| 194 | 194 | $aCallableObjects[$sComponentId] = $this->makeCallableObject($sComponentId); |
| 195 | 195 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | private function setComponentPublicMethods(string $sKey, string $sClass): void |
| 206 | 206 | { |
| 207 | - if(isset($this->aComponentPublicMethods[$sKey])) |
|
| 207 | + if (isset($this->aComponentPublicMethods[$sKey])) |
|
| 208 | 208 | { |
| 209 | 209 | return; |
| 210 | 210 | } |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | /** @var Config|null */ |
| 255 | 255 | $xPackageConfig = $aOptions['config'] ?? null; |
| 256 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 256 | + if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 257 | 257 | { |
| 258 | 258 | return null; |
| 259 | 259 | } |
| 260 | 260 | $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
| 261 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 261 | + if (!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 262 | 262 | { |
| 263 | 263 | return null; |
| 264 | 264 | } |
@@ -268,23 +268,23 @@ discard block |
||
| 268 | 268 | $xMetadata = null; |
| 269 | 269 | $xMetadataCache = null; |
| 270 | 270 | $xConfig = $di->config(); |
| 271 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 271 | + if ($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 272 | 272 | { |
| 273 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 273 | + if (!$di->h('jaxon_metadata_cache_dir')) |
|
| 274 | 274 | { |
| 275 | 275 | $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
| 276 | 276 | $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
| 277 | 277 | } |
| 278 | 278 | $xMetadataCache = $di->getMetadataCache(); |
| 279 | 279 | $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
| 280 | - if($xMetadata !== null) |
|
| 280 | + if ($xMetadata !== null) |
|
| 281 | 281 | { |
| 282 | 282 | return $xMetadata; |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
| 287 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 287 | + $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC| |
|
| 288 | 288 | ReflectionProperty::IS_PROTECTED)); |
| 289 | 289 | |
| 290 | 290 | $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | $xMetadata = $xMetadataReader->getAttributes($xInput); |
| 293 | 293 | |
| 294 | 294 | // Try to save the metadata in the cache |
| 295 | - if($xMetadataCache !== null && $xMetadata !== null) |
|
| 295 | + if ($xMetadataCache !== null && $xMetadata !== null) |
|
| 296 | 296 | { |
| 297 | 297 | $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
| 298 | 298 | } |
@@ -15,81 +15,81 @@ |
||
| 15 | 15 | |
| 16 | 16 | trait CallableTrait |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * Register the values into the container |
| 20 | 20 | * |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - private function registerCallables(): void |
|
| 24 | - { |
|
| 25 | - // Validator |
|
| 26 | - $this->set(Validator::class, function($di) { |
|
| 27 | - return new Validator($di->g(ConfigManager::class), $di->g(Translator::class)); |
|
| 28 | - }); |
|
| 29 | - // Callable objects registry |
|
| 30 | - $this->set(ComponentRegistry::class, function($di) { |
|
| 31 | - return new ComponentRegistry($di->g(ComponentContainer::class)); |
|
| 32 | - }); |
|
| 33 | - // Callable class plugin |
|
| 34 | - $this->set(CallableClassPlugin::class, function($di) { |
|
| 35 | - $sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.class'); |
|
| 36 | - return new CallableClassPlugin($sPrefix, $di->getLogger(), |
|
| 37 | - $di->g(ComponentContainer::class), $di->g(ComponentRegistry::class), |
|
| 38 | - $di->g(Translator::class), $di->g(TemplateEngine::class), |
|
| 39 | - $di->g(Validator::class)); |
|
| 40 | - }); |
|
| 41 | - // Callable dir plugin |
|
| 42 | - $this->set(CallableDirPlugin::class, function($di) { |
|
| 43 | - return new CallableDirPlugin($di->g(ComponentContainer::class), |
|
| 44 | - $di->g(ComponentRegistry::class), $di->g(Translator::class)); |
|
| 45 | - }); |
|
| 46 | - // Callable function plugin |
|
| 47 | - $this->set(CallableFunctionPlugin::class, function($di) { |
|
| 48 | - $sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.function'); |
|
| 49 | - $bDebug = $di->g(ConfigManager::class)->getOption('core.debug.on', false); |
|
| 50 | - return new CallableFunctionPlugin($sPrefix, $bDebug, |
|
| 51 | - $di->g(Container::class), $di->g(TemplateEngine::class), |
|
| 52 | - $di->g(Translator::class), $di->g(Validator::class)); |
|
| 53 | - }); |
|
| 54 | - } |
|
| 23 | +private function registerCallables(): void |
|
| 24 | +{ |
|
| 25 | +// Validator |
|
| 26 | +$this->set(Validator::class, function($di) { |
|
| 27 | +return new Validator($di->g(ConfigManager::class), $di->g(Translator::class)); |
|
| 28 | +}); |
|
| 29 | +// Callable objects registry |
|
| 30 | +$this->set(ComponentRegistry::class, function($di) { |
|
| 31 | +return new ComponentRegistry($di->g(ComponentContainer::class)); |
|
| 32 | +}); |
|
| 33 | +// Callable class plugin |
|
| 34 | +$this->set(CallableClassPlugin::class, function($di) { |
|
| 35 | +$sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.class'); |
|
| 36 | +return new CallableClassPlugin($sPrefix, $di->getLogger(), |
|
| 37 | + $di->g(ComponentContainer::class), $di->g(ComponentRegistry::class), |
|
| 38 | + $di->g(Translator::class), $di->g(TemplateEngine::class), |
|
| 39 | + $di->g(Validator::class)); |
|
| 40 | +}); |
|
| 41 | +// Callable dir plugin |
|
| 42 | +$this->set(CallableDirPlugin::class, function($di) { |
|
| 43 | +return new CallableDirPlugin($di->g(ComponentContainer::class), |
|
| 44 | + $di->g(ComponentRegistry::class), $di->g(Translator::class)); |
|
| 45 | +}); |
|
| 46 | +// Callable function plugin |
|
| 47 | +$this->set(CallableFunctionPlugin::class, function($di) { |
|
| 48 | +$sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.function'); |
|
| 49 | +$bDebug = $di->g(ConfigManager::class)->getOption('core.debug.on', false); |
|
| 50 | +return new CallableFunctionPlugin($sPrefix, $bDebug, |
|
| 51 | + $di->g(Container::class), $di->g(TemplateEngine::class), |
|
| 52 | + $di->g(Translator::class), $di->g(Validator::class)); |
|
| 53 | +}); |
|
| 54 | +} |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * Get the callable registry |
| 58 | 58 | * |
| 59 | 59 | * @return ComponentRegistry |
| 60 | 60 | */ |
| 61 | - public function getComponentRegistry(): ComponentRegistry |
|
| 62 | - { |
|
| 63 | - return $this->g(ComponentRegistry::class); |
|
| 64 | - } |
|
| 61 | +public function getComponentRegistry(): ComponentRegistry |
|
| 62 | +{ |
|
| 63 | +return $this->g(ComponentRegistry::class); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Get the callable function plugin |
| 68 | 68 | * |
| 69 | 69 | * @return CallableFunctionPlugin |
| 70 | 70 | */ |
| 71 | - public function getCallableFunctionPlugin(): CallableFunctionPlugin |
|
| 72 | - { |
|
| 73 | - return $this->g(CallableFunctionPlugin::class); |
|
| 74 | - } |
|
| 71 | +public function getCallableFunctionPlugin(): CallableFunctionPlugin |
|
| 72 | +{ |
|
| 73 | +return $this->g(CallableFunctionPlugin::class); |
|
| 74 | +} |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | +/** |
|
| 77 | 77 | * Get the callable class plugin |
| 78 | 78 | * |
| 79 | 79 | * @return CallableClassPlugin |
| 80 | 80 | */ |
| 81 | - public function getCallableClassPlugin(): CallableClassPlugin |
|
| 82 | - { |
|
| 83 | - return $this->g(CallableClassPlugin::class); |
|
| 84 | - } |
|
| 81 | +public function getCallableClassPlugin(): CallableClassPlugin |
|
| 82 | +{ |
|
| 83 | +return $this->g(CallableClassPlugin::class); |
|
| 84 | +} |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * Get the callable dir plugin |
| 88 | 88 | * |
| 89 | 89 | * @return CallableDirPlugin |
| 90 | 90 | */ |
| 91 | - public function getCallableDirPlugin(): CallableDirPlugin |
|
| 92 | - { |
|
| 93 | - return $this->g(CallableDirPlugin::class); |
|
| 94 | - } |
|
| 91 | +public function getCallableDirPlugin(): CallableDirPlugin |
|
| 92 | +{ |
|
| 93 | +return $this->g(CallableDirPlugin::class); |
|
| 94 | +} |
|
| 95 | 95 | } |
@@ -16,104 +16,104 @@ |
||
| 16 | 16 | |
| 17 | 17 | trait AppTrait |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - private $sJsLibVersion = 'jaxon_javascript_library_version'; |
|
| 22 | +private $sJsLibVersion = 'jaxon_javascript_library_version'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * Register the values into the container |
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | - private function registerApp(): void |
|
| 30 | - { |
|
| 31 | - // Config Manager |
|
| 32 | - $this->set(ConfigEventManager::class, function($di) { |
|
| 33 | - return new ConfigEventManager($di->g(Container::class)); |
|
| 34 | - }); |
|
| 35 | - $this->set(ConfigManager::class, function($di) { |
|
| 36 | - $aDefaultOptions = require(__DIR__ . '/../../../config/lib.php'); |
|
| 37 | - return new ConfigManager($aDefaultOptions, $di->g(Translator::class), |
|
| 38 | - $di->g(ConfigReader::class), $di->g(ConfigSetter::class), |
|
| 39 | - $di->g(ConfigEventManager::class)); |
|
| 40 | - }); |
|
| 29 | +private function registerApp(): void |
|
| 30 | +{ |
|
| 31 | +// Config Manager |
|
| 32 | +$this->set(ConfigEventManager::class, function($di) { |
|
| 33 | +return new ConfigEventManager($di->g(Container::class)); |
|
| 34 | +}); |
|
| 35 | +$this->set(ConfigManager::class, function($di) { |
|
| 36 | +$aDefaultOptions = require(__DIR__ . '/../../../config/lib.php'); |
|
| 37 | +return new ConfigManager($aDefaultOptions, $di->g(Translator::class), |
|
| 38 | + $di->g(ConfigReader::class), $di->g(ConfigSetter::class), |
|
| 39 | + $di->g(ConfigEventManager::class)); |
|
| 40 | +}); |
|
| 41 | 41 | |
| 42 | - // Jaxon App |
|
| 43 | - $this->set(AppInterface::class, fn() => new App()); |
|
| 44 | - // Jaxon App bootstrap |
|
| 45 | - $this->set(Bootstrap::class, function($di) { |
|
| 46 | - return new Bootstrap($di->g(ConfigManager::class), |
|
| 47 | - $di->g(PackageManager::class), $di->g(CallbackManager::class)); |
|
| 48 | - }); |
|
| 49 | - // The javascript library version |
|
| 50 | - $this->set($this->sJsLibVersion, function($di) { |
|
| 51 | - $xRequest = $di->getRequest(); |
|
| 52 | - $aParams = $xRequest->getMethod() === 'POST' ? |
|
| 53 | - $xRequest->getParsedBody() : $xRequest->getQueryParams(); |
|
| 54 | - return $aParams['jxnv'] ?? '3.3.0'; |
|
| 55 | - }); |
|
| 56 | - } |
|
| 42 | +// Jaxon App |
|
| 43 | +$this->set(AppInterface::class, fn() => new App()); |
|
| 44 | +// Jaxon App bootstrap |
|
| 45 | +$this->set(Bootstrap::class, function($di) { |
|
| 46 | +return new Bootstrap($di->g(ConfigManager::class), |
|
| 47 | + $di->g(PackageManager::class), $di->g(CallbackManager::class)); |
|
| 48 | +}); |
|
| 49 | +// The javascript library version |
|
| 50 | +$this->set($this->sJsLibVersion, function($di) { |
|
| 51 | +$xRequest = $di->getRequest(); |
|
| 52 | +$aParams = $xRequest->getMethod() === 'POST' ? |
|
| 53 | + $xRequest->getParsedBody() : $xRequest->getQueryParams(); |
|
| 54 | +return $aParams['jxnv'] ?? '3.3.0'; |
|
| 55 | +}); |
|
| 56 | +} |
|
| 57 | 57 | |
| 58 | - /** |
|
| 58 | +/** |
|
| 59 | 59 | * Register the event handlers |
| 60 | 60 | * |
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | - private function setEventHandlers(): void |
|
| 64 | - { |
|
| 65 | - $xEventManager = $this->g(ConfigEventManager::class); |
|
| 66 | - $xEventManager->addLibConfigListener(Translator::class); |
|
| 67 | - } |
|
| 63 | +private function setEventHandlers(): void |
|
| 64 | +{ |
|
| 65 | +$xEventManager = $this->g(ConfigEventManager::class); |
|
| 66 | +$xEventManager->addLibConfigListener(Translator::class); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Get the App instance |
| 71 | 71 | * |
| 72 | 72 | * @return AppInterface |
| 73 | 73 | */ |
| 74 | - public function getApp(): AppInterface |
|
| 75 | - { |
|
| 76 | - return $this->g(AppInterface::class); |
|
| 77 | - } |
|
| 74 | +public function getApp(): AppInterface |
|
| 75 | +{ |
|
| 76 | +return $this->g(AppInterface::class); |
|
| 77 | +} |
|
| 78 | 78 | |
| 79 | - /** |
|
| 79 | +/** |
|
| 80 | 80 | * Get the App bootstrap |
| 81 | 81 | * |
| 82 | 82 | * @return Bootstrap |
| 83 | 83 | */ |
| 84 | - public function getBootstrap(): Bootstrap |
|
| 85 | - { |
|
| 86 | - return $this->g(Bootstrap::class); |
|
| 87 | - } |
|
| 84 | +public function getBootstrap(): Bootstrap |
|
| 85 | +{ |
|
| 86 | +return $this->g(Bootstrap::class); |
|
| 87 | +} |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | +/** |
|
| 90 | 90 | * Get the config manager |
| 91 | 91 | * |
| 92 | 92 | * @return ConfigManager |
| 93 | 93 | */ |
| 94 | - public function config(): ConfigManager |
|
| 95 | - { |
|
| 96 | - return $this->g(ConfigManager::class); |
|
| 97 | - } |
|
| 94 | +public function config(): ConfigManager |
|
| 95 | +{ |
|
| 96 | +return $this->g(ConfigManager::class); |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * Get the javascript library version |
| 101 | 101 | * |
| 102 | 102 | * @return string |
| 103 | 103 | */ |
| 104 | - public function getJsLibVersion(): string |
|
| 105 | - { |
|
| 106 | - return $this->g($this->sJsLibVersion); |
|
| 107 | - } |
|
| 104 | +public function getJsLibVersion(): string |
|
| 105 | +{ |
|
| 106 | +return $this->g($this->sJsLibVersion); |
|
| 107 | +} |
|
| 108 | 108 | |
| 109 | - /** |
|
| 109 | +/** |
|
| 110 | 110 | * Get the default request URI |
| 111 | 111 | * |
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | - public function getRequestUri(): string |
|
| 115 | - { |
|
| 116 | - return $this->config()->getOption('core.request.uri', |
|
| 117 | - $this->getParameterReader()->uri()); |
|
| 118 | - } |
|
| 114 | +public function getRequestUri(): string |
|
| 115 | +{ |
|
| 116 | +return $this->config()->getOption('core.request.uri', |
|
| 117 | +$this->getParameterReader()->uri()); |
|
| 118 | +} |
|
| 119 | 119 | } |
@@ -15,64 +15,64 @@ |
||
| 15 | 15 | |
| 16 | 16 | trait ResponseTrait |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * Register the values into the container |
| 20 | 20 | * |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - private function registerResponses(): void |
|
| 24 | - { |
|
| 25 | - // Global Response |
|
| 26 | - $this->set(Response::class, function($di) { |
|
| 27 | - return new Response($di->g(ResponseManager::class), $di->g(PluginManager::class)); |
|
| 28 | - }); |
|
| 29 | - // Response Manager |
|
| 30 | - $this->set(ResponseManager::class, function($di) { |
|
| 31 | - $sEncoding = trim($di->g(ConfigManager::class)->getOption('core.encoding', '')); |
|
| 32 | - return new ResponseManager($di->g(Container::class), $di->g(Translator::class), $sEncoding); |
|
| 33 | - }); |
|
| 34 | - } |
|
| 23 | +private function registerResponses(): void |
|
| 24 | +{ |
|
| 25 | +// Global Response |
|
| 26 | +$this->set(Response::class, function($di) { |
|
| 27 | +return new Response($di->g(ResponseManager::class), $di->g(PluginManager::class)); |
|
| 28 | +}); |
|
| 29 | +// Response Manager |
|
| 30 | +$this->set(ResponseManager::class, function($di) { |
|
| 31 | +$sEncoding = trim($di->g(ConfigManager::class)->getOption('core.encoding', '')); |
|
| 32 | +return new ResponseManager($di->g(Container::class), $di->g(Translator::class), $sEncoding); |
|
| 33 | +}); |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Get the response manager |
| 38 | 38 | * |
| 39 | 39 | * @return ResponseManager |
| 40 | 40 | */ |
| 41 | - public function getResponseManager(): ResponseManager |
|
| 42 | - { |
|
| 43 | - return $this->g(ResponseManager::class); |
|
| 44 | - } |
|
| 41 | +public function getResponseManager(): ResponseManager |
|
| 42 | +{ |
|
| 43 | +return $this->g(ResponseManager::class); |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * Get the global Response object |
| 48 | 48 | * |
| 49 | 49 | * @return Response |
| 50 | 50 | */ |
| 51 | - public function getResponse(): Response |
|
| 52 | - { |
|
| 53 | - return $this->g(Response::class); |
|
| 54 | - } |
|
| 51 | +public function getResponse(): Response |
|
| 52 | +{ |
|
| 53 | +return $this->g(Response::class); |
|
| 54 | +} |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * Create a new Jaxon response |
| 58 | 58 | * |
| 59 | 59 | * @return Response |
| 60 | 60 | */ |
| 61 | - public function newResponse(): Response |
|
| 62 | - { |
|
| 63 | - return new Response($this->g(ResponseManager::class), $this->g(PluginManager::class)); |
|
| 64 | - } |
|
| 61 | +public function newResponse(): Response |
|
| 62 | +{ |
|
| 63 | +return new Response($this->g(ResponseManager::class), $this->g(PluginManager::class)); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Create a new reponse for a Jaxon component |
| 68 | 68 | * |
| 69 | 69 | * @param JxnCall $xJxnCall |
| 70 | 70 | * |
| 71 | 71 | * @return NodeResponse |
| 72 | 72 | */ |
| 73 | - public function newNodeResponse(JxnCall $xJxnCall): NodeResponse |
|
| 74 | - { |
|
| 75 | - return new NodeResponse($this->g(ResponseManager::class), |
|
| 76 | - $this->g(PluginManager::class), $xJxnCall); |
|
| 77 | - } |
|
| 73 | +public function newNodeResponse(JxnCall $xJxnCall): NodeResponse |
|
| 74 | +{ |
|
| 75 | +return new NodeResponse($this->g(ResponseManager::class), |
|
| 76 | +$this->g(PluginManager::class), $xJxnCall); |
|
| 77 | +} |
|
| 78 | 78 | } |
@@ -18,78 +18,78 @@ |
||
| 18 | 18 | |
| 19 | 19 | trait ViewTrait |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * Register the values into the container |
| 23 | 23 | * |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | - private function registerViews(): void |
|
| 27 | - { |
|
| 28 | - // Jaxon template view |
|
| 29 | - $this->set(TemplateView::class, function($di) { |
|
| 30 | - return new TemplateView($di->g(TemplateEngine::class)); |
|
| 31 | - }); |
|
| 32 | - // View Renderer |
|
| 33 | - $this->set(ViewRenderer::class, function($di) { |
|
| 34 | - $xViewRenderer = new ViewRenderer($di->g(Container::class)); |
|
| 35 | - // Add the default view renderer |
|
| 36 | - $xViewRenderer->addRenderer('jaxon', function($di) { |
|
| 37 | - return $di->g(TemplateView::class); |
|
| 38 | - }); |
|
| 39 | - $sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 40 | - $sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 41 | - // By default, render pagination templates with Jaxon. |
|
| 42 | - $xViewRenderer->addNamespace('jaxon', $sTemplateDir, '.php', 'jaxon'); |
|
| 43 | - $xViewRenderer->addNamespace('pagination', $sPaginationDir, '.php', 'jaxon'); |
|
| 44 | - return $xViewRenderer; |
|
| 45 | - }); |
|
| 26 | +private function registerViews(): void |
|
| 27 | +{ |
|
| 28 | +// Jaxon template view |
|
| 29 | +$this->set(TemplateView::class, function($di) { |
|
| 30 | +return new TemplateView($di->g(TemplateEngine::class)); |
|
| 31 | +}); |
|
| 32 | +// View Renderer |
|
| 33 | +$this->set(ViewRenderer::class, function($di) { |
|
| 34 | +$xViewRenderer = new ViewRenderer($di->g(Container::class)); |
|
| 35 | +// Add the default view renderer |
|
| 36 | +$xViewRenderer->addRenderer('jaxon', function($di) { |
|
| 37 | + return $di->g(TemplateView::class); |
|
| 38 | +}); |
|
| 39 | +$sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 40 | +$sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 41 | +// By default, render pagination templates with Jaxon. |
|
| 42 | +$xViewRenderer->addNamespace('jaxon', $sTemplateDir, '.php', 'jaxon'); |
|
| 43 | +$xViewRenderer->addNamespace('pagination', $sPaginationDir, '.php', 'jaxon'); |
|
| 44 | +return $xViewRenderer; |
|
| 45 | +}); |
|
| 46 | 46 | |
| 47 | - // By default there is no dialog library registry. |
|
| 48 | - $this->set(LibraryRegistryInterface::class, function($di) { |
|
| 49 | - return null; |
|
| 50 | - }); |
|
| 51 | - // Dialog command |
|
| 52 | - $this->set(DialogCommand::class, function($di) { |
|
| 53 | - return new DialogCommand($di->g(LibraryRegistryInterface::class)); |
|
| 54 | - }); |
|
| 55 | - // Pagination renderer |
|
| 56 | - $this->set(RendererInterface::class, function($di) { |
|
| 57 | - return new Renderer($di->g(ViewRenderer::class)); |
|
| 58 | - }); |
|
| 47 | +// By default there is no dialog library registry. |
|
| 48 | +$this->set(LibraryRegistryInterface::class, function($di) { |
|
| 49 | +return null; |
|
| 50 | +}); |
|
| 51 | +// Dialog command |
|
| 52 | +$this->set(DialogCommand::class, function($di) { |
|
| 53 | +return new DialogCommand($di->g(LibraryRegistryInterface::class)); |
|
| 54 | +}); |
|
| 55 | +// Pagination renderer |
|
| 56 | +$this->set(RendererInterface::class, function($di) { |
|
| 57 | +return new Renderer($di->g(ViewRenderer::class)); |
|
| 58 | +}); |
|
| 59 | 59 | |
| 60 | - // Helpers for HTML custom attributes formatting |
|
| 61 | - $this->set(HtmlAttrHelper::class, function($di) { |
|
| 62 | - return new HtmlAttrHelper($di->g(ComponentContainer::class)); |
|
| 63 | - }); |
|
| 64 | - } |
|
| 60 | +// Helpers for HTML custom attributes formatting |
|
| 61 | +$this->set(HtmlAttrHelper::class, function($di) { |
|
| 62 | +return new HtmlAttrHelper($di->g(ComponentContainer::class)); |
|
| 63 | +}); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Get the view renderer |
| 68 | 68 | * |
| 69 | 69 | * @return ViewRenderer |
| 70 | 70 | */ |
| 71 | - public function getViewRenderer(): ViewRenderer |
|
| 72 | - { |
|
| 73 | - return $this->g(ViewRenderer::class); |
|
| 74 | - } |
|
| 71 | +public function getViewRenderer(): ViewRenderer |
|
| 72 | +{ |
|
| 73 | +return $this->g(ViewRenderer::class); |
|
| 74 | +} |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | +/** |
|
| 77 | 77 | * Get the custom attributes helper |
| 78 | 78 | * |
| 79 | 79 | * @return HtmlAttrHelper |
| 80 | 80 | */ |
| 81 | - public function getHtmlAttrHelper(): HtmlAttrHelper |
|
| 82 | - { |
|
| 83 | - return $this->g(HtmlAttrHelper::class); |
|
| 84 | - } |
|
| 81 | +public function getHtmlAttrHelper(): HtmlAttrHelper |
|
| 82 | +{ |
|
| 83 | +return $this->g(HtmlAttrHelper::class); |
|
| 84 | +} |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * Get the dialog command |
| 88 | 88 | * |
| 89 | 89 | * @return DialogCommand |
| 90 | 90 | */ |
| 91 | - public function getDialogCommand(): DialogCommand |
|
| 92 | - { |
|
| 93 | - return $this->g(DialogCommand::class); |
|
| 94 | - } |
|
| 91 | +public function getDialogCommand(): DialogCommand |
|
| 92 | +{ |
|
| 93 | +return $this->g(DialogCommand::class); |
|
| 94 | +} |
|
| 95 | 95 | } |
@@ -14,78 +14,78 @@ |
||
| 14 | 14 | |
| 15 | 15 | trait UtilTrait |
| 16 | 16 | { |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * Register the values into the container |
| 19 | 19 | * |
| 20 | 20 | * @return void |
| 21 | 21 | */ |
| 22 | - private function registerUtils(): void |
|
| 23 | - { |
|
| 24 | - // Translator |
|
| 25 | - $this->set(Translator::class, function($di) { |
|
| 26 | - $xTranslator = new Translator(); |
|
| 27 | - $sResourceDir = rtrim(trim($di->g('jaxon.core.dir.translation')), '/\\'); |
|
| 28 | - // Load the debug translations |
|
| 29 | - $xTranslator->loadTranslations($sResourceDir . '/en/errors.php', 'en'); |
|
| 30 | - $xTranslator->loadTranslations($sResourceDir . '/fr/errors.php', 'fr'); |
|
| 31 | - $xTranslator->loadTranslations($sResourceDir . '/es/errors.php', 'es'); |
|
| 32 | - // Load the config translations |
|
| 33 | - $xTranslator->loadTranslations($sResourceDir . '/en/config.php', 'en'); |
|
| 34 | - $xTranslator->loadTranslations($sResourceDir . '/fr/config.php', 'fr'); |
|
| 35 | - $xTranslator->loadTranslations($sResourceDir . '/es/config.php', 'es'); |
|
| 36 | - // Load the labels translations |
|
| 37 | - $xTranslator->loadTranslations($sResourceDir . '/en/labels.php', 'en'); |
|
| 38 | - $xTranslator->loadTranslations($sResourceDir . '/fr/labels.php', 'fr'); |
|
| 39 | - $xTranslator->loadTranslations($sResourceDir . '/es/labels.php', 'es'); |
|
| 40 | - return $xTranslator; |
|
| 41 | - }); |
|
| 22 | +private function registerUtils(): void |
|
| 23 | +{ |
|
| 24 | +// Translator |
|
| 25 | +$this->set(Translator::class, function($di) { |
|
| 26 | +$xTranslator = new Translator(); |
|
| 27 | +$sResourceDir = rtrim(trim($di->g('jaxon.core.dir.translation')), '/\\'); |
|
| 28 | +// Load the debug translations |
|
| 29 | +$xTranslator->loadTranslations($sResourceDir . '/en/errors.php', 'en'); |
|
| 30 | +$xTranslator->loadTranslations($sResourceDir . '/fr/errors.php', 'fr'); |
|
| 31 | +$xTranslator->loadTranslations($sResourceDir . '/es/errors.php', 'es'); |
|
| 32 | +// Load the config translations |
|
| 33 | +$xTranslator->loadTranslations($sResourceDir . '/en/config.php', 'en'); |
|
| 34 | +$xTranslator->loadTranslations($sResourceDir . '/fr/config.php', 'fr'); |
|
| 35 | +$xTranslator->loadTranslations($sResourceDir . '/es/config.php', 'es'); |
|
| 36 | +// Load the labels translations |
|
| 37 | +$xTranslator->loadTranslations($sResourceDir . '/en/labels.php', 'en'); |
|
| 38 | +$xTranslator->loadTranslations($sResourceDir . '/fr/labels.php', 'fr'); |
|
| 39 | +$xTranslator->loadTranslations($sResourceDir . '/es/labels.php', 'es'); |
|
| 40 | +return $xTranslator; |
|
| 41 | +}); |
|
| 42 | 42 | |
| 43 | - // Config reader |
|
| 44 | - $this->set(ConfigReader::class, function($di) { |
|
| 45 | - return new ConfigReader($di->g(ConfigSetter::class)); |
|
| 46 | - }); |
|
| 47 | - // Config setter |
|
| 48 | - $this->set(ConfigSetter::class, function() { |
|
| 49 | - return new ConfigSetter(); |
|
| 50 | - }); |
|
| 51 | - // Template engine |
|
| 52 | - $this->set(TemplateEngine::class, function($di) { |
|
| 53 | - $xTemplateEngine = new TemplateEngine(); |
|
| 54 | - $sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 55 | - $sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 56 | - $xTemplateEngine->addNamespace('jaxon', $sTemplateDir, '.php'); |
|
| 57 | - $xTemplateEngine->addNamespace('pagination', $sPaginationDir, '.php'); |
|
| 58 | - $xTemplateEngine->setDefaultNamespace('jaxon'); |
|
| 59 | - return $xTemplateEngine; |
|
| 60 | - }); |
|
| 61 | - // URI detector |
|
| 62 | - $this->set(UriDetector::class, function() { |
|
| 63 | - return new UriDetector(); |
|
| 64 | - }); |
|
| 43 | +// Config reader |
|
| 44 | +$this->set(ConfigReader::class, function($di) { |
|
| 45 | +return new ConfigReader($di->g(ConfigSetter::class)); |
|
| 46 | +}); |
|
| 47 | +// Config setter |
|
| 48 | +$this->set(ConfigSetter::class, function() { |
|
| 49 | +return new ConfigSetter(); |
|
| 50 | +}); |
|
| 51 | +// Template engine |
|
| 52 | +$this->set(TemplateEngine::class, function($di) { |
|
| 53 | +$xTemplateEngine = new TemplateEngine(); |
|
| 54 | +$sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 55 | +$sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 56 | +$xTemplateEngine->addNamespace('jaxon', $sTemplateDir, '.php'); |
|
| 57 | +$xTemplateEngine->addNamespace('pagination', $sPaginationDir, '.php'); |
|
| 58 | +$xTemplateEngine->setDefaultNamespace('jaxon'); |
|
| 59 | +return $xTemplateEngine; |
|
| 60 | +}); |
|
| 61 | +// URI detector |
|
| 62 | +$this->set(UriDetector::class, function() { |
|
| 63 | +return new UriDetector(); |
|
| 64 | +}); |
|
| 65 | 65 | |
| 66 | - // Temp cache for Jaxon components |
|
| 67 | - $this->set(Stash::class, function() { |
|
| 68 | - return new Stash(); |
|
| 69 | - }); |
|
| 70 | - } |
|
| 66 | +// Temp cache for Jaxon components |
|
| 67 | +$this->set(Stash::class, function() { |
|
| 68 | +return new Stash(); |
|
| 69 | +}); |
|
| 70 | +} |
|
| 71 | 71 | |
| 72 | - /** |
|
| 72 | +/** |
|
| 73 | 73 | * Get the template engine |
| 74 | 74 | * |
| 75 | 75 | * @return TemplateEngine |
| 76 | 76 | */ |
| 77 | - public function getTemplateEngine(): TemplateEngine |
|
| 78 | - { |
|
| 79 | - return $this->g(TemplateEngine::class); |
|
| 80 | - } |
|
| 77 | +public function getTemplateEngine(): TemplateEngine |
|
| 78 | +{ |
|
| 79 | +return $this->g(TemplateEngine::class); |
|
| 80 | +} |
|
| 81 | 81 | |
| 82 | - /** |
|
| 82 | +/** |
|
| 83 | 83 | * Get the temp cache for Jaxon components |
| 84 | 84 | * |
| 85 | 85 | * @return Stash |
| 86 | 86 | */ |
| 87 | - public function getStash(): Stash |
|
| 88 | - { |
|
| 89 | - return $this->g(Stash::class); |
|
| 90 | - } |
|
| 87 | +public function getStash(): Stash |
|
| 88 | +{ |
|
| 89 | +return $this->g(Stash::class); |
|
| 90 | +} |
|
| 91 | 91 | } |