Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Configuration | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
3 | |||
| getConfigurationInstance | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The main class for fetching the configuration, update and delete items. This |
| 5 | * class is also a small Dependency Injection Container for phpMyFAQ. |
| 6 | * |
| 7 | * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 8 | * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 9 | * obtain one at https://mozilla.org/MPL/2.0/. |
| 10 | * |
| 11 | * @package phpMyFAQ |
| 12 | * @author Thorsten Rinne <thorsten@phpmyfaq.de> |
| 13 | * @copyright 2006-2026 phpMyFAQ Team |
| 14 | * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 15 | * @link https://www.phpmyfaq.de |
| 16 | * @since 2006-01-04 |
| 17 | */ |
| 18 | |
| 19 | declare(strict_types=1); |
| 20 | |
| 21 | namespace phpMyFAQ; |
| 22 | |
| 23 | use phpMyFAQ\Configuration\ConfigurationRepository; |
| 24 | use phpMyFAQ\Configuration\LayoutSettings; |
| 25 | use phpMyFAQ\Configuration\LdapSettings; |
| 26 | use phpMyFAQ\Configuration\MailSettings; |
| 27 | use phpMyFAQ\Configuration\SearchSettings; |
| 28 | use phpMyFAQ\Configuration\SecuritySettings; |
| 29 | use phpMyFAQ\Configuration\UrlSettings; |
| 30 | use phpMyFAQ\Database\DatabaseDriver; |
| 31 | use phpMyFAQ\Plugin\PluginException; |
| 32 | |
| 33 | /** |
| 34 | * Class Configuration |
| 35 | * |
| 36 | * @package phpMyFAQ |
| 37 | */ |
| 38 | class Configuration |
| 39 | { |
| 40 | use ConfigurationMethodsTrait; |
| 41 | |
| 42 | private static ?Configuration $configuration = null; |
| 43 | |
| 44 | protected string $tableName = 'faqconfig'; |
| 45 | |
| 46 | public function __construct(DatabaseDriver $databaseDriver) |
| 47 | { |
| 48 | $this->setDatabase($databaseDriver); |
| 49 | $this->setLogger(); |
| 50 | try { |
| 51 | $this->setPluginManager(); |
| 52 | } catch (PluginException $pluginException) { |
| 53 | $this->getLogger()->error($pluginException->getMessage()); |
| 54 | } |
| 55 | |
| 56 | $this->configurationRepository = new ConfigurationRepository($this); |
| 57 | $this->ldapSettings = new LdapSettings($this); |
| 58 | $this->mailSettings = new MailSettings($this); |
| 59 | $this->searchSettings = new SearchSettings($this); |
| 60 | $this->securitySettings = new SecuritySettings($this); |
| 61 | $this->layoutSettings = new LayoutSettings($this); |
| 62 | $this->urlSettings = new UrlSettings($this); |
| 63 | |
| 64 | if (is_null(self::$configuration)) { |
| 65 | self::$configuration = $this; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | public static function getConfigurationInstance(): Configuration |
| 70 | { |
| 71 | return self::$configuration ?? throw new \LogicException('Configuration has not been initialized yet.'); |
| 72 | } |
| 73 | } |