@@ -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 | } |
@@ -8,71 +8,71 @@ |
||
| 8 | 8 | |
| 9 | 9 | abstract class NodeComponent extends Component\AbstractComponent |
| 10 | 10 | {
|
| 11 | - use Component\HelperTrait; |
|
| 12 | - use Component\NodeResponseTrait; |
|
| 13 | - use Component\AjaxResponseTrait; |
|
| 14 | - use Component\ComponentTrait; |
|
| 11 | +use Component\HelperTrait; |
|
| 12 | +use Component\NodeResponseTrait; |
|
| 13 | +use Component\AjaxResponseTrait; |
|
| 14 | +use Component\ComponentTrait; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @inheritDoc |
| 18 | 18 | */ |
| 19 | - final protected function initComponent(Container $di, ComponentHelper $xHelper): void |
|
| 20 | - {
|
|
| 21 | - $this->setHelper($xHelper); |
|
| 22 | - $this->setNodeResponse($di); |
|
| 23 | - $this->setAjaxResponse($di); |
|
| 24 | - } |
|
| 19 | +final protected function initComponent(Container $di, ComponentHelper $xHelper): void |
|
| 20 | +{
|
|
| 21 | +$this->setHelper($xHelper); |
|
| 22 | +$this->setNodeResponse($di); |
|
| 23 | +$this->setAjaxResponse($di); |
|
| 24 | +} |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @return string|Stringable |
| 28 | 28 | */ |
| 29 | - abstract public function html(): string|Stringable; |
|
| 29 | +abstract public function html(): string|Stringable; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * Called before rendering the component. |
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | - protected function before(): void |
|
| 37 | - {}
|
|
| 36 | +protected function before(): void |
|
| 37 | +{}
|
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * Called after rendering the component. |
| 41 | 41 | * |
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | - protected function after(): void |
|
| 45 | - {}
|
|
| 44 | +protected function after(): void |
|
| 45 | +{}
|
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * Set the attached DOM node content with the component HTML code. |
| 49 | 49 | * |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - final public function render(): void |
|
| 53 | - {
|
|
| 54 | - $this->before(); |
|
| 55 | - $this->node()->html((string)$this->html()); |
|
| 56 | - $this->after(); |
|
| 57 | - } |
|
| 52 | +final public function render(): void |
|
| 53 | +{
|
|
| 54 | +$this->before(); |
|
| 55 | +$this->node()->html((string)$this->html()); |
|
| 56 | +$this->after(); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * Clear the attached DOM node content. |
| 61 | 61 | * |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - final public function clear(): void |
|
| 65 | - {
|
|
| 66 | - $this->node()->clear(); |
|
| 67 | - } |
|
| 64 | +final public function clear(): void |
|
| 65 | +{
|
|
| 66 | +$this->node()->clear(); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Show/hide the attached DOM node. |
| 71 | 71 | * |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | - final public function visible(bool $bVisible): void |
|
| 75 | - {
|
|
| 76 | - $bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide(); |
|
| 77 | - } |
|
| 74 | +final public function visible(bool $bVisible): void |
|
| 75 | +{
|
|
| 76 | +$bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide(); |
|
| 77 | +} |
|
| 78 | 78 | } |
@@ -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 | } |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | class ConfigManager |
| 31 | 31 | { |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @var Config |
| 34 | 34 | */ |
| 35 | - protected $xLibConfig; |
|
| 35 | +protected $xLibConfig; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 37 | +/** |
|
| 38 | 38 | * @var Config |
| 39 | 39 | */ |
| 40 | - protected $xAppConfig; |
|
| 40 | +protected $xAppConfig; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 42 | +/** |
|
| 43 | 43 | * The constructor |
| 44 | 44 | * |
| 45 | 45 | * @param array $aDefaultOptions |
@@ -48,15 +48,15 @@ discard block |
||
| 48 | 48 | * @param ConfigSetter $xConfigSetter |
| 49 | 49 | * @param ConfigEventManager $xEventManager |
| 50 | 50 | */ |
| 51 | - public function __construct(array $aDefaultOptions, private Translator $xTranslator, |
|
| 52 | - private ConfigReader $xConfigReader, private ConfigSetter $xConfigSetter, |
|
| 53 | - private ConfigEventManager $xEventManager) |
|
| 54 | - { |
|
| 55 | - $this->xLibConfig = $xConfigSetter->newConfig($aDefaultOptions); |
|
| 56 | - $this->xAppConfig = $xConfigSetter->newConfig(); |
|
| 57 | - } |
|
| 51 | +public function __construct(array $aDefaultOptions, private Translator $xTranslator, |
|
| 52 | +private ConfigReader $xConfigReader, private ConfigSetter $xConfigSetter, |
|
| 53 | +private ConfigEventManager $xEventManager) |
|
| 54 | +{ |
|
| 55 | +$this->xLibConfig = $xConfigSetter->newConfig($aDefaultOptions); |
|
| 56 | +$this->xAppConfig = $xConfigSetter->newConfig(); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * Read a config file |
| 61 | 61 | * |
| 62 | 62 | * @param string $sConfigFile |
@@ -64,35 +64,35 @@ discard block |
||
| 64 | 64 | * @return array |
| 65 | 65 | * @throws SetupException |
| 66 | 66 | */ |
| 67 | - public function read(string $sConfigFile): array |
|
| 68 | - { |
|
| 69 | - try |
|
| 70 | - { |
|
| 71 | - return $this->xConfigReader->read($sConfigFile); |
|
| 72 | - } |
|
| 73 | - catch(YamlExtension $e) |
|
| 74 | - { |
|
| 75 | - $sMessage = $this->xTranslator->trans('errors.yaml.install'); |
|
| 76 | - throw new SetupException($sMessage); |
|
| 77 | - } |
|
| 78 | - catch(FileExtension $e) |
|
| 79 | - { |
|
| 80 | - $sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]); |
|
| 81 | - throw new SetupException($sMessage); |
|
| 82 | - } |
|
| 83 | - catch(FileAccess $e) |
|
| 84 | - { |
|
| 85 | - $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]); |
|
| 86 | - throw new SetupException($sMessage); |
|
| 87 | - } |
|
| 88 | - catch(FileContent $e) |
|
| 89 | - { |
|
| 90 | - $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]); |
|
| 91 | - throw new SetupException($sMessage); |
|
| 92 | - } |
|
| 93 | - } |
|
| 67 | +public function read(string $sConfigFile): array |
|
| 68 | +{ |
|
| 69 | +try |
|
| 70 | +{ |
|
| 71 | +return $this->xConfigReader->read($sConfigFile); |
|
| 72 | +} |
|
| 73 | +catch(YamlExtension $e) |
|
| 74 | +{ |
|
| 75 | +$sMessage = $this->xTranslator->trans('errors.yaml.install'); |
|
| 76 | +throw new SetupException($sMessage); |
|
| 77 | +} |
|
| 78 | +catch(FileExtension $e) |
|
| 79 | +{ |
|
| 80 | +$sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]); |
|
| 81 | +throw new SetupException($sMessage); |
|
| 82 | +} |
|
| 83 | +catch(FileAccess $e) |
|
| 84 | +{ |
|
| 85 | +$sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]); |
|
| 86 | +throw new SetupException($sMessage); |
|
| 87 | +} |
|
| 88 | +catch(FileContent $e) |
|
| 89 | +{ |
|
| 90 | +$sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]); |
|
| 91 | +throw new SetupException($sMessage); |
|
| 92 | +} |
|
| 93 | +} |
|
| 94 | 94 | |
| 95 | - /** |
|
| 95 | +/** |
|
| 96 | 96 | * Read options from a config file and set the library config |
| 97 | 97 | * |
| 98 | 98 | * @param string $sConfigFile The full path to the config file |
@@ -101,27 +101,27 @@ discard block |
||
| 101 | 101 | * @return void |
| 102 | 102 | * @throws SetupException |
| 103 | 103 | */ |
| 104 | - public function load(string $sConfigFile, string $sConfigSection = ''): void |
|
| 105 | - { |
|
| 106 | - try |
|
| 107 | - { |
|
| 108 | - // Read the options and save in the config. |
|
| 109 | - $this->xLibConfig = $this->xConfigSetter |
|
| 110 | - ->setOptions($this->xLibConfig, $this->read($sConfigFile), $sConfigSection); |
|
| 111 | - // Call the config change listeners. |
|
| 112 | - $this->xEventManager->libConfigChanged($this->xLibConfig, ''); |
|
| 113 | - } |
|
| 114 | - catch(DataDepth $e) |
|
| 115 | - { |
|
| 116 | - $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 117 | - 'key' => $e->sPrefix, |
|
| 118 | - 'depth' => $e->nDepth, |
|
| 119 | - ]); |
|
| 120 | - throw new SetupException($sMessage); |
|
| 121 | - } |
|
| 122 | - } |
|
| 104 | +public function load(string $sConfigFile, string $sConfigSection = ''): void |
|
| 105 | +{ |
|
| 106 | +try |
|
| 107 | +{ |
|
| 108 | +// Read the options and save in the config. |
|
| 109 | +$this->xLibConfig = $this->xConfigSetter |
|
| 110 | + ->setOptions($this->xLibConfig, $this->read($sConfigFile), $sConfigSection); |
|
| 111 | +// Call the config change listeners. |
|
| 112 | +$this->xEventManager->libConfigChanged($this->xLibConfig, ''); |
|
| 113 | +} |
|
| 114 | +catch(DataDepth $e) |
|
| 115 | +{ |
|
| 116 | +$sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 117 | + 'key' => $e->sPrefix, |
|
| 118 | + 'depth' => $e->nDepth, |
|
| 119 | +]); |
|
| 120 | +throw new SetupException($sMessage); |
|
| 121 | +} |
|
| 122 | +} |
|
| 123 | 123 | |
| 124 | - /** |
|
| 124 | +/** |
|
| 125 | 125 | * Set the config options of the library |
| 126 | 126 | * |
| 127 | 127 | * @param array $aOptions |
@@ -130,27 +130,27 @@ discard block |
||
| 130 | 130 | * @return bool |
| 131 | 131 | * @throws SetupException |
| 132 | 132 | */ |
| 133 | - public function setOptions(array $aOptions, string $sNamePrefix = ''): bool |
|
| 134 | - { |
|
| 135 | - try |
|
| 136 | - { |
|
| 137 | - $this->xLibConfig = $this->xConfigSetter |
|
| 138 | - ->setOptions($this->xLibConfig, $aOptions, $sNamePrefix); |
|
| 139 | - // Call the config change listeners. |
|
| 140 | - $this->xEventManager->libConfigChanged($this->xLibConfig, ''); |
|
| 141 | - return $this->xLibConfig->changed(); |
|
| 142 | - } |
|
| 143 | - catch(DataDepth $e) |
|
| 144 | - { |
|
| 145 | - $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 146 | - 'key' => $e->sPrefix, |
|
| 147 | - 'depth' => $e->nDepth, |
|
| 148 | - ]); |
|
| 149 | - throw new SetupException($sMessage); |
|
| 150 | - } |
|
| 151 | - } |
|
| 133 | +public function setOptions(array $aOptions, string $sNamePrefix = ''): bool |
|
| 134 | +{ |
|
| 135 | +try |
|
| 136 | +{ |
|
| 137 | +$this->xLibConfig = $this->xConfigSetter |
|
| 138 | + ->setOptions($this->xLibConfig, $aOptions, $sNamePrefix); |
|
| 139 | +// Call the config change listeners. |
|
| 140 | +$this->xEventManager->libConfigChanged($this->xLibConfig, ''); |
|
| 141 | +return $this->xLibConfig->changed(); |
|
| 142 | +} |
|
| 143 | +catch(DataDepth $e) |
|
| 144 | +{ |
|
| 145 | +$sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 146 | + 'key' => $e->sPrefix, |
|
| 147 | + 'depth' => $e->nDepth, |
|
| 148 | +]); |
|
| 149 | +throw new SetupException($sMessage); |
|
| 150 | +} |
|
| 151 | +} |
|
| 152 | 152 | |
| 153 | - /** |
|
| 153 | +/** |
|
| 154 | 154 | * Set the value of a config option |
| 155 | 155 | * |
| 156 | 156 | * @param string $sName The option name |
@@ -158,15 +158,15 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return void |
| 160 | 160 | */ |
| 161 | - public function setOption(string $sName, $xValue): void |
|
| 162 | - { |
|
| 163 | - $this->xLibConfig = $this->xConfigSetter |
|
| 164 | - ->setOption($this->xLibConfig, $sName, $xValue); |
|
| 165 | - // Call the config change listeners. |
|
| 166 | - $this->xEventManager->libConfigChanged($this->xLibConfig, $sName); |
|
| 167 | - } |
|
| 161 | +public function setOption(string $sName, $xValue): void |
|
| 162 | +{ |
|
| 163 | +$this->xLibConfig = $this->xConfigSetter |
|
| 164 | +->setOption($this->xLibConfig, $sName, $xValue); |
|
| 165 | +// Call the config change listeners. |
|
| 166 | +$this->xEventManager->libConfigChanged($this->xLibConfig, $sName); |
|
| 167 | +} |
|
| 168 | 168 | |
| 169 | - /** |
|
| 169 | +/** |
|
| 170 | 170 | * Get the value of a config option |
| 171 | 171 | * |
| 172 | 172 | * @param string $sName The option name |
@@ -174,36 +174,36 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return mixed |
| 176 | 176 | */ |
| 177 | - public function getOption(string $sName, $xDefault = null): mixed |
|
| 178 | - { |
|
| 179 | - return $this->xLibConfig->getOption($sName, $xDefault); |
|
| 180 | - } |
|
| 177 | +public function getOption(string $sName, $xDefault = null): mixed |
|
| 178 | +{ |
|
| 179 | +return $this->xLibConfig->getOption($sName, $xDefault); |
|
| 180 | +} |
|
| 181 | 181 | |
| 182 | - /** |
|
| 182 | +/** |
|
| 183 | 183 | * Check the presence of a config option |
| 184 | 184 | * |
| 185 | 185 | * @param string $sName The option name |
| 186 | 186 | * |
| 187 | 187 | * @return bool |
| 188 | 188 | */ |
| 189 | - public function hasOption(string $sName): bool |
|
| 190 | - { |
|
| 191 | - return $this->xLibConfig->hasOption($sName); |
|
| 192 | - } |
|
| 189 | +public function hasOption(string $sName): bool |
|
| 190 | +{ |
|
| 191 | +return $this->xLibConfig->hasOption($sName); |
|
| 192 | +} |
|
| 193 | 193 | |
| 194 | - /** |
|
| 194 | +/** |
|
| 195 | 195 | * Get the names of the options matching a given prefix |
| 196 | 196 | * |
| 197 | 197 | * @param string $sPrefix The prefix to match |
| 198 | 198 | * |
| 199 | 199 | * @return array |
| 200 | 200 | */ |
| 201 | - public function getOptionNames(string $sPrefix): array |
|
| 202 | - { |
|
| 203 | - return $this->xLibConfig->getOptionNames($sPrefix); |
|
| 204 | - } |
|
| 201 | +public function getOptionNames(string $sPrefix): array |
|
| 202 | +{ |
|
| 203 | +return $this->xLibConfig->getOptionNames($sPrefix); |
|
| 204 | +} |
|
| 205 | 205 | |
| 206 | - /** |
|
| 206 | +/** |
|
| 207 | 207 | * Set the value of a config option |
| 208 | 208 | * |
| 209 | 209 | * @param string $sName The option name |
@@ -211,25 +211,25 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return void |
| 213 | 213 | */ |
| 214 | - public function setAppOption(string $sName, $xValue): void |
|
| 215 | - { |
|
| 216 | - $this->xAppConfig = $this->xConfigSetter |
|
| 217 | - ->setOption($this->xAppConfig, $sName, $xValue); |
|
| 218 | - // Call the config change listeners. |
|
| 219 | - $this->xEventManager->appConfigChanged($this->xAppConfig, $sName); |
|
| 220 | - } |
|
| 214 | +public function setAppOption(string $sName, $xValue): void |
|
| 215 | +{ |
|
| 216 | +$this->xAppConfig = $this->xConfigSetter |
|
| 217 | +->setOption($this->xAppConfig, $sName, $xValue); |
|
| 218 | +// Call the config change listeners. |
|
| 219 | +$this->xEventManager->appConfigChanged($this->xAppConfig, $sName); |
|
| 220 | +} |
|
| 221 | 221 | |
| 222 | - /** |
|
| 222 | +/** |
|
| 223 | 223 | * Get the application config |
| 224 | 224 | * |
| 225 | 225 | * @return Config |
| 226 | 226 | */ |
| 227 | - public function getAppConfig(): Config |
|
| 228 | - { |
|
| 229 | - return $this->xAppConfig; |
|
| 230 | - } |
|
| 227 | +public function getAppConfig(): Config |
|
| 228 | +{ |
|
| 229 | +return $this->xAppConfig; |
|
| 230 | +} |
|
| 231 | 231 | |
| 232 | - /** |
|
| 232 | +/** |
|
| 233 | 233 | * Set the application config options |
| 234 | 234 | * |
| 235 | 235 | * @param array $aAppOptions |
@@ -237,27 +237,27 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return bool |
| 239 | 239 | */ |
| 240 | - public function setAppOptions(array $aAppOptions, string $sNamePrefix = ''): bool |
|
| 241 | - { |
|
| 242 | - try |
|
| 243 | - { |
|
| 244 | - $this->xAppConfig = $this->xConfigSetter |
|
| 245 | - ->setOptions($this->xAppConfig, $aAppOptions, $sNamePrefix); |
|
| 246 | - // Call the config change listeners. |
|
| 247 | - $this->xEventManager->appConfigChanged($this->xAppConfig, ''); |
|
| 248 | - return $this->xAppConfig->changed(); |
|
| 249 | - } |
|
| 250 | - catch(DataDepth $e) |
|
| 251 | - { |
|
| 252 | - $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 253 | - 'key' => $e->sPrefix, |
|
| 254 | - 'depth' => $e->nDepth, |
|
| 255 | - ]); |
|
| 256 | - throw new SetupException($sMessage); |
|
| 257 | - } |
|
| 258 | - } |
|
| 240 | +public function setAppOptions(array $aAppOptions, string $sNamePrefix = ''): bool |
|
| 241 | +{ |
|
| 242 | +try |
|
| 243 | +{ |
|
| 244 | +$this->xAppConfig = $this->xConfigSetter |
|
| 245 | + ->setOptions($this->xAppConfig, $aAppOptions, $sNamePrefix); |
|
| 246 | +// Call the config change listeners. |
|
| 247 | +$this->xEventManager->appConfigChanged($this->xAppConfig, ''); |
|
| 248 | +return $this->xAppConfig->changed(); |
|
| 249 | +} |
|
| 250 | +catch(DataDepth $e) |
|
| 251 | +{ |
|
| 252 | +$sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 253 | + 'key' => $e->sPrefix, |
|
| 254 | + 'depth' => $e->nDepth, |
|
| 255 | +]); |
|
| 256 | +throw new SetupException($sMessage); |
|
| 257 | +} |
|
| 258 | +} |
|
| 259 | 259 | |
| 260 | - /** |
|
| 260 | +/** |
|
| 261 | 261 | * Get the value of an application config option |
| 262 | 262 | * |
| 263 | 263 | * @param string $sName The option name |
@@ -265,24 +265,24 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return mixed |
| 267 | 267 | */ |
| 268 | - public function getAppOption(string $sName, $xDefault = null): mixed |
|
| 269 | - { |
|
| 270 | - return $this->xAppConfig->getOption($sName, $xDefault); |
|
| 271 | - } |
|
| 268 | +public function getAppOption(string $sName, $xDefault = null): mixed |
|
| 269 | +{ |
|
| 270 | +return $this->xAppConfig->getOption($sName, $xDefault); |
|
| 271 | +} |
|
| 272 | 272 | |
| 273 | - /** |
|
| 273 | +/** |
|
| 274 | 274 | * Check the presence of an application config option |
| 275 | 275 | * |
| 276 | 276 | * @param string $sName The option name |
| 277 | 277 | * |
| 278 | 278 | * @return bool |
| 279 | 279 | */ |
| 280 | - public function hasAppOption(string $sName): bool |
|
| 281 | - { |
|
| 282 | - return $this->xAppConfig->hasOption($sName); |
|
| 283 | - } |
|
| 280 | +public function hasAppOption(string $sName): bool |
|
| 281 | +{ |
|
| 282 | +return $this->xAppConfig->hasOption($sName); |
|
| 283 | +} |
|
| 284 | 284 | |
| 285 | - /** |
|
| 285 | +/** |
|
| 286 | 286 | * Create a new the config object |
| 287 | 287 | * |
| 288 | 288 | * @param array $aOptions The options array |
@@ -291,54 +291,54 @@ discard block |
||
| 291 | 291 | * @return Config |
| 292 | 292 | * @throws SetupException |
| 293 | 293 | */ |
| 294 | - public function newConfig(array $aOptions = [], string $sNamePrefix = ''): Config |
|
| 295 | - { |
|
| 296 | - try |
|
| 297 | - { |
|
| 298 | - return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix); |
|
| 299 | - } |
|
| 300 | - catch(DataDepth $e) |
|
| 301 | - { |
|
| 302 | - $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 303 | - 'key' => $e->sPrefix, |
|
| 304 | - 'depth' => $e->nDepth, |
|
| 305 | - ]); |
|
| 306 | - throw new SetupException($sMessage); |
|
| 307 | - } |
|
| 308 | - } |
|
| 294 | +public function newConfig(array $aOptions = [], string $sNamePrefix = ''): Config |
|
| 295 | +{ |
|
| 296 | +try |
|
| 297 | +{ |
|
| 298 | +return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix); |
|
| 299 | +} |
|
| 300 | +catch(DataDepth $e) |
|
| 301 | +{ |
|
| 302 | +$sMessage = $this->xTranslator->trans('errors.data.depth', [ |
|
| 303 | + 'key' => $e->sPrefix, |
|
| 304 | + 'depth' => $e->nDepth, |
|
| 305 | +]); |
|
| 306 | +throw new SetupException($sMessage); |
|
| 307 | +} |
|
| 308 | +} |
|
| 309 | 309 | |
| 310 | - /** |
|
| 310 | +/** |
|
| 311 | 311 | * @param string $sClassName |
| 312 | 312 | * |
| 313 | 313 | * @return void |
| 314 | 314 | */ |
| 315 | - public function addLibEventListener(string $sClassName): void |
|
| 316 | - { |
|
| 317 | - $this->xEventManager->addLibConfigListener($sClassName); |
|
| 318 | - } |
|
| 315 | +public function addLibEventListener(string $sClassName): void |
|
| 316 | +{ |
|
| 317 | +$this->xEventManager->addLibConfigListener($sClassName); |
|
| 318 | +} |
|
| 319 | 319 | |
| 320 | - /** |
|
| 320 | +/** |
|
| 321 | 321 | * @param string $sClassName |
| 322 | 322 | * |
| 323 | 323 | * @return void |
| 324 | 324 | */ |
| 325 | - public function addAppEventListener(string $sClassName): void |
|
| 326 | - { |
|
| 327 | - $this->xEventManager->addAppConfigListener($sClassName); |
|
| 328 | - } |
|
| 325 | +public function addAppEventListener(string $sClassName): void |
|
| 326 | +{ |
|
| 327 | +$this->xEventManager->addAppConfigListener($sClassName); |
|
| 328 | +} |
|
| 329 | 329 | |
| 330 | - /** |
|
| 330 | +/** |
|
| 331 | 331 | * Make the helpers functions available in the global namespace. |
| 332 | 332 | * |
| 333 | 333 | * @param bool $bForce |
| 334 | 334 | * |
| 335 | 335 | * @return void |
| 336 | 336 | */ |
| 337 | - public function globals(bool $bForce = false): void |
|
| 338 | - { |
|
| 339 | - if($bForce || $this->getAppOption('helpers.global', true)) |
|
| 340 | - { |
|
| 341 | - require_once dirname(__DIR__, 2) . '/globals.php'; |
|
| 342 | - } |
|
| 343 | - } |
|
| 337 | +public function globals(bool $bForce = false): void |
|
| 338 | +{ |
|
| 339 | +if($bForce || $this->getAppOption('helpers.global', true)) |
|
| 340 | +{ |
|
| 341 | +require_once dirname(__DIR__, 2) . '/globals.php'; |
|
| 342 | +} |
|
| 343 | +} |
|
| 344 | 344 | } |
@@ -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 | } |
@@ -21,59 +21,59 @@ |
||
| 21 | 21 | |
| 22 | 22 | abstract class HookData extends AbstractData |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $aCalls = []; |
|
| 27 | +protected $aCalls = []; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - abstract protected function getType(): string; |
|
| 32 | +abstract protected function getType(): string; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | - public function getName(): string |
|
| 38 | - { |
|
| 39 | - return '__' . $this->getType(); |
|
| 40 | - } |
|
| 37 | +public function getName(): string |
|
| 38 | +{ |
|
| 39 | +return '__' . $this->getType(); |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - /** |
|
| 42 | +/** |
|
| 43 | 43 | * @return mixed |
| 44 | 44 | */ |
| 45 | - public function getValue(): mixed |
|
| 46 | - { |
|
| 47 | - return $this->aCalls; |
|
| 48 | - } |
|
| 45 | +public function getValue(): mixed |
|
| 46 | +{ |
|
| 47 | +return $this->aCalls; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * @param string $sMethod |
| 52 | 52 | * @param array $aParams |
| 53 | 53 | * |
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | - public function addCall(string $sMethod, array $aParams): void |
|
| 57 | - { |
|
| 58 | - if(!$this->validateMethod($sMethod)) |
|
| 59 | - { |
|
| 60 | - $sType = $this->getType(); |
|
| 61 | - throw new SetupException("'$sMethod' is not a valid \"call\" value for $sType."); |
|
| 62 | - } |
|
| 63 | - $this->aCalls[$sMethod] = $aParams; |
|
| 64 | - } |
|
| 56 | +public function addCall(string $sMethod, array $aParams): void |
|
| 57 | +{ |
|
| 58 | +if(!$this->validateMethod($sMethod)) |
|
| 59 | +{ |
|
| 60 | +$sType = $this->getType(); |
|
| 61 | +throw new SetupException("'$sMethod' is not a valid \"call\" value for $sType."); |
|
| 62 | +} |
|
| 63 | +$this->aCalls[$sMethod] = $aParams; |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * @inheritDoc |
| 68 | 68 | */ |
| 69 | - public function encode(string $sVarName): array |
|
| 70 | - { |
|
| 71 | - $aCalls = []; |
|
| 72 | - foreach($this->aCalls as $sMethod => $aParams) |
|
| 73 | - { |
|
| 74 | - $sParams = addslashes(json_encode($aParams)); |
|
| 75 | - $aCalls[] = "{$sVarName}->addCall('$sMethod', json_decode(\"$sParams\", true));"; |
|
| 76 | - } |
|
| 77 | - return $aCalls; |
|
| 78 | - } |
|
| 69 | +public function encode(string $sVarName): array |
|
| 70 | +{ |
|
| 71 | +$aCalls = []; |
|
| 72 | +foreach($this->aCalls as $sMethod => $aParams) |
|
| 73 | +{ |
|
| 74 | +$sParams = addslashes(json_encode($aParams)); |
|
| 75 | +$aCalls[] = "{$sVarName}->addCall('$sMethod', json_decode(\"$sParams\", true));"; |
|
| 76 | +} |
|
| 77 | +return $aCalls; |
|
| 78 | +} |
|
| 79 | 79 | } |
@@ -8,20 +8,20 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class FuncComponent extends Component\AbstractComponent |
| 10 | 10 | { |
| 11 | - use Component\HelperTrait; |
|
| 12 | - use Component\AjaxResponseTrait; |
|
| 13 | - use Component\ComponentTrait; |
|
| 11 | +use Component\HelperTrait; |
|
| 12 | +use Component\AjaxResponseTrait; |
|
| 13 | +use Component\ComponentTrait; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 15 | +/** |
|
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - final protected function initComponent(Container $di, ComponentHelper $xHelper): void |
|
| 19 | - { |
|
| 20 | - $this->setHelper($xHelper); |
|
| 21 | - $this->setAjaxResponse($di); |
|
| 22 | - } |
|
| 18 | +final protected function initComponent(Container $di, ComponentHelper $xHelper): void |
|
| 19 | +{ |
|
| 20 | +$this->setHelper($xHelper); |
|
| 21 | +$this->setAjaxResponse($di); |
|
| 22 | +} |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * Create a paginator. |
| 26 | 26 | * |
| 27 | 27 | * @param int $nPageNumber The current page number |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return Paginator |
| 32 | 32 | */ |
| 33 | - final public function paginator(int $nPageNumber, int $nItemsPerPage, int $nTotalItems): Paginator |
|
| 34 | - { |
|
| 35 | - return $this->response->paginator($nPageNumber, $nItemsPerPage, $nTotalItems); |
|
| 36 | - } |
|
| 33 | +final public function paginator(int $nPageNumber, int $nItemsPerPage, int $nTotalItems): Paginator |
|
| 34 | +{ |
|
| 35 | +return $this->response->paginator($nPageNumber, $nItemsPerPage, $nTotalItems); |
|
| 36 | +} |
|
| 37 | 37 | } |