@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | use function ltrim; |
| 23 | 23 | |
| 24 | -#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | |
|
| 25 | - Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] |
|
| 24 | +#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_PROPERTY| |
|
| 25 | + Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)] |
|
| 26 | 26 | class Inject extends AbstractAttribute |
| 27 | 27 | { |
| 28 | 28 | /** |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function validate(): void |
| 80 | 80 | { |
| 81 | - if($this->nTarget === Attribute::TARGET_CLASS) |
|
| 81 | + if ($this->nTarget === Attribute::TARGET_CLASS) |
|
| 82 | 82 | { |
| 83 | - if(!$this->attr || !$this->type) |
|
| 83 | + if (!$this->attr || !$this->type) |
|
| 84 | 84 | { |
| 85 | 85 | throw new SetupException('When applied to a class, the Inject attribute requires two arguments.'); |
| 86 | 86 | } |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | - if($this->nTarget === Attribute::TARGET_METHOD) |
|
| 89 | + if ($this->nTarget === Attribute::TARGET_METHOD) |
|
| 90 | 90 | { |
| 91 | - if(!$this->attr) |
|
| 91 | + if (!$this->attr) |
|
| 92 | 92 | { |
| 93 | 93 | throw new SetupException('When applied to a method, the Inject attribute requires the "attr" argument.'); |
| 94 | 94 | } |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private function getFullClassName(): void |
| 102 | 102 | { |
| 103 | - if(!$this->type) |
|
| 103 | + if (!$this->type) |
|
| 104 | 104 | { |
| 105 | 105 | // If no type is provided, take the attribute type. |
| 106 | 106 | $this->type = $this->aTypes[$this->attr] ?? ''; |
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | - if($this->type[0] === '\\') |
|
| 109 | + if ($this->type[0] === '\\') |
|
| 110 | 110 | { |
| 111 | 111 | $this->type = ltrim($this->type, '\\'); |
| 112 | 112 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | $aFiles = scandir($this->sCacheDir); |
| 46 | 46 | foreach ($aFiles as $sFile) |
| 47 | 47 | { |
| 48 | - if($sFile !== '.' && $sFile !== '..') |
|
| 48 | + if ($sFile !== '.' && $sFile !== '..') |
|
| 49 | 49 | { |
| 50 | 50 | @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
| 51 | 51 | } |
@@ -241,83 +241,83 @@ |
||
| 241 | 241 | $this->aComponentPublicMethods['node'], |
| 242 | 242 | $xReflectionClass->isSubclassOf(FuncComponent::class) => |
| 243 | 243 | $this->aComponentPublicMethods['func'], |
| 244 | - default => [[], []], |
|
| 245 | - }; |
|
| 244 | +default => [[], []], |
|
| 245 | +}; |
|
| 246 | 246 | |
| 247 | - return [$aMethods, ...$aBaseMethods]; |
|
| 248 | - } |
|
| 247 | +return [$aMethods, ...$aBaseMethods]; |
|
| 248 | +} |
|
| 249 | 249 | |
| 250 | - /** |
|
| 250 | +/** |
|
| 251 | 251 | * @param ReflectionClass $xReflectionClass |
| 252 | 252 | * @param array $aMethods |
| 253 | 253 | * @param array $aOptions |
| 254 | 254 | * |
| 255 | 255 | * @return Metadata|null |
| 256 | 256 | */ |
| 257 | - private function getComponentMetadata(ReflectionClass $xReflectionClass, |
|
| 258 | - array $aMethods, array $aOptions): Metadata|null |
|
| 259 | - { |
|
| 260 | - /** @var Config|null */ |
|
| 261 | - $xPackageConfig = $aOptions['config'] ?? null; |
|
| 262 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 263 | - { |
|
| 264 | - return null; |
|
| 265 | - } |
|
| 266 | - $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
|
| 267 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 268 | - { |
|
| 269 | - return null; |
|
| 270 | - } |
|
| 257 | +private function getComponentMetadata(ReflectionClass $xReflectionClass, |
|
| 258 | +array $aMethods, array $aOptions): Metadata|null |
|
| 259 | +{ |
|
| 260 | +/** @var Config|null */ |
|
| 261 | +$xPackageConfig = $aOptions['config'] ?? null; |
|
| 262 | +if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 263 | +{ |
|
| 264 | +return null; |
|
| 265 | +} |
|
| 266 | +$sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
|
| 267 | +if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 268 | +{ |
|
| 269 | +return null; |
|
| 270 | +} |
|
| 271 | 271 | |
| 272 | - // Try to get the class metadata from the cache. |
|
| 273 | - $di = $this->cn(); |
|
| 274 | - $xMetadata = null; |
|
| 275 | - $xMetadataCache = null; |
|
| 276 | - $xConfig = $di->config(); |
|
| 277 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 278 | - { |
|
| 279 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 280 | - { |
|
| 281 | - $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
|
| 282 | - $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
|
| 283 | - } |
|
| 284 | - $xMetadataCache = $di->getMetadataCache(); |
|
| 285 | - $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
|
| 286 | - if($xMetadata !== null) |
|
| 287 | - { |
|
| 288 | - return $xMetadata; |
|
| 289 | - } |
|
| 290 | - } |
|
| 272 | +// Try to get the class metadata from the cache. |
|
| 273 | +$di = $this->cn(); |
|
| 274 | +$xMetadata = null; |
|
| 275 | +$xMetadataCache = null; |
|
| 276 | +$xConfig = $di->config(); |
|
| 277 | +if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 278 | +{ |
|
| 279 | +if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 280 | +{ |
|
| 281 | + $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
|
| 282 | + $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
|
| 283 | +} |
|
| 284 | +$xMetadataCache = $di->getMetadataCache(); |
|
| 285 | +$xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
|
| 286 | +if($xMetadata !== null) |
|
| 287 | +{ |
|
| 288 | + return $xMetadata; |
|
| 289 | +} |
|
| 290 | +} |
|
| 291 | 291 | |
| 292 | - $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
|
| 293 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 294 | - ReflectionProperty::IS_PROTECTED)); |
|
| 292 | +$aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
|
| 293 | +$xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 294 | + ReflectionProperty::IS_PROTECTED)); |
|
| 295 | 295 | |
| 296 | - $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
|
| 297 | - $xInput = new InputData($xReflectionClass, $aMethods, $aProperties); |
|
| 298 | - $xMetadata = $xMetadataReader->getAttributes($xInput); |
|
| 296 | +$xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
|
| 297 | +$xInput = new InputData($xReflectionClass, $aMethods, $aProperties); |
|
| 298 | +$xMetadata = $xMetadataReader->getAttributes($xInput); |
|
| 299 | 299 | |
| 300 | - // Try to save the metadata in the cache |
|
| 301 | - if($xMetadataCache !== null) |
|
| 302 | - { |
|
| 303 | - $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
|
| 304 | - } |
|
| 300 | +// Try to save the metadata in the cache |
|
| 301 | +if($xMetadataCache !== null) |
|
| 302 | +{ |
|
| 303 | +$xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
|
| 304 | +} |
|
| 305 | 305 | |
| 306 | - return $xMetadata; |
|
| 307 | - } |
|
| 306 | +return $xMetadata; |
|
| 307 | +} |
|
| 308 | 308 | |
| 309 | - /** |
|
| 309 | +/** |
|
| 310 | 310 | * @param ReflectionClass $xReflectionClass |
| 311 | 311 | * @param array $aOptions |
| 312 | 312 | * |
| 313 | 313 | * @return ComponentOptions |
| 314 | 314 | */ |
| 315 | - public function getComponentOptions(ReflectionClass $xReflectionClass, |
|
| 316 | - array $aOptions): ComponentOptions |
|
| 317 | - { |
|
| 318 | - $aMethods = $this->getPublicMethods($xReflectionClass); |
|
| 319 | - $xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions); |
|
| 315 | +public function getComponentOptions(ReflectionClass $xReflectionClass, |
|
| 316 | +array $aOptions): ComponentOptions |
|
| 317 | +{ |
|
| 318 | +$aMethods = $this->getPublicMethods($xReflectionClass); |
|
| 319 | +$xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions); |
|
| 320 | 320 | |
| 321 | - return new ComponentOptions($aMethods, $aOptions, $xMetadata); |
|
| 322 | - } |
|
| 321 | +return new ComponentOptions($aMethods, $aOptions, $xMetadata); |
|
| 322 | +} |
|
| 323 | 323 | } |
@@ -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 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | private function setComponentPublicMethods(string $sKey, string $sClass, |
| 207 | 207 | array $aNeverExported): void |
| 208 | 208 | { |
| 209 | - if(isset($this->aComponentPublicMethods[$sKey])) |
|
| 209 | + if (isset($this->aComponentPublicMethods[$sKey])) |
|
| 210 | 210 | { |
| 211 | 211 | return; |
| 212 | 212 | } |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | /** @var Config|null */ |
| 261 | 261 | $xPackageConfig = $aOptions['config'] ?? null; |
| 262 | - if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 262 | + if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false)) |
|
| 263 | 263 | { |
| 264 | 264 | return null; |
| 265 | 265 | } |
| 266 | 266 | $sMetadataFormat = $xPackageConfig->getOption('metadata.format'); |
| 267 | - if(!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 267 | + if (!in_array($sMetadataFormat, ['attributes', 'annotations'])) |
|
| 268 | 268 | { |
| 269 | 269 | return null; |
| 270 | 270 | } |
@@ -274,23 +274,23 @@ discard block |
||
| 274 | 274 | $xMetadata = null; |
| 275 | 275 | $xMetadataCache = null; |
| 276 | 276 | $xConfig = $di->config(); |
| 277 | - if($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 277 | + if ($xConfig->getAppOption('metadata.cache.enabled', false)) |
|
| 278 | 278 | { |
| 279 | - if(!$di->h('jaxon_metadata_cache_dir')) |
|
| 279 | + if (!$di->h('jaxon_metadata_cache_dir')) |
|
| 280 | 280 | { |
| 281 | 281 | $sCacheDir = $xConfig->getAppOption('metadata.cache.dir'); |
| 282 | 282 | $di->val('jaxon_metadata_cache_dir', $sCacheDir); |
| 283 | 283 | } |
| 284 | 284 | $xMetadataCache = $di->getMetadataCache(); |
| 285 | 285 | $xMetadata = $xMetadataCache->read($xReflectionClass->getName()); |
| 286 | - if($xMetadata !== null) |
|
| 286 | + if ($xMetadata !== null) |
|
| 287 | 287 | { |
| 288 | 288 | return $xMetadata; |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $aProperties = array_map(fn($xProperty) => $xProperty->getName(), |
| 293 | - $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC | |
|
| 293 | + $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC| |
|
| 294 | 294 | ReflectionProperty::IS_PROTECTED)); |
| 295 | 295 | |
| 296 | 296 | $xMetadataReader = $di->getMetadataReader($sMetadataFormat); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $xMetadata = $xMetadataReader->getAttributes($xInput); |
| 299 | 299 | |
| 300 | 300 | // Try to save the metadata in the cache |
| 301 | - if($xMetadataCache !== null) |
|
| 301 | + if ($xMetadataCache !== null) |
|
| 302 | 302 | { |
| 303 | 303 | $xMetadataCache->save($xReflectionClass->getName(), $xMetadata); |
| 304 | 304 | } |
@@ -13,25 +13,25 @@ |
||
| 13 | 13 | |
| 14 | 14 | class Page |
| 15 | 15 | { |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @var string |
| 18 | 18 | */ |
| 19 | - public $sType; |
|
| 19 | +public $sType; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - public $sText; |
|
| 24 | +public $sText; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @var int |
| 28 | 28 | */ |
| 29 | - public $nNumber; |
|
| 29 | +public $nNumber; |
|
| 30 | 30 | |
| 31 | - public function __construct(string $sType, string $sText, int $nNumber) |
|
| 32 | - { |
|
| 33 | - $this->sType = $sType; |
|
| 34 | - $this->sText = $sText; |
|
| 35 | - $this->nNumber = $nNumber; |
|
| 36 | - } |
|
| 31 | +public function __construct(string $sType, string $sText, int $nNumber) |
|
| 32 | +{ |
|
| 33 | +$this->sType = $sType; |
|
| 34 | +$this->sText = $sText; |
|
| 35 | +$this->nNumber = $nNumber; |
|
| 36 | +} |
|
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -9,35 +9,35 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class Store implements JsonSerializable, Stringable |
| 11 | 11 | { |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * The view renderer |
| 14 | 14 | * |
| 15 | 15 | * @var ViewInterface|null |
| 16 | 16 | */ |
| 17 | - protected $xRenderer = null; |
|
| 17 | +protected $xRenderer = null; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * The view namespace |
| 21 | 21 | * |
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - protected $sNamespace; |
|
| 24 | +protected $sNamespace; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * The view name |
| 28 | 28 | * |
| 29 | 29 | * @var string |
| 30 | 30 | */ |
| 31 | - protected $sViewName; |
|
| 31 | +protected $sViewName; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * The view data |
| 35 | 35 | * |
| 36 | 36 | * @var array |
| 37 | 37 | */ |
| 38 | - protected $aViewData = []; |
|
| 38 | +protected $aViewData = []; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * Make a piece of data available for the rendered view |
| 42 | 42 | * |
| 43 | 43 | * @param string $sName The data name |
@@ -45,26 +45,26 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return Store |
| 47 | 47 | */ |
| 48 | - public function with(string $sName, $xValue): Store |
|
| 49 | - { |
|
| 50 | - $this->aViewData[$sName] = $xValue; |
|
| 51 | - return $this; |
|
| 52 | - } |
|
| 48 | +public function with(string $sName, $xValue): Store |
|
| 49 | +{ |
|
| 50 | +$this->aViewData[$sName] = $xValue; |
|
| 51 | +return $this; |
|
| 52 | +} |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | +/** |
|
| 55 | 55 | * Set the data to be rendered |
| 56 | 56 | * |
| 57 | 57 | * @param array $aViewData The view data |
| 58 | 58 | * |
| 59 | 59 | * @return Store |
| 60 | 60 | */ |
| 61 | - public function setData(array $aViewData): Store |
|
| 62 | - { |
|
| 63 | - $this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 61 | +public function setData(array $aViewData): Store |
|
| 62 | +{ |
|
| 63 | +$this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 64 | +return $this; |
|
| 65 | +} |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * Set the view to be rendered, with optional data |
| 69 | 69 | * |
| 70 | 70 | * @param ViewInterface $xRenderer The view renderer |
@@ -74,65 +74,65 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return Store |
| 76 | 76 | */ |
| 77 | - public function setView(ViewInterface $xRenderer, |
|
| 78 | - string $sNamespace, string $sViewName, array $aViewData = []): Store |
|
| 79 | - { |
|
| 80 | - $this->xRenderer = $xRenderer; |
|
| 81 | - $this->sNamespace = trim($sNamespace); |
|
| 82 | - $this->sViewName = trim($sViewName); |
|
| 83 | - $this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 84 | - return $this; |
|
| 85 | - } |
|
| 77 | +public function setView(ViewInterface $xRenderer, |
|
| 78 | +string $sNamespace, string $sViewName, array $aViewData = []): Store |
|
| 79 | +{ |
|
| 80 | +$this->xRenderer = $xRenderer; |
|
| 81 | +$this->sNamespace = trim($sNamespace); |
|
| 82 | +$this->sViewName = trim($sViewName); |
|
| 83 | +$this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 84 | +return $this; |
|
| 85 | +} |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | +/** |
|
| 88 | 88 | * Get the view namespace |
| 89 | 89 | * |
| 90 | 90 | * @return string The view namespace |
| 91 | 91 | */ |
| 92 | - public function getNamespace(): string |
|
| 93 | - { |
|
| 94 | - return $this->sNamespace; |
|
| 95 | - } |
|
| 92 | +public function getNamespace(): string |
|
| 93 | +{ |
|
| 94 | +return $this->sNamespace; |
|
| 95 | +} |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | +/** |
|
| 98 | 98 | * Get the view name |
| 99 | 99 | * |
| 100 | 100 | * @return string The view name |
| 101 | 101 | */ |
| 102 | - public function getViewName(): string |
|
| 103 | - { |
|
| 104 | - return $this->sViewName; |
|
| 105 | - } |
|
| 102 | +public function getViewName(): string |
|
| 103 | +{ |
|
| 104 | +return $this->sViewName; |
|
| 105 | +} |
|
| 106 | 106 | |
| 107 | - /** |
|
| 107 | +/** |
|
| 108 | 108 | * Get the view data |
| 109 | 109 | * |
| 110 | 110 | * @return array The view data |
| 111 | 111 | */ |
| 112 | - public function getViewData(): array |
|
| 113 | - { |
|
| 114 | - return $this->aViewData; |
|
| 115 | - } |
|
| 112 | +public function getViewData(): array |
|
| 113 | +{ |
|
| 114 | +return $this->aViewData; |
|
| 115 | +} |
|
| 116 | 116 | |
| 117 | - /** |
|
| 117 | +/** |
|
| 118 | 118 | * Render a view using third party view system |
| 119 | 119 | * |
| 120 | 120 | * @return string The string representation of the view |
| 121 | 121 | */ |
| 122 | - public function __toString(): string |
|
| 123 | - { |
|
| 124 | - return !$this->xRenderer ? '' : $this->xRenderer->render($this); |
|
| 125 | - } |
|
| 122 | +public function __toString(): string |
|
| 123 | +{ |
|
| 124 | +return !$this->xRenderer ? '' : $this->xRenderer->render($this); |
|
| 125 | +} |
|
| 126 | 126 | |
| 127 | - /** |
|
| 127 | +/** |
|
| 128 | 128 | * Convert this object to string for json. |
| 129 | 129 | * |
| 130 | 130 | * This is a method of the JsonSerializable interface. |
| 131 | 131 | * |
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | - public function jsonSerialize(): string |
|
| 135 | - { |
|
| 136 | - return $this->__toString(); |
|
| 137 | - } |
|
| 134 | +public function jsonSerialize(): string |
|
| 135 | +{ |
|
| 136 | +return $this->__toString(); |
|
| 137 | +} |
|
| 138 | 138 | } |
@@ -18,32 +18,32 @@ |
||
| 18 | 18 | |
| 19 | 19 | abstract class AbstractData |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * Generate the PHP code to populate a Metadata object |
| 23 | 23 | * |
| 24 | 24 | * @param string $sVarName |
| 25 | 25 | * |
| 26 | 26 | * @return array |
| 27 | 27 | */ |
| 28 | - abstract public function encode(string $sVarName): array; |
|
| 28 | +abstract public function encode(string $sVarName): array; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - abstract public function getName(): string; |
|
| 33 | +abstract public function getName(): string; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * @return mixed |
| 37 | 37 | */ |
| 38 | - abstract public function getValue(): mixed; |
|
| 38 | +abstract public function getValue(): mixed; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @param string $sMethod |
| 42 | 42 | * |
| 43 | 43 | * @return bool |
| 44 | 44 | */ |
| 45 | - protected function validateMethod(string $sMethod): bool |
|
| 46 | - { |
|
| 47 | - return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sMethod) > 0; |
|
| 48 | - } |
|
| 45 | +protected function validateMethod(string $sMethod): bool |
|
| 46 | +{ |
|
| 47 | +return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sMethod) > 0; |
|
| 48 | +} |
|
| 49 | 49 | } |
@@ -19,46 +19,46 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | abstract class AbstractPackage extends AbstractCodeGenerator |
| 21 | 21 | { |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * The configuration options of the package |
| 24 | 24 | * |
| 25 | 25 | * @var Config |
| 26 | 26 | */ |
| 27 | - protected $xPkgConfig; |
|
| 27 | +protected $xPkgConfig; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * The view renderer |
| 31 | 31 | * |
| 32 | 32 | * @var ViewRenderer |
| 33 | 33 | */ |
| 34 | - protected $xRenderer; |
|
| 34 | +protected $xRenderer; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Get the path to the config file, or the config options in an array. |
| 38 | 38 | * |
| 39 | 39 | * @return string|array |
| 40 | 40 | */ |
| 41 | - abstract public static function config(): string|array; |
|
| 41 | +abstract public static function config(): string|array; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * Get the package config object |
| 45 | 45 | * |
| 46 | 46 | * @return Config |
| 47 | 47 | */ |
| 48 | - final public function getConfig(): Config |
|
| 49 | - { |
|
| 50 | - return $this->xPkgConfig; |
|
| 51 | - } |
|
| 48 | +final public function getConfig(): Config |
|
| 49 | +{ |
|
| 50 | +return $this->xPkgConfig; |
|
| 51 | +} |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | +/** |
|
| 54 | 54 | * This method is automatically called after the package instance is created and configured. |
| 55 | 55 | * |
| 56 | 56 | * @return void |
| 57 | 57 | */ |
| 58 | - protected function init(): void |
|
| 59 | - {} |
|
| 58 | +protected function init(): void |
|
| 59 | +{} |
|
| 60 | 60 | |
| 61 | - /** |
|
| 61 | +/** |
|
| 62 | 62 | * Get the value of a given package option |
| 63 | 63 | * |
| 64 | 64 | * @param string $sOption The option name |
@@ -66,59 +66,59 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | - final public function getOption(string $sOption, $xDefault = null): mixed |
|
| 70 | - { |
|
| 71 | - return $this->xPkgConfig->getOption($sOption, $xDefault); |
|
| 72 | - } |
|
| 69 | +final public function getOption(string $sOption, $xDefault = null): mixed |
|
| 70 | +{ |
|
| 71 | +return $this->xPkgConfig->getOption($sOption, $xDefault); |
|
| 72 | +} |
|
| 73 | 73 | |
| 74 | - /** |
|
| 74 | +/** |
|
| 75 | 75 | * Get the view renderer |
| 76 | 76 | * |
| 77 | 77 | * @return ViewRenderer |
| 78 | 78 | */ |
| 79 | - final public function view(): ViewRenderer |
|
| 80 | - { |
|
| 81 | - return $this->xRenderer; |
|
| 82 | - } |
|
| 79 | +final public function view(): ViewRenderer |
|
| 80 | +{ |
|
| 81 | +return $this->xRenderer; |
|
| 82 | +} |
|
| 83 | 83 | |
| 84 | - /** |
|
| 84 | +/** |
|
| 85 | 85 | * @inheritDoc |
| 86 | 86 | */ |
| 87 | - final public function getHash(): string |
|
| 88 | - { |
|
| 89 | - // Packages do not generate hash on their own. So we make this method final. |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 87 | +final public function getHash(): string |
|
| 88 | +{ |
|
| 89 | +// Packages do not generate hash on their own. So we make this method final. |
|
| 90 | +return ''; |
|
| 91 | +} |
|
| 92 | 92 | |
| 93 | - /** |
|
| 93 | +/** |
|
| 94 | 94 | * Get the HTML code of the package home page |
| 95 | 95 | * |
| 96 | 96 | * @return string|Stringable |
| 97 | 97 | */ |
| 98 | - public function getHtml(): string|Stringable |
|
| 99 | - { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 98 | +public function getHtml(): string|Stringable |
|
| 99 | +{ |
|
| 100 | +return ''; |
|
| 101 | +} |
|
| 102 | 102 | |
| 103 | - /** |
|
| 103 | +/** |
|
| 104 | 104 | * Get the HTML code of the package home page |
| 105 | 105 | * |
| 106 | 106 | * This method is an alias for getHtml(). |
| 107 | 107 | * |
| 108 | 108 | * @return string|Stringable |
| 109 | 109 | */ |
| 110 | - public function html(): string|Stringable |
|
| 111 | - { |
|
| 112 | - return $this->getHtml(); |
|
| 113 | - } |
|
| 110 | +public function html(): string|Stringable |
|
| 111 | +{ |
|
| 112 | +return $this->getHtml(); |
|
| 113 | +} |
|
| 114 | 114 | |
| 115 | - /** |
|
| 115 | +/** |
|
| 116 | 116 | * Get the Js code of the ready() callback |
| 117 | 117 | * |
| 118 | 118 | * @return string|Stringable |
| 119 | 119 | */ |
| 120 | - public function getReadyScript(): string|Stringable |
|
| 121 | - { |
|
| 122 | - return ''; |
|
| 123 | - } |
|
| 120 | +public function getReadyScript(): string|Stringable |
|
| 121 | +{ |
|
| 122 | +return ''; |
|
| 123 | +} |
|
| 124 | 124 | } |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | try |
| 122 | 122 | {
|
| 123 | 123 | $xFilesystem->createDirectory($sUploadDir); |
| 124 | - if(!$xFilesystem->directoryExists($sUploadDir)) |
|
| 124 | + if (!$xFilesystem->directoryExists($sUploadDir)) |
|
| 125 | 125 | {
|
| 126 | 126 | throw new RequestException($this->xTranslator->trans('errors.upload.access'));
|
| 127 | 127 | } |
| 128 | 128 | return $sUploadDir; |
| 129 | 129 | } |
| 130 | - catch(FilesystemException $e) |
|
| 130 | + catch (FilesystemException $e) |
|
| 131 | 131 | {
|
| 132 | 132 | $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
|
| 133 | 133 | throw new RequestException($this->xTranslator->trans('errors.upload.access'));
|
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | {
|
| 163 | 163 | // Check the uploaded file validity |
| 164 | 164 | $nErrorCode = $xHttpFile->getError(); |
| 165 | - if($nErrorCode !== UPLOAD_ERR_OK) |
|
| 165 | + if ($nErrorCode !== UPLOAD_ERR_OK) |
|
| 166 | 166 | {
|
| 167 | 167 | $this->xLogger->error('File upload error.', [
|
| 168 | 168 | 'code' => $nErrorCode, |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // Filename without the extension. Needs to be sanitized. |
| 178 | 178 | $sName = pathinfo($xHttpFile->getClientFilename(), PATHINFO_FILENAME); |
| 179 | - if($this->cNameSanitizer !== null) |
|
| 179 | + if ($this->cNameSanitizer !== null) |
|
| 180 | 180 | {
|
| 181 | 181 | $sName = (string)call_user_func($this->cNameSanitizer, |
| 182 | 182 | $sName, $sField, $this->sUploadFieldId); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // Set the user file data |
| 186 | 186 | $xFile = File::fromHttpFile($this->xFileStorage->filesystem($sField), $xHttpFile, $sUploadDir, $sName); |
| 187 | 187 | // Verify file validity (format, size) |
| 188 | - if(!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
| 188 | + if (!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
| 189 | 189 | {
|
| 190 | 190 | throw new RequestException($this->xValidator->getErrorMessage()); |
| 191 | 191 | } |
@@ -209,16 +209,16 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | $aUserFiles = []; |
| 211 | 211 | $aAllFiles = []; // A flat list of all uploaded files |
| 212 | - foreach($aTempFiles as $sField => $aFiles) |
|
| 212 | + foreach ($aTempFiles as $sField => $aFiles) |
|
| 213 | 213 | {
|
| 214 | 214 | $aUserFiles[$sField] = []; |
| 215 | 215 | // Get the path to the upload dir |
| 216 | 216 | $sUploadDir = $this->getUploadDir($sField); |
| 217 | - if(!is_array($aFiles)) |
|
| 217 | + if (!is_array($aFiles)) |
|
| 218 | 218 | {
|
| 219 | 219 | $aFiles = [$aFiles]; |
| 220 | 220 | } |
| 221 | - foreach($aFiles as $xHttpFile) |
|
| 221 | + foreach ($aFiles as $xHttpFile) |
|
| 222 | 222 | {
|
| 223 | 223 | $aFile = $this->makeUploadedFile($xHttpFile, $sUploadDir, $sField); |
| 224 | 224 | $aUserFiles[$sField][] = $aFile['user']; |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | // Copy the uploaded files from the temp dir to the user dir |
| 230 | 230 | try |
| 231 | 231 | {
|
| 232 | - foreach($aAllFiles as $aFiles) |
|
| 232 | + foreach ($aAllFiles as $aFiles) |
|
| 233 | 233 | {
|
| 234 | 234 | $sPath = $aFiles['user']->path(); |
| 235 | 235 | $xContent = $aFiles['temp']->getStream(); |
| 236 | 236 | $aFiles['user']->filesystem()->write($sPath, $xContent); |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | - catch(FilesystemException $e) |
|
| 239 | + catch (FilesystemException $e) |
|
| 240 | 240 | {
|
| 241 | 241 | $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
|
| 242 | 242 | throw new RequestException($this->xTranslator->trans('errors.upload.access'));
|
@@ -126,8 +126,7 @@ discard block |
||
| 126 | 126 | throw new RequestException($this->xTranslator->trans('errors.upload.access'));
|
| 127 | 127 | } |
| 128 | 128 | return $sUploadDir; |
| 129 | - } |
|
| 130 | - catch(FilesystemException $e) |
|
| 129 | + } catch(FilesystemException $e) |
|
| 131 | 130 | {
|
| 132 | 131 | $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
|
| 133 | 132 | throw new RequestException($this->xTranslator->trans('errors.upload.access'));
|
@@ -235,8 +234,7 @@ discard block |
||
| 235 | 234 | $xContent = $aFiles['temp']->getStream(); |
| 236 | 235 | $aFiles['user']->filesystem()->write($sPath, $xContent); |
| 237 | 236 | } |
| 238 | - } |
|
| 239 | - catch(FilesystemException $e) |
|
| 237 | + } catch(FilesystemException $e) |
|
| 240 | 238 | {
|
| 241 | 239 | $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
|
| 242 | 240 | throw new RequestException($this->xTranslator->trans('errors.upload.access'));
|
@@ -20,99 +20,99 @@ |
||
| 20 | 20 | |
| 21 | 21 | trait RequestTrait |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Register the values into the container |
| 25 | 25 | * |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - private function registerRequests(): void |
|
| 29 | - { |
|
| 30 | - // The parameter reader |
|
| 31 | - $this->set(ParameterReader::class, function($di) { |
|
| 32 | - return new ParameterReader($di->g(Container::class), $di->g(Translator::class), |
|
| 33 | - $di->g(ConfigManager::class), $di->g(UriDetector::class)); |
|
| 34 | - }); |
|
| 35 | - // Callback Manager |
|
| 36 | - $this->set(CallbackManager::class, function($di) { |
|
| 37 | - return new CallbackManager($di->g(ResponseManager::class)); |
|
| 38 | - }); |
|
| 39 | - // By default, register a null upload handler |
|
| 40 | - $this->set(UploadHandlerInterface::class, function() { |
|
| 41 | - return null; |
|
| 42 | - }); |
|
| 43 | - // Request Handler |
|
| 44 | - $this->set(RequestHandler::class, function($di) { |
|
| 45 | - return new RequestHandler($di->g(Container::class), $di->g(PluginManager::class), |
|
| 46 | - $di->g(ResponseManager::class), $di->g(CallbackManager::class), |
|
| 47 | - $di->g(DatabagPlugin::class)); |
|
| 48 | - }); |
|
| 49 | - // Requests and calls Factory |
|
| 50 | - $this->set(CallFactory::class, function($di) { |
|
| 51 | - return new CallFactory($di->g(ComponentContainer::class), $di->g(DialogCommand::class)); |
|
| 52 | - }); |
|
| 53 | - // Factory for function parameters |
|
| 54 | - $this->set(ParameterFactory::class, function() { |
|
| 55 | - return new ParameterFactory(); |
|
| 56 | - }); |
|
| 57 | - } |
|
| 28 | +private function registerRequests(): void |
|
| 29 | +{ |
|
| 30 | +// The parameter reader |
|
| 31 | +$this->set(ParameterReader::class, function($di) { |
|
| 32 | +return new ParameterReader($di->g(Container::class), $di->g(Translator::class), |
|
| 33 | + $di->g(ConfigManager::class), $di->g(UriDetector::class)); |
|
| 34 | +}); |
|
| 35 | +// Callback Manager |
|
| 36 | +$this->set(CallbackManager::class, function($di) { |
|
| 37 | +return new CallbackManager($di->g(ResponseManager::class)); |
|
| 38 | +}); |
|
| 39 | +// By default, register a null upload handler |
|
| 40 | +$this->set(UploadHandlerInterface::class, function() { |
|
| 41 | +return null; |
|
| 42 | +}); |
|
| 43 | +// Request Handler |
|
| 44 | +$this->set(RequestHandler::class, function($di) { |
|
| 45 | +return new RequestHandler($di->g(Container::class), $di->g(PluginManager::class), |
|
| 46 | + $di->g(ResponseManager::class), $di->g(CallbackManager::class), |
|
| 47 | + $di->g(DatabagPlugin::class)); |
|
| 48 | +}); |
|
| 49 | +// Requests and calls Factory |
|
| 50 | +$this->set(CallFactory::class, function($di) { |
|
| 51 | +return new CallFactory($di->g(ComponentContainer::class), $di->g(DialogCommand::class)); |
|
| 52 | +}); |
|
| 53 | +// Factory for function parameters |
|
| 54 | +$this->set(ParameterFactory::class, function() { |
|
| 55 | +return new ParameterFactory(); |
|
| 56 | +}); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * Get the callback manager |
| 61 | 61 | * |
| 62 | 62 | * @return CallbackManager |
| 63 | 63 | */ |
| 64 | - public function callback(): CallbackManager |
|
| 65 | - { |
|
| 66 | - return $this->g(CallbackManager::class); |
|
| 67 | - } |
|
| 64 | +public function callback(): CallbackManager |
|
| 65 | +{ |
|
| 66 | +return $this->g(CallbackManager::class); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Get the js call factory |
| 71 | 71 | * |
| 72 | 72 | * @return CallFactory |
| 73 | 73 | */ |
| 74 | - public function getCallFactory(): CallFactory |
|
| 75 | - { |
|
| 76 | - return $this->g(CallFactory::class); |
|
| 77 | - } |
|
| 74 | +public function getCallFactory(): CallFactory |
|
| 75 | +{ |
|
| 76 | +return $this->g(CallFactory::class); |
|
| 77 | +} |
|
| 78 | 78 | |
| 79 | - /** |
|
| 79 | +/** |
|
| 80 | 80 | * Get the js call parameter factory |
| 81 | 81 | * |
| 82 | 82 | * @return ParameterFactory |
| 83 | 83 | */ |
| 84 | - public function getParameterFactory(): ParameterFactory |
|
| 85 | - { |
|
| 86 | - return $this->g(ParameterFactory::class); |
|
| 87 | - } |
|
| 84 | +public function getParameterFactory(): ParameterFactory |
|
| 85 | +{ |
|
| 86 | +return $this->g(ParameterFactory::class); |
|
| 87 | +} |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | +/** |
|
| 90 | 90 | * Get the request handler |
| 91 | 91 | * |
| 92 | 92 | * @return RequestHandler |
| 93 | 93 | */ |
| 94 | - public function getRequestHandler(): RequestHandler |
|
| 95 | - { |
|
| 96 | - return $this->g(RequestHandler::class); |
|
| 97 | - } |
|
| 94 | +public function getRequestHandler(): RequestHandler |
|
| 95 | +{ |
|
| 96 | +return $this->g(RequestHandler::class); |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * Get the upload handler |
| 101 | 101 | * |
| 102 | 102 | * @return UploadHandlerInterface|null |
| 103 | 103 | */ |
| 104 | - public function getUploadHandler(): ?UploadHandlerInterface |
|
| 105 | - { |
|
| 106 | - return $this->g(UploadHandlerInterface::class); |
|
| 107 | - } |
|
| 104 | +public function getUploadHandler(): ?UploadHandlerInterface |
|
| 105 | +{ |
|
| 106 | +return $this->g(UploadHandlerInterface::class); |
|
| 107 | +} |
|
| 108 | 108 | |
| 109 | - /** |
|
| 109 | +/** |
|
| 110 | 110 | * Get the parameter reader |
| 111 | 111 | * |
| 112 | 112 | * @return ParameterReader |
| 113 | 113 | */ |
| 114 | - public function getParameterReader(): ParameterReader |
|
| 115 | - { |
|
| 116 | - return $this->g(ParameterReader::class); |
|
| 117 | - } |
|
| 114 | +public function getParameterReader(): ParameterReader |
|
| 115 | +{ |
|
| 116 | +return $this->g(ParameterReader::class); |
|
| 117 | +} |
|
| 118 | 118 | } |