@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | protected function validateObjectName(string $sName): void |
| 52 | 52 | { |
| 53 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0) |
|
| 53 | + if (preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0) |
|
| 54 | 54 | { |
| 55 | 55 | return; |
| 56 | 56 | } |
@@ -113,8 +113,7 @@ discard block |
||
| 113 | 113 | private function alert(string $sType, string $sMessage, array $aArgs): array |
| 114 | 114 | { |
| 115 | 115 | return [ |
| 116 | - 'lib' => $this->getLibrary() ?: |
|
| 117 | - ($this->xRegistry?->getAlertLibrary()->getName() ?? ''), |
|
| 116 | + 'lib' => $this->getLibrary() ?: ($this->xRegistry?->getAlertLibrary()->getName() ?? ''), |
|
| 118 | 117 | 'message' => [ |
| 119 | 118 | 'type' => $sType, |
| 120 | 119 | 'title' => $this->getTitle(), |
@@ -197,8 +196,7 @@ discard block |
||
| 197 | 196 | public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []): array |
| 198 | 197 | { |
| 199 | 198 | return [ |
| 200 | - 'lib' => $this->getLibrary() ?: |
|
| 201 | - ($this->xRegistry?->getModalLibrary()->getName() ?? ''), |
|
| 199 | + 'lib' => $this->getLibrary() ?: ($this->xRegistry?->getModalLibrary()->getName() ?? ''), |
|
| 202 | 200 | 'dialog' => [ |
| 203 | 201 | 'title' => $sTitle, |
| 204 | 202 | 'content' => $sContent, |
@@ -216,8 +214,7 @@ discard block |
||
| 216 | 214 | public function hide(): array |
| 217 | 215 | { |
| 218 | 216 | return [ |
| 219 | - 'lib' => $this->getLibrary() ?: |
|
| 220 | - ($this->xRegistry?->getModalLibrary()->getName() ?? ''), |
|
| 217 | + 'lib' => $this->getLibrary() ?: ($this->xRegistry?->getModalLibrary()->getName() ?? ''), |
|
| 221 | 218 | ]; |
| 222 | 219 | } |
| 223 | 220 | |
@@ -232,8 +229,7 @@ discard block |
||
| 232 | 229 | public function confirm(string $sQuestion, array $aArgs = []): array |
| 233 | 230 | { |
| 234 | 231 | return [ |
| 235 | - 'lib' => $this->getLibrary() ?: |
|
| 236 | - ($this->xRegistry?->getConfirmLibrary()->getName() ?? ''), |
|
| 232 | + 'lib' => $this->getLibrary() ?: ($this->xRegistry?->getConfirmLibrary()->getName() ?? ''), |
|
| 237 | 233 | 'question' => [ |
| 238 | 234 | 'title' => $this->getTitle(), |
| 239 | 235 | 'phrase' => $this->phrase($sQuestion, $aArgs), |
@@ -128,9 +128,8 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | private function updatePagesCount(): Paginator |
| 130 | 130 | { |
| 131 | - $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : |
|
| 132 | - (int)ceil($this->nItemsCount / $this->nItemsPerPage)); |
|
| 133 | - if($this->nPageNumber > $this->nPagesCount) |
|
| 131 | + $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : (int)ceil($this->nItemsCount / $this->nItemsPerPage)); |
|
| 132 | + if ($this->nPageNumber > $this->nPagesCount) |
|
| 134 | 133 | { |
| 135 | 134 | $this->nPageNumber = $this->nPagesCount; |
| 136 | 135 | } |
@@ -184,8 +183,7 @@ discard block |
||
| 184 | 183 | protected function getPrevPage(): Page |
| 185 | 184 | { |
| 186 | 185 | return $this->nPageNumber <= 1 ? |
| 187 | - new Page('disabled', $this->sPreviousText, 0) : |
|
| 188 | - new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1); |
|
| 186 | + new Page('disabled', $this->sPreviousText, 0) : new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1); |
|
| 189 | 187 | } |
| 190 | 188 | |
| 191 | 189 | /** |
@@ -196,8 +194,7 @@ discard block |
||
| 196 | 194 | protected function getNextPage(): Page |
| 197 | 195 | { |
| 198 | 196 | return $this->nPageNumber >= $this->nPagesCount ? |
| 199 | - new Page('disabled', $this->sNextText, 0) : |
|
| 200 | - new Page('enabled', $this->sNextText, $this->nPageNumber + 1); |
|
| 197 | + new Page('disabled', $this->sNextText, 0) : new Page('enabled', $this->sNextText, $this->nPageNumber + 1); |
|
| 201 | 198 | } |
| 202 | 199 | |
| 203 | 200 | /** |
@@ -209,7 +206,7 @@ discard block |
||
| 209 | 206 | */ |
| 210 | 207 | protected function getPage(int $nNumber): Page |
| 211 | 208 | { |
| 212 | - if($nNumber < 1) |
|
| 209 | + if ($nNumber < 1) |
|
| 213 | 210 | { |
| 214 | 211 | return new Page('disabled', $this->sEllipsysText, 0); |
| 215 | 212 | } |
@@ -228,9 +225,9 @@ discard block |
||
| 228 | 225 | { |
| 229 | 226 | $aPageNumbers = []; |
| 230 | 227 | |
| 231 | - if($this->nPagesCount <= $this->nMaxPages) |
|
| 228 | + if ($this->nPagesCount <= $this->nMaxPages) |
|
| 232 | 229 | { |
| 233 | - for($i = 0; $i < $this->nPagesCount; $i++) |
|
| 230 | + for ($i = 0; $i < $this->nPagesCount; $i++) |
|
| 234 | 231 | { |
| 235 | 232 | $aPageNumbers[] = $i + 1; |
| 236 | 233 | } |
@@ -243,7 +240,7 @@ discard block |
||
| 243 | 240 | |
| 244 | 241 | $nSlidingStart = 1; |
| 245 | 242 | $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber; |
| 246 | - if($nSlidingEndOffset < 0) |
|
| 243 | + if ($nSlidingEndOffset < 0) |
|
| 247 | 244 | { |
| 248 | 245 | $nSlidingStart = $this->nPageNumber - $nNumAdjacents; |
| 249 | 246 | $nSlidingEndOffset = 0; |
@@ -251,23 +248,23 @@ discard block |
||
| 251 | 248 | |
| 252 | 249 | $nSlidingEnd = $this->nPagesCount; |
| 253 | 250 | $nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount; |
| 254 | - if($nSlidingStartOffset < 0) |
|
| 251 | + if ($nSlidingStartOffset < 0) |
|
| 255 | 252 | { |
| 256 | 253 | $nSlidingEnd = $this->nPageNumber + $nNumAdjacents; |
| 257 | 254 | $nSlidingStartOffset = 0; |
| 258 | 255 | } |
| 259 | 256 | |
| 260 | 257 | // Build the list of page numbers. |
| 261 | - if($nSlidingStart > 1) |
|
| 258 | + if ($nSlidingStart > 1) |
|
| 262 | 259 | { |
| 263 | 260 | $aPageNumbers[] = 1; |
| 264 | 261 | $aPageNumbers[] = 0; // Ellipsys; |
| 265 | 262 | } |
| 266 | - for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
| 263 | + for ($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
| 267 | 264 | { |
| 268 | 265 | $aPageNumbers[] = $i; |
| 269 | 266 | } |
| 270 | - if($nSlidingEnd < $this->nPagesCount) |
|
| 267 | + if ($nSlidingEnd < $this->nPagesCount) |
|
| 271 | 268 | { |
| 272 | 269 | $aPageNumbers[] = 0; // Ellipsys; |
| 273 | 270 | $aPageNumbers[] = $this->nPagesCount; |
@@ -293,7 +290,7 @@ discard block |
||
| 293 | 290 | */ |
| 294 | 291 | public function pages(): array |
| 295 | 292 | { |
| 296 | - if($this->nPagesCount < 2) |
|
| 293 | + if ($this->nPagesCount < 2) |
|
| 297 | 294 | { |
| 298 | 295 | return []; |
| 299 | 296 | } |
@@ -344,7 +341,7 @@ discard block |
||
| 344 | 341 | private function renderLinks(): string |
| 345 | 342 | { |
| 346 | 343 | $aPages = $this->pages(); |
| 347 | - if(count($aPages) === 0) |
|
| 344 | + if (count($aPages) === 0) |
|
| 348 | 345 | { |
| 349 | 346 | return ''; |
| 350 | 347 | } |
@@ -365,7 +362,7 @@ discard block |
||
| 365 | 362 | { |
| 366 | 363 | $sHtml = $this->renderLinks(); |
| 367 | 364 | // The HTML code must always be displayed, even if it is empty. |
| 368 | - if(is_a($this->xPlugin->response(), Response::class)) |
|
| 365 | + if (is_a($this->xPlugin->response(), Response::class)) |
|
| 369 | 366 | { |
| 370 | 367 | /** @var Response */ |
| 371 | 368 | $xResponse = $this->xPlugin->response(); |
@@ -388,13 +385,13 @@ discard block |
||
| 388 | 385 | */ |
| 389 | 386 | public function render(JsExpr $xCall, string $sWrapperId = ''): void |
| 390 | 387 | { |
| 391 | - if(($xFunc = $xCall->func()) === null) |
|
| 388 | + if (($xFunc = $xCall->func()) === null) |
|
| 392 | 389 | { |
| 393 | 390 | return; |
| 394 | 391 | } |
| 395 | 392 | |
| 396 | 393 | $aParams = $this->showLinks(trim($sWrapperId)); |
| 397 | - if($aParams !== null) |
|
| 394 | + if ($aParams !== null) |
|
| 398 | 395 | { |
| 399 | 396 | // Set click handlers on the pagination links |
| 400 | 397 | $aParams['func'] = $xFunc->withPage()->jsonSerialize(); |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | { |
| 54 | 54 | $this->sDirectory = ''; |
| 55 | 55 | $this->sExtension = ''; |
| 56 | - if(isset($this->aDirectories[$sNamespace])) |
|
| 56 | + if (isset($this->aDirectories[$sNamespace])) |
|
| 57 | 57 | { |
| 58 | 58 | // Make sure there's only one '/' at the end of the string |
| 59 | 59 | $this->sDirectory = rtrim($this->aDirectories[$sNamespace]['path'], '/') . '/'; |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | $sViewName = $store->getViewName(); |
| 60 | 60 | $sNamespace = $store->getNamespace(); |
| 61 | 61 | // In this view renderer, the namespace must always be prepended to the view name. |
| 62 | - if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 62 | + if (substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 63 | 63 | { |
| 64 | 64 | $sViewName = $sNamespace . '::' . $sViewName; |
| 65 | 65 | } |
@@ -18,22 +18,22 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | class TemplateView implements ViewInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * The Jaxon template engine |
| 23 | 23 | * |
| 24 | 24 | * @var TemplateEngine |
| 25 | 25 | */ |
| 26 | - protected $xTemplateEngine; |
|
| 26 | +protected $xTemplateEngine; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * The class constructor |
| 30 | 30 | */ |
| 31 | - public function __construct(TemplateEngine $xTemplateEngine) |
|
| 32 | - { |
|
| 33 | - $this->xTemplateEngine = $xTemplateEngine; |
|
| 34 | - } |
|
| 31 | +public function __construct(TemplateEngine $xTemplateEngine) |
|
| 32 | +{ |
|
| 33 | +$this->xTemplateEngine = $xTemplateEngine; |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Add a namespace to this view renderer |
| 38 | 38 | * |
| 39 | 39 | * @param string $sNamespace The namespace name |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void |
|
| 46 | - { |
|
| 47 | - $this->xTemplateEngine->addNamespace($sNamespace, $sDirectory, $sExtension); |
|
| 48 | - } |
|
| 45 | +public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void |
|
| 46 | +{ |
|
| 47 | +$this->xTemplateEngine->addNamespace($sNamespace, $sDirectory, $sExtension); |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * Render a view |
| 52 | 52 | * |
| 53 | 53 | * @param Store $store A store populated with the view data |
| 54 | 54 | * |
| 55 | 55 | * @return string The string representation of the view |
| 56 | 56 | */ |
| 57 | - public function render(Store $store): string |
|
| 58 | - { |
|
| 59 | - $sViewName = $store->getViewName(); |
|
| 60 | - $sNamespace = $store->getNamespace(); |
|
| 61 | - // In this view renderer, the namespace must always be prepended to the view name. |
|
| 62 | - if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 63 | - { |
|
| 64 | - $sViewName = $sNamespace . '::' . $sViewName; |
|
| 65 | - } |
|
| 66 | - // Render the template |
|
| 67 | - return trim($this->xTemplateEngine->render($sViewName, $store->getViewData()), " \t\n"); |
|
| 68 | - } |
|
| 57 | +public function render(Store $store): string |
|
| 58 | +{ |
|
| 59 | +$sViewName = $store->getViewName(); |
|
| 60 | +$sNamespace = $store->getNamespace(); |
|
| 61 | +// In this view renderer, the namespace must always be prepended to the view name. |
|
| 62 | +if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
| 63 | +{ |
|
| 64 | +$sViewName = $sNamespace . '::' . $sViewName; |
|
| 65 | +} |
|
| 66 | +// Render the template |
|
| 67 | +return trim($this->xTemplateEngine->render($sViewName, $store->getViewData()), " \t\n"); |
|
| 68 | +} |
|
| 69 | 69 | } |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | public function on(string $event, JsExpr $xJsExpr): self |
| 61 | 61 | { |
| 62 | - if($this->sSelector === '') |
|
| 62 | + if ($this->sSelector === '') |
|
| 63 | 63 | { |
| 64 | 64 | return $this; |
| 65 | 65 | } |
@@ -203,12 +203,12 @@ |
||
| 203 | 203 | $sCode = match($sType) { |
| 204 | 204 | 'html' => jaxon()->package($sClass)?->getHtml() ?? '', |
| 205 | 205 | 'ready' => jaxon()->package($sClass)?->getReadyScript() ?? '', |
| 206 | - default => '' |
|
| 207 | - }; |
|
| 208 | - $sCode = trim($sCode); |
|
| 206 | +default => '' |
|
| 207 | +}; |
|
| 208 | +$sCode = trim($sCode); |
|
| 209 | 209 | |
| 210 | - return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | - // Call the ready code with the jaxon.dom.ready function. |
|
| 212 | - "jaxon.dom.ready(() => $sCode)"; |
|
| 213 | - } |
|
| 210 | +return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | +// Call the ready code with the jaxon.dom.ready function. |
|
| 212 | +"jaxon.dom.ready(() => $sCode)"; |
|
| 213 | +} |
|
| 214 | 214 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function html(JxnCall $xJsCall): string |
| 55 | 55 | { |
| 56 | 56 | $sClassName = $xJsCall->_class(); |
| 57 | - if(!$sClassName) |
|
| 57 | + if (!$sClassName) |
|
| 58 | 58 | { |
| 59 | 59 | return ''; |
| 60 | 60 | } |
@@ -88,8 +88,7 @@ discard block |
||
| 88 | 88 | public function pagination(JxnCall $xJsCall): string |
| 89 | 89 | { |
| 90 | 90 | // The pagination is always rendered with the same Pagination component. |
| 91 | - $sComponent = $this->sPaginationComponent ?: |
|
| 92 | - ($this->sPaginationComponent = rq(Pagination::class)->_class()); |
|
| 91 | + $sComponent = $this->sPaginationComponent ?: ($this->sPaginationComponent = rq(Pagination::class)->_class()); |
|
| 93 | 92 | $sItem = $xJsCall->_class(); |
| 94 | 93 | return "jxn-bind=\"$sComponent\" jxn-item=\"$sItem\""; |
| 95 | 94 | } |
@@ -154,15 +153,14 @@ discard block |
||
| 154 | 153 | */ |
| 155 | 154 | private function setEventHandler(array $aHandler, ?EventAttr $xAttr = null): EventAttr|null |
| 156 | 155 | { |
| 157 | - if(!$this->eventIsValid($aHandler)) |
|
| 156 | + if (!$this->eventIsValid($aHandler)) |
|
| 158 | 157 | { |
| 159 | 158 | return $xAttr; |
| 160 | 159 | } |
| 161 | 160 | // The array content is valid. |
| 162 | 161 | [$sSelector, $sEvent, $xJsExpr] = $aHandler; |
| 163 | 162 | return !$xAttr ? |
| 164 | - $this->select($sSelector)->on($sEvent, $xJsExpr) : |
|
| 165 | - $xAttr->select($sSelector)->on($sEvent, $xJsExpr); |
|
| 163 | + $this->select($sSelector)->on($sEvent, $xJsExpr) : $xAttr->select($sSelector)->on($sEvent, $xJsExpr); |
|
| 166 | 164 | } |
| 167 | 165 | |
| 168 | 166 | /** |
@@ -207,8 +205,7 @@ discard block |
||
| 207 | 205 | }; |
| 208 | 206 | $sCode = trim($sCode); |
| 209 | 207 | |
| 210 | - return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | - // Call the ready code with the jaxon.dom.ready function. |
|
| 208 | + return $sType !== 'ready' || $sCode === '' ? $sCode : // Call the ready code with the jaxon.dom.ready function. |
|
| 212 | 209 | "jaxon.dom.ready(() => $sCode)"; |
| 213 | 210 | } |
| 214 | 211 | } |
@@ -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 |
| 16 | 16 | */ |
| 17 | - protected $xRenderer; |
|
| 17 | +protected $xRenderer; |
|
| 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 | } |
@@ -97,18 +97,18 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function addNamespaces(Config $xAppConfig): void |
| 99 | 99 | { |
| 100 | - if(empty($aNamespaces = $xAppConfig->getOptionNames('views'))) |
|
| 100 | + if (empty($aNamespaces = $xAppConfig->getOptionNames('views'))) |
|
| 101 | 101 | { |
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $sPackage = $xAppConfig->getOption('package', ''); |
| 106 | - foreach($aNamespaces as $sNamespace => $sOption) |
|
| 106 | + foreach ($aNamespaces as $sNamespace => $sOption) |
|
| 107 | 107 | { |
| 108 | 108 | // Save the namespace |
| 109 | 109 | $aNamespace = $xAppConfig->getOption($sOption); |
| 110 | 110 | $aNamespace['package'] = $sPackage; |
| 111 | - if(!isset($aNamespace['renderer'])) |
|
| 111 | + if (!isset($aNamespace['renderer'])) |
|
| 112 | 112 | { |
| 113 | 113 | $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer. |
| 114 | 114 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) { |
| 148 | 148 | return $aOptions['renderer'] === $sId; |
| 149 | 149 | }); |
| 150 | - foreach($aNamespaces as $sName => $aOptions) |
|
| 150 | + foreach ($aNamespaces as $sName => $aOptions) |
|
| 151 | 151 | { |
| 152 | 152 | $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']); |
| 153 | 153 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function getNamespaceRenderer(string $sNamespace): ?ViewInterface |
| 182 | 182 | { |
| 183 | - if(!isset($this->aNamespaces[$sNamespace])) |
|
| 183 | + if (!isset($this->aNamespaces[$sNamespace])) |
|
| 184 | 184 | { |
| 185 | 185 | return null; |
| 186 | 186 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | protected function store(): Store |
| 207 | 207 | { |
| 208 | - if(!$this->xStore) |
|
| 208 | + if (!$this->xStore) |
|
| 209 | 209 | { |
| 210 | 210 | $this->xStore = new Store(); |
| 211 | 211 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function shareValues(array $aValues): ViewRenderer |
| 251 | 251 | { |
| 252 | - foreach($aValues as $sName => $xValue) |
|
| 252 | + foreach ($aValues as $sName => $xValue) |
|
| 253 | 253 | { |
| 254 | 254 | $this->share($sName, $xValue); |
| 255 | 255 | } |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | $sNamespace = $this->sDefaultNamespace; |
| 274 | 274 | // Get the namespace from the view name |
| 275 | 275 | $nSeparatorPosition = strrpos($sViewName, '::'); |
| 276 | - if($nSeparatorPosition !== false) |
|
| 276 | + if ($nSeparatorPosition !== false) |
|
| 277 | 277 | { |
| 278 | 278 | $sNamespace = substr($sViewName, 0, $nSeparatorPosition); |
| 279 | 279 | $sViewName = substr($sViewName, $nSeparatorPosition + 2); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | $xRenderer = $this->getNamespaceRenderer($sNamespace); |
| 283 | - if(!$xRenderer) |
|
| 283 | + if (!$xRenderer) |
|
| 284 | 284 | { |
| 285 | 285 | // Cannot render a view if there's no renderer corresponding to the namespace. |
| 286 | 286 | return $this->xEmptyStore; |