@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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; |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | public function new(string $sBag, string $sKey, $xValue): void |
| 91 | 91 | { |
| 92 | 92 | // Set the value only if it doesn't already exist. |
| 93 | - if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 93 | + if (!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 94 | 94 | { |
| 95 | 95 | $this->set($sBag, $sKey, $xValue); |
| 96 | 96 | } |
@@ -37,8 +37,7 @@ |
||
| 37 | 37 | private function getPageNumber(int $pageNumber): int |
| 38 | 38 | { |
| 39 | 39 | // If no page number is provided, then get the value from the databag. |
| 40 | - return $pageNumber > 0 ? $pageNumber : |
|
| 41 | - (int)$this->bag($this->bagName())->get($this->bagAttr(), 1); |
|
| 40 | + return $pageNumber > 0 ? $pageNumber : (int)$this->bag($this->bagName())->get($this->bagAttr(), 1); |
|
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | /** |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | // and the other classes will get this request from there. |
| 65 | 65 | $this->di->val(ServerRequestInterface::class, $request); |
| 66 | 66 | |
| 67 | - if(!$this->xRequestHandler->canProcessRequest()) |
|
| 67 | + if (!$this->xRequestHandler->canProcessRequest()) |
|
| 68 | 68 | { |
| 69 | 69 | // Unable to find a plugin to process the request |
| 70 | 70 | return $handler->handle($request); |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | // and the other classes will get this request from there. |
| 73 | 73 | $this->di->val(ServerRequestInterface::class, $request); |
| 74 | 74 | |
| 75 | - if(!$this->xRequestHandler->canProcessRequest()) |
|
| 75 | + if (!$this->xRequestHandler->canProcessRequest()) |
|
| 76 | 76 | { |
| 77 | 77 | // Unable to find a plugin to process the request |
| 78 | 78 | throw new RequestException($this->xTranslator->trans('errors.request.plugin')); |