@@ -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 | } |
@@ -59,52 +59,52 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | class Paginator |
| 61 | 61 | { |
| 62 | - /** |
|
| 62 | +/** |
|
| 63 | 63 | * @var integer |
| 64 | 64 | */ |
| 65 | - protected $nItemsCount = 0; |
|
| 65 | +protected $nItemsCount = 0; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * @var integer |
| 69 | 69 | */ |
| 70 | - protected $nPagesCount = 0; |
|
| 70 | +protected $nPagesCount = 0; |
|
| 71 | 71 | |
| 72 | - /** |
|
| 72 | +/** |
|
| 73 | 73 | * @var integer |
| 74 | 74 | */ |
| 75 | - protected $nItemsPerPage = 0; |
|
| 75 | +protected $nItemsPerPage = 0; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 77 | +/** |
|
| 78 | 78 | * @var integer |
| 79 | 79 | */ |
| 80 | - protected $nPageNumber = 0; |
|
| 80 | +protected $nPageNumber = 0; |
|
| 81 | 81 | |
| 82 | - /** |
|
| 82 | +/** |
|
| 83 | 83 | * @var integer |
| 84 | 84 | */ |
| 85 | - protected $nMaxPages = 10; |
|
| 85 | +protected $nMaxPages = 10; |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | +/** |
|
| 88 | 88 | * @var string |
| 89 | 89 | */ |
| 90 | - protected $sPreviousText = '«'; |
|
| 90 | +protected $sPreviousText = '«'; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 92 | +/** |
|
| 93 | 93 | * @var string |
| 94 | 94 | */ |
| 95 | - protected $sNextText = '»'; |
|
| 95 | +protected $sNextText = '»'; |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | +/** |
|
| 98 | 98 | * @var string |
| 99 | 99 | */ |
| 100 | - protected $sEllipsysText = '...'; |
|
| 100 | +protected $sEllipsysText = '...'; |
|
| 101 | 101 | |
| 102 | - /** |
|
| 102 | +/** |
|
| 103 | 103 | * @var PaginatorPlugin |
| 104 | 104 | */ |
| 105 | - private $xPlugin; |
|
| 105 | +private $xPlugin; |
|
| 106 | 106 | |
| 107 | - /** |
|
| 107 | +/** |
|
| 108 | 108 | * The constructor. |
| 109 | 109 | * |
| 110 | 110 | * @param PaginatorPlugin $xPlugin |
@@ -112,293 +112,293 @@ discard block |
||
| 112 | 112 | * @param int $nItemsPerPage The number of items per page |
| 113 | 113 | * @param int $nItemsCount The total number of items |
| 114 | 114 | */ |
| 115 | - public function __construct(PaginatorPlugin $xPlugin, int $nPageNumber, int $nItemsPerPage, int $nItemsCount) |
|
| 116 | - { |
|
| 117 | - $this->xPlugin = $xPlugin; |
|
| 118 | - $this->nItemsPerPage = $nItemsPerPage > 0 ? $nItemsPerPage : 0; |
|
| 119 | - $this->nItemsCount = $nItemsCount > 0 ? $nItemsCount : 0; |
|
| 120 | - $this->nPageNumber = $nPageNumber < 1 ? 1 : $nPageNumber; |
|
| 121 | - $this->updatePagesCount(); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 115 | +public function __construct(PaginatorPlugin $xPlugin, int $nPageNumber, int $nItemsPerPage, int $nItemsCount) |
|
| 116 | +{ |
|
| 117 | +$this->xPlugin = $xPlugin; |
|
| 118 | +$this->nItemsPerPage = $nItemsPerPage > 0 ? $nItemsPerPage : 0; |
|
| 119 | +$this->nItemsCount = $nItemsCount > 0 ? $nItemsCount : 0; |
|
| 120 | +$this->nPageNumber = $nPageNumber < 1 ? 1 : $nPageNumber; |
|
| 121 | +$this->updatePagesCount(); |
|
| 122 | +} |
|
| 123 | + |
|
| 124 | +/** |
|
| 125 | 125 | * Update the number of pages |
| 126 | 126 | * |
| 127 | 127 | * @return Paginator |
| 128 | 128 | */ |
| 129 | - private function updatePagesCount(): Paginator |
|
| 130 | - { |
|
| 131 | - $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : |
|
| 132 | - (int)ceil($this->nItemsCount / $this->nItemsPerPage)); |
|
| 133 | - if($this->nPageNumber > $this->nPagesCount) |
|
| 134 | - { |
|
| 135 | - $this->nPageNumber = $this->nPagesCount; |
|
| 136 | - } |
|
| 137 | - return $this; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 129 | +private function updatePagesCount(): Paginator |
|
| 130 | +{ |
|
| 131 | +$this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : |
|
| 132 | +(int)ceil($this->nItemsCount / $this->nItemsPerPage)); |
|
| 133 | +if($this->nPageNumber > $this->nPagesCount) |
|
| 134 | +{ |
|
| 135 | +$this->nPageNumber = $this->nPagesCount; |
|
| 136 | +} |
|
| 137 | +return $this; |
|
| 138 | +} |
|
| 139 | + |
|
| 140 | +/** |
|
| 141 | 141 | * Set the text for the previous page link |
| 142 | 142 | * |
| 143 | 143 | * @param string $sText The text for the previous page link |
| 144 | 144 | * |
| 145 | 145 | * @return Paginator |
| 146 | 146 | */ |
| 147 | - public function setPreviousText(string $sText): Paginator |
|
| 148 | - { |
|
| 149 | - $this->sPreviousText = $sText; |
|
| 150 | - return $this; |
|
| 151 | - } |
|
| 147 | +public function setPreviousText(string $sText): Paginator |
|
| 148 | +{ |
|
| 149 | +$this->sPreviousText = $sText; |
|
| 150 | +return $this; |
|
| 151 | +} |
|
| 152 | 152 | |
| 153 | - /** |
|
| 153 | +/** |
|
| 154 | 154 | * Set the text for the next page link |
| 155 | 155 | * |
| 156 | 156 | * @param string $sText The text for the previous page link |
| 157 | 157 | * |
| 158 | 158 | * @return Paginator |
| 159 | 159 | */ |
| 160 | - public function setNextText(string $sText): Paginator |
|
| 161 | - { |
|
| 162 | - $this->sNextText = $sText; |
|
| 163 | - return $this; |
|
| 164 | - } |
|
| 160 | +public function setNextText(string $sText): Paginator |
|
| 161 | +{ |
|
| 162 | +$this->sNextText = $sText; |
|
| 163 | +return $this; |
|
| 164 | +} |
|
| 165 | 165 | |
| 166 | - /** |
|
| 166 | +/** |
|
| 167 | 167 | * Set the max number of pages to show |
| 168 | 168 | * |
| 169 | 169 | * @param int $nMaxPages The max number of pages to show |
| 170 | 170 | * |
| 171 | 171 | * @return Paginator |
| 172 | 172 | */ |
| 173 | - public function setMaxPages(int $nMaxPages): Paginator |
|
| 174 | - { |
|
| 175 | - $this->nMaxPages = max($nMaxPages, 4); |
|
| 176 | - return $this; |
|
| 177 | - } |
|
| 173 | +public function setMaxPages(int $nMaxPages): Paginator |
|
| 174 | +{ |
|
| 175 | +$this->nMaxPages = max($nMaxPages, 4); |
|
| 176 | +return $this; |
|
| 177 | +} |
|
| 178 | 178 | |
| 179 | - /** |
|
| 179 | +/** |
|
| 180 | 180 | * Get the previous page data. |
| 181 | 181 | * |
| 182 | 182 | * @return Page |
| 183 | 183 | */ |
| 184 | - protected function getPrevPage(): Page |
|
| 185 | - { |
|
| 186 | - return $this->nPageNumber <= 1 ? |
|
| 187 | - new Page('disabled', $this->sPreviousText, 0) : |
|
| 188 | - new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 184 | +protected function getPrevPage(): Page |
|
| 185 | +{ |
|
| 186 | +return $this->nPageNumber <= 1 ? |
|
| 187 | +new Page('disabled', $this->sPreviousText, 0) : |
|
| 188 | +new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1); |
|
| 189 | +} |
|
| 190 | + |
|
| 191 | +/** |
|
| 192 | 192 | * Get the next page data. |
| 193 | 193 | * |
| 194 | 194 | * @return Page |
| 195 | 195 | */ |
| 196 | - protected function getNextPage(): Page |
|
| 197 | - { |
|
| 198 | - return $this->nPageNumber >= $this->nPagesCount ? |
|
| 199 | - new Page('disabled', $this->sNextText, 0) : |
|
| 200 | - new Page('enabled', $this->sNextText, $this->nPageNumber + 1); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 196 | +protected function getNextPage(): Page |
|
| 197 | +{ |
|
| 198 | +return $this->nPageNumber >= $this->nPagesCount ? |
|
| 199 | +new Page('disabled', $this->sNextText, 0) : |
|
| 200 | +new Page('enabled', $this->sNextText, $this->nPageNumber + 1); |
|
| 201 | +} |
|
| 202 | + |
|
| 203 | +/** |
|
| 204 | 204 | * Get a page data. |
| 205 | 205 | * |
| 206 | 206 | * @param integer $nNumber The page number |
| 207 | 207 | * |
| 208 | 208 | * @return Page |
| 209 | 209 | */ |
| 210 | - protected function getPage(int $nNumber): Page |
|
| 211 | - { |
|
| 212 | - if($nNumber < 1) |
|
| 213 | - { |
|
| 214 | - return new Page('disabled', $this->sEllipsysText, 0); |
|
| 215 | - } |
|
| 216 | - $sType = ($nNumber === $this->nPageNumber ? 'current' : 'enabled'); |
|
| 217 | - return new Page($sType, "$nNumber", $nNumber); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 210 | +protected function getPage(int $nNumber): Page |
|
| 211 | +{ |
|
| 212 | +if($nNumber < 1) |
|
| 213 | +{ |
|
| 214 | +return new Page('disabled', $this->sEllipsysText, 0); |
|
| 215 | +} |
|
| 216 | +$sType = ($nNumber === $this->nPageNumber ? 'current' : 'enabled'); |
|
| 217 | +return new Page($sType, "$nNumber", $nNumber); |
|
| 218 | +} |
|
| 219 | + |
|
| 220 | +/** |
|
| 221 | 221 | * Get the array of page numbers to be printed. |
| 222 | 222 | * |
| 223 | 223 | * Example: [1, 0, 4, 5, 6, 0, 10] |
| 224 | 224 | * |
| 225 | 225 | * @return array |
| 226 | 226 | */ |
| 227 | - protected function getPageNumbers(): array |
|
| 228 | - { |
|
| 229 | - $aPageNumbers = []; |
|
| 230 | - |
|
| 231 | - if($this->nPagesCount <= $this->nMaxPages) |
|
| 232 | - { |
|
| 233 | - for($i = 0; $i < $this->nPagesCount; $i++) |
|
| 234 | - { |
|
| 235 | - $aPageNumbers[] = $i + 1; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - return $aPageNumbers; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - // Determine the sliding range, centered around the current page. |
|
| 242 | - $nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2); |
|
| 243 | - |
|
| 244 | - $nSlidingStart = 1; |
|
| 245 | - $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber; |
|
| 246 | - if($nSlidingEndOffset < 0) |
|
| 247 | - { |
|
| 248 | - $nSlidingStart = $this->nPageNumber - $nNumAdjacents; |
|
| 249 | - $nSlidingEndOffset = 0; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $nSlidingEnd = $this->nPagesCount; |
|
| 253 | - $nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount; |
|
| 254 | - if($nSlidingStartOffset < 0) |
|
| 255 | - { |
|
| 256 | - $nSlidingEnd = $this->nPageNumber + $nNumAdjacents; |
|
| 257 | - $nSlidingStartOffset = 0; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // Build the list of page numbers. |
|
| 261 | - if($nSlidingStart > 1) |
|
| 262 | - { |
|
| 263 | - $aPageNumbers[] = 1; |
|
| 264 | - $aPageNumbers[] = 0; // Ellipsys; |
|
| 265 | - } |
|
| 266 | - for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
| 267 | - { |
|
| 268 | - $aPageNumbers[] = $i; |
|
| 269 | - } |
|
| 270 | - if($nSlidingEnd < $this->nPagesCount) |
|
| 271 | - { |
|
| 272 | - $aPageNumbers[] = 0; // Ellipsys; |
|
| 273 | - $aPageNumbers[] = $this->nPagesCount; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - return $aPageNumbers; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 227 | +protected function getPageNumbers(): array |
|
| 228 | +{ |
|
| 229 | +$aPageNumbers = []; |
|
| 230 | + |
|
| 231 | +if($this->nPagesCount <= $this->nMaxPages) |
|
| 232 | +{ |
|
| 233 | +for($i = 0; $i < $this->nPagesCount; $i++) |
|
| 234 | +{ |
|
| 235 | + $aPageNumbers[] = $i + 1; |
|
| 236 | +} |
|
| 237 | + |
|
| 238 | +return $aPageNumbers; |
|
| 239 | +} |
|
| 240 | + |
|
| 241 | +// Determine the sliding range, centered around the current page. |
|
| 242 | +$nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2); |
|
| 243 | + |
|
| 244 | +$nSlidingStart = 1; |
|
| 245 | +$nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber; |
|
| 246 | +if($nSlidingEndOffset < 0) |
|
| 247 | +{ |
|
| 248 | +$nSlidingStart = $this->nPageNumber - $nNumAdjacents; |
|
| 249 | +$nSlidingEndOffset = 0; |
|
| 250 | +} |
|
| 251 | + |
|
| 252 | +$nSlidingEnd = $this->nPagesCount; |
|
| 253 | +$nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount; |
|
| 254 | +if($nSlidingStartOffset < 0) |
|
| 255 | +{ |
|
| 256 | +$nSlidingEnd = $this->nPageNumber + $nNumAdjacents; |
|
| 257 | +$nSlidingStartOffset = 0; |
|
| 258 | +} |
|
| 259 | + |
|
| 260 | +// Build the list of page numbers. |
|
| 261 | +if($nSlidingStart > 1) |
|
| 262 | +{ |
|
| 263 | +$aPageNumbers[] = 1; |
|
| 264 | +$aPageNumbers[] = 0; // Ellipsys; |
|
| 265 | +} |
|
| 266 | +for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
| 267 | +{ |
|
| 268 | +$aPageNumbers[] = $i; |
|
| 269 | +} |
|
| 270 | +if($nSlidingEnd < $this->nPagesCount) |
|
| 271 | +{ |
|
| 272 | +$aPageNumbers[] = 0; // Ellipsys; |
|
| 273 | +$aPageNumbers[] = $this->nPagesCount; |
|
| 274 | +} |
|
| 275 | + |
|
| 276 | +return $aPageNumbers; |
|
| 277 | +} |
|
| 278 | + |
|
| 279 | +/** |
|
| 280 | 280 | * Get the current page number. |
| 281 | 281 | * |
| 282 | 282 | * @return int |
| 283 | 283 | */ |
| 284 | - public function currentPage(): int |
|
| 285 | - { |
|
| 286 | - return $this->nPageNumber; |
|
| 287 | - } |
|
| 284 | +public function currentPage(): int |
|
| 285 | +{ |
|
| 286 | +return $this->nPageNumber; |
|
| 287 | +} |
|
| 288 | 288 | |
| 289 | - /** |
|
| 289 | +/** |
|
| 290 | 290 | * Get the links (pages raw data). |
| 291 | 291 | * |
| 292 | 292 | * @return array<Page> |
| 293 | 293 | */ |
| 294 | - public function pages(): array |
|
| 295 | - { |
|
| 296 | - if($this->nPagesCount < 2) |
|
| 297 | - { |
|
| 298 | - return []; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $aPageNumbers = $this->getPageNumbers(); |
|
| 302 | - $aPages = [$this->getPrevPage()]; |
|
| 303 | - array_walk($aPageNumbers, function($nNumber) use(&$aPages) { |
|
| 304 | - $aPages[] = $this->getPage($nNumber); |
|
| 305 | - }); |
|
| 306 | - $aPages[] = $this->getNextPage(); |
|
| 307 | - |
|
| 308 | - return $aPages; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - /** |
|
| 294 | +public function pages(): array |
|
| 295 | +{ |
|
| 296 | +if($this->nPagesCount < 2) |
|
| 297 | +{ |
|
| 298 | +return []; |
|
| 299 | +} |
|
| 300 | + |
|
| 301 | +$aPageNumbers = $this->getPageNumbers(); |
|
| 302 | +$aPages = [$this->getPrevPage()]; |
|
| 303 | +array_walk($aPageNumbers, function($nNumber) use(&$aPages) { |
|
| 304 | +$aPages[] = $this->getPage($nNumber); |
|
| 305 | +}); |
|
| 306 | +$aPages[] = $this->getNextPage(); |
|
| 307 | + |
|
| 308 | +return $aPages; |
|
| 309 | +} |
|
| 310 | + |
|
| 311 | +/** |
|
| 312 | 312 | * Call a closure that will receive the page number as parameter. |
| 313 | 313 | * |
| 314 | 314 | * @param Closure $fPageCallback |
| 315 | 315 | * |
| 316 | 316 | * @return Paginator |
| 317 | 317 | */ |
| 318 | - public function page(Closure $fPageCallback): Paginator |
|
| 319 | - { |
|
| 320 | - $fPageCallback($this->nPageNumber); |
|
| 318 | +public function page(Closure $fPageCallback): Paginator |
|
| 319 | +{ |
|
| 320 | +$fPageCallback($this->nPageNumber); |
|
| 321 | 321 | |
| 322 | - return $this; |
|
| 323 | - } |
|
| 322 | +return $this; |
|
| 323 | +} |
|
| 324 | 324 | |
| 325 | - /** |
|
| 325 | +/** |
|
| 326 | 326 | * Call a closure that will receive the pagination offset as parameter. |
| 327 | 327 | * |
| 328 | 328 | * @param Closure $fOffsetCallback |
| 329 | 329 | * |
| 330 | 330 | * @return Paginator |
| 331 | 331 | */ |
| 332 | - public function offset(Closure $fOffsetCallback): Paginator |
|
| 333 | - { |
|
| 334 | - $fOffsetCallback(($this->nPageNumber - 1) * $this->nItemsPerPage); |
|
| 332 | +public function offset(Closure $fOffsetCallback): Paginator |
|
| 333 | +{ |
|
| 334 | +$fOffsetCallback(($this->nPageNumber - 1) * $this->nItemsPerPage); |
|
| 335 | 335 | |
| 336 | - return $this; |
|
| 337 | - } |
|
| 336 | +return $this; |
|
| 337 | +} |
|
| 338 | 338 | |
| 339 | - /** |
|
| 339 | +/** |
|
| 340 | 340 | * Show the pagination links |
| 341 | 341 | * |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | - private function renderLinks(): string |
|
| 345 | - { |
|
| 346 | - $aPages = $this->pages(); |
|
| 347 | - if(count($aPages) === 0) |
|
| 348 | - { |
|
| 349 | - return ''; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - $xPrevPage = array_shift($aPages); // The first entry in the array |
|
| 353 | - $xNextPage = array_pop($aPages); // The last entry in the array |
|
| 354 | - return $this->xPlugin->renderer()->render($aPages, $xPrevPage, $xNextPage); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 344 | +private function renderLinks(): string |
|
| 345 | +{ |
|
| 346 | +$aPages = $this->pages(); |
|
| 347 | +if(count($aPages) === 0) |
|
| 348 | +{ |
|
| 349 | +return ''; |
|
| 350 | +} |
|
| 351 | + |
|
| 352 | +$xPrevPage = array_shift($aPages); // The first entry in the array |
|
| 353 | +$xNextPage = array_pop($aPages); // The last entry in the array |
|
| 354 | +return $this->xPlugin->renderer()->render($aPages, $xPrevPage, $xNextPage); |
|
| 355 | +} |
|
| 356 | + |
|
| 357 | +/** |
|
| 358 | 358 | * Show the pagination links |
| 359 | 359 | * |
| 360 | 360 | * @param string $sWrapperId |
| 361 | 361 | * |
| 362 | 362 | * @return array|null |
| 363 | 363 | */ |
| 364 | - private function showLinks(string $sWrapperId): ?array |
|
| 365 | - { |
|
| 366 | - $sHtml = $this->renderLinks(); |
|
| 367 | - // The HTML code must always be displayed, even if it is empty. |
|
| 368 | - if(is_a($this->xPlugin->response(), Response::class)) |
|
| 369 | - { |
|
| 370 | - /** @var Response */ |
|
| 371 | - $xResponse = $this->xPlugin->response(); |
|
| 372 | - $xResponse->html($sWrapperId, $sHtml); |
|
| 373 | - return !$sHtml ? null : ['id' => $sWrapperId]; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - // The wrapper id is not needed for the NodeResponse |
|
| 377 | - /** @var NodeResponse */ |
|
| 378 | - $xResponse = $this->xPlugin->response(); |
|
| 379 | - $xResponse->html($sHtml); |
|
| 380 | - return !$sHtml ? null : []; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - /** |
|
| 364 | +private function showLinks(string $sWrapperId): ?array |
|
| 365 | +{ |
|
| 366 | +$sHtml = $this->renderLinks(); |
|
| 367 | +// The HTML code must always be displayed, even if it is empty. |
|
| 368 | +if(is_a($this->xPlugin->response(), Response::class)) |
|
| 369 | +{ |
|
| 370 | +/** @var Response */ |
|
| 371 | +$xResponse = $this->xPlugin->response(); |
|
| 372 | +$xResponse->html($sWrapperId, $sHtml); |
|
| 373 | +return !$sHtml ? null : ['id' => $sWrapperId]; |
|
| 374 | +} |
|
| 375 | + |
|
| 376 | +// The wrapper id is not needed for the NodeResponse |
|
| 377 | +/** @var NodeResponse */ |
|
| 378 | +$xResponse = $this->xPlugin->response(); |
|
| 379 | +$xResponse->html($sHtml); |
|
| 380 | +return !$sHtml ? null : []; |
|
| 381 | +} |
|
| 382 | + |
|
| 383 | +/** |
|
| 384 | 384 | * @param JsExpr $xCall |
| 385 | 385 | * @param string $sWrapperId |
| 386 | 386 | * |
| 387 | 387 | * @return void |
| 388 | 388 | */ |
| 389 | - public function render(JsExpr $xCall, string $sWrapperId = ''): void |
|
| 390 | - { |
|
| 391 | - if(($xFunc = $xCall->func()) === null) |
|
| 392 | - { |
|
| 393 | - return; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $aParams = $this->showLinks(trim($sWrapperId)); |
|
| 397 | - if($aParams !== null) |
|
| 398 | - { |
|
| 399 | - // Set click handlers on the pagination links |
|
| 400 | - $aParams['func'] = $xFunc->withPage()->jsonSerialize(); |
|
| 401 | - $this->xPlugin->addCommand('pg.paginate', $aParams); |
|
| 402 | - } |
|
| 403 | - } |
|
| 389 | +public function render(JsExpr $xCall, string $sWrapperId = ''): void |
|
| 390 | +{ |
|
| 391 | +if(($xFunc = $xCall->func()) === null) |
|
| 392 | +{ |
|
| 393 | +return; |
|
| 394 | +} |
|
| 395 | + |
|
| 396 | +$aParams = $this->showLinks(trim($sWrapperId)); |
|
| 397 | +if($aParams !== null) |
|
| 398 | +{ |
|
| 399 | +// Set click handlers on the pagination links |
|
| 400 | +$aParams['func'] = $xFunc->withPage()->jsonSerialize(); |
|
| 401 | +$this->xPlugin->addCommand('pg.paginate', $aParams); |
|
| 402 | +} |
|
| 403 | +} |
|
| 404 | 404 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | interface RendererInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Render an array of pagination links |
| 21 | 21 | * |
| 22 | 22 | * @param Page[] $aPages |
@@ -25,5 +25,5 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string; |
|
| 28 | +public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string; |
|
| 29 | 29 | } |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | class Renderer implements RendererInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * The constructor. |
| 26 | 26 | * |
| 27 | 27 | * @param ViewRenderer $xRenderer |
| 28 | 28 | */ |
| 29 | - public function __construct(private ViewRenderer $xRenderer) |
|
| 30 | - { |
|
| 31 | - $this->xRenderer = $xRenderer; |
|
| 32 | - } |
|
| 29 | +public function __construct(private ViewRenderer $xRenderer) |
|
| 30 | +{ |
|
| 31 | +$this->xRenderer = $xRenderer; |
|
| 32 | +} |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @param Page $xPage |
| 36 | 36 | * |
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | - private function renderPage(Page $xPage): string |
|
| 40 | - { |
|
| 41 | - return $this->xRenderer->render("pagination::links/{$xPage->sType}", [ |
|
| 42 | - 'page' => $xPage->nNumber, |
|
| 43 | - 'text' => $xPage->sText, |
|
| 44 | - ])->__toString(); |
|
| 45 | - } |
|
| 39 | +private function renderPage(Page $xPage): string |
|
| 40 | +{ |
|
| 41 | +return $this->xRenderer->render("pagination::links/{$xPage->sType}", [ |
|
| 42 | +'page' => $xPage->nNumber, |
|
| 43 | +'text' => $xPage->sText, |
|
| 44 | +])->__toString(); |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * Render an array of pagination links |
| 49 | 49 | * |
| 50 | 50 | * @param Page[] $aPages |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string |
|
| 57 | - { |
|
| 58 | - return trim($this->xRenderer->render('pagination::wrapper', [ |
|
| 59 | - 'links' => array_map(fn($xPage) => $this->renderPage($xPage), $aPages), |
|
| 60 | - 'prev' => $this->renderPage($xPrevPage), |
|
| 61 | - 'next' => $this->renderPage($xNextPage), |
|
| 62 | - ])->__toString()); |
|
| 63 | - } |
|
| 56 | +public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string |
|
| 57 | +{ |
|
| 58 | +return trim($this->xRenderer->render('pagination::wrapper', [ |
|
| 59 | +'links' => array_map(fn($xPage) => $this->renderPage($xPage), $aPages), |
|
| 60 | +'prev' => $this->renderPage($xPrevPage), |
|
| 61 | +'next' => $this->renderPage($xNextPage), |
|
| 62 | +])->__toString()); |
|
| 63 | +} |
|
| 64 | 64 | } |
@@ -20,15 +20,15 @@ |
||
| 20 | 20 | |
| 21 | 21 | class Translator extends BaseTranslator implements ConfigListenerInterface |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * @inheritDoc |
| 25 | 25 | */ |
| 26 | - public function onChange(Config $xConfig, string $sName): void |
|
| 27 | - { |
|
| 28 | - // Set the library language any time the config is changed. |
|
| 29 | - if($sName === '' || $sName === 'core.language') |
|
| 30 | - { |
|
| 31 | - $this->setLocale($xConfig->getOption('core.language')); |
|
| 32 | - } |
|
| 33 | - } |
|
| 26 | +public function onChange(Config $xConfig, string $sName): void |
|
| 27 | +{ |
|
| 28 | +// Set the library language any time the config is changed. |
|
| 29 | +if($sName === '' || $sName === 'core.language') |
|
| 30 | +{ |
|
| 31 | +$this->setLocale($xConfig->getOption('core.language')); |
|
| 32 | +} |
|
| 33 | +} |
|
| 34 | 34 | } |
@@ -19,61 +19,61 @@ |
||
| 19 | 19 | |
| 20 | 20 | class ConfigEventManager |
| 21 | 21 | { |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * @var string[] |
| 24 | 24 | */ |
| 25 | - protected $aLibConfigListeners = []; |
|
| 25 | +protected $aLibConfigListeners = []; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * @var string[] |
| 29 | 29 | */ |
| 30 | - protected $aAppConfigListeners = []; |
|
| 30 | +protected $aAppConfigListeners = []; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @param Container $di |
| 34 | 34 | */ |
| 35 | - public function __construct(private Container $di) |
|
| 36 | - {} |
|
| 35 | +public function __construct(private Container $di) |
|
| 36 | +{} |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @param string $sClassName |
| 40 | 40 | * |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - public function addLibConfigListener(string $sClassName): void |
|
| 44 | - { |
|
| 45 | - $this->aLibConfigListeners[] = $sClassName; |
|
| 46 | - } |
|
| 43 | +public function addLibConfigListener(string $sClassName): void |
|
| 44 | +{ |
|
| 45 | +$this->aLibConfigListeners[] = $sClassName; |
|
| 46 | +} |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * @param string $sClassName |
| 50 | 50 | * |
| 51 | 51 | * @return void |
| 52 | 52 | */ |
| 53 | - public function addAppConfigListener(string $sClassName): void |
|
| 54 | - { |
|
| 55 | - $this->aAppConfigListeners[] = $sClassName; |
|
| 56 | - } |
|
| 53 | +public function addAppConfigListener(string $sClassName): void |
|
| 54 | +{ |
|
| 55 | +$this->aAppConfigListeners[] = $sClassName; |
|
| 56 | +} |
|
| 57 | 57 | |
| 58 | - /** |
|
| 58 | +/** |
|
| 59 | 59 | * @inheritDoc |
| 60 | 60 | */ |
| 61 | - public function libConfigChanged(Config $xConfig, string $sName): void |
|
| 62 | - { |
|
| 63 | - foreach($this->aLibConfigListeners as $sListener) |
|
| 64 | - { |
|
| 65 | - $this->di->g($sListener)->onChange($xConfig, $sName); |
|
| 66 | - } |
|
| 67 | - } |
|
| 61 | +public function libConfigChanged(Config $xConfig, string $sName): void |
|
| 62 | +{ |
|
| 63 | +foreach($this->aLibConfigListeners as $sListener) |
|
| 64 | +{ |
|
| 65 | +$this->di->g($sListener)->onChange($xConfig, $sName); |
|
| 66 | +} |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * @inheritDoc |
| 71 | 71 | */ |
| 72 | - public function appConfigChanged(Config $xConfig, string $sName): void |
|
| 73 | - { |
|
| 74 | - foreach($this->aAppConfigListeners as $sListener) |
|
| 75 | - { |
|
| 76 | - $this->di->g($sListener)->onChange($xConfig, $sName); |
|
| 77 | - } |
|
| 78 | - } |
|
| 72 | +public function appConfigChanged(Config $xConfig, string $sName): void |
|
| 73 | +{ |
|
| 74 | +foreach($this->aAppConfigListeners as $sListener) |
|
| 75 | +{ |
|
| 76 | +$this->di->g($sListener)->onChange($xConfig, $sName); |
|
| 77 | +} |
|
| 78 | +} |
|
| 79 | 79 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | interface ConfigListenerInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * Config option changed, in case of multiple changes, the name is an empty string |
| 23 | 23 | * |
| 24 | 24 | * @param Config $xConfig |
@@ -26,5 +26,5 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | - public function onChange(Config $xConfig, string $sName): void; |
|
| 29 | +public function onChange(Config $xConfig, string $sName): void; |
|
| 30 | 30 | } |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | trait ConfigTrait |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @return ConfigManager |
| 21 | 21 | */ |
| 22 | - abstract protected function config(): ConfigManager; |
|
| 22 | +abstract protected function config(): ConfigManager; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * Get the value of a config option |
| 26 | 26 | * |
| 27 | 27 | * @param string $sName The option name |
@@ -29,24 +29,24 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return mixed |
| 31 | 31 | */ |
| 32 | - public function getLibOption(string $sName, $xDefault = null): mixed |
|
| 33 | - { |
|
| 34 | - return $this->config()->getOption($sName, $xDefault); |
|
| 35 | - } |
|
| 32 | +public function getLibOption(string $sName, $xDefault = null): mixed |
|
| 33 | +{ |
|
| 34 | +return $this->config()->getOption($sName, $xDefault); |
|
| 35 | +} |
|
| 36 | 36 | |
| 37 | - /** |
|
| 37 | +/** |
|
| 38 | 38 | * Check the presence of a config option |
| 39 | 39 | * |
| 40 | 40 | * @param string $sName The option name |
| 41 | 41 | * |
| 42 | 42 | * @return bool |
| 43 | 43 | */ |
| 44 | - public function hasLibOption(string $sName): bool |
|
| 45 | - { |
|
| 46 | - return $this->config()->hasOption($sName); |
|
| 47 | - } |
|
| 44 | +public function hasLibOption(string $sName): bool |
|
| 45 | +{ |
|
| 46 | +return $this->config()->hasOption($sName); |
|
| 47 | +} |
|
| 48 | 48 | |
| 49 | - /** |
|
| 49 | +/** |
|
| 50 | 50 | * Set the value of a config option |
| 51 | 51 | * |
| 52 | 52 | * @param string $sName The option name |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | - public function setLibOption(string $sName, $xValue): void |
|
| 58 | - { |
|
| 59 | - $this->config()->setOption($sName, $xValue); |
|
| 60 | - } |
|
| 57 | +public function setLibOption(string $sName, $xValue): void |
|
| 58 | +{ |
|
| 59 | +$this->config()->setOption($sName, $xValue); |
|
| 60 | +} |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | +/** |
|
| 63 | 63 | * Get the value of an application config option |
| 64 | 64 | * |
| 65 | 65 | * @param string $sName The option name |
@@ -67,24 +67,24 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return mixed |
| 69 | 69 | */ |
| 70 | - public function getAppOption(string $sName, $xDefault = null): mixed |
|
| 71 | - { |
|
| 72 | - return $this->config()->getAppOption($sName, $xDefault); |
|
| 73 | - } |
|
| 70 | +public function getAppOption(string $sName, $xDefault = null): mixed |
|
| 71 | +{ |
|
| 72 | +return $this->config()->getAppOption($sName, $xDefault); |
|
| 73 | +} |
|
| 74 | 74 | |
| 75 | - /** |
|
| 75 | +/** |
|
| 76 | 76 | * Check the presence of an application config option |
| 77 | 77 | * |
| 78 | 78 | * @param string $sName The option name |
| 79 | 79 | * |
| 80 | 80 | * @return bool |
| 81 | 81 | */ |
| 82 | - public function hasAppOption(string $sName): bool |
|
| 83 | - { |
|
| 84 | - return $this->config()->hasAppOption($sName); |
|
| 85 | - } |
|
| 82 | +public function hasAppOption(string $sName): bool |
|
| 83 | +{ |
|
| 84 | +return $this->config()->hasAppOption($sName); |
|
| 85 | +} |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | +/** |
|
| 88 | 88 | * Set the value of a config option |
| 89 | 89 | * |
| 90 | 90 | * @param string $sName The option name |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | - public function setAppOption(string $sName, $xValue): void |
|
| 96 | - { |
|
| 97 | - $this->config()->setAppOption($sName, $xValue); |
|
| 98 | - } |
|
| 95 | +public function setAppOption(string $sName, $xValue): void |
|
| 96 | +{ |
|
| 97 | +$this->config()->setAppOption($sName, $xValue); |
|
| 98 | +} |
|
| 99 | 99 | } |