| 12345678910111213141516171819202122232425262728 |
- <?php
- declare(strict_types=1);
- namespace SixShop\System\Trait;
- use SixShop\System\ExtensionManager;
- trait ConfigTrait
- {
- public function __construct(private readonly ExtensionManager $extensionManager, private array $options = [])
- {
- }
- public function getConfig(string $key = null): mixed
- {
- if (empty($this->options)) {
- if (!method_exists($this, 'getExtensionID')) {
- return [];
- }
- $this->options = $this->extensionManager->getExtensionConfig($this->getExtensionID());
- }
- return $key ? ($this->options[$key] ?? null) : $this->options;
- }
- public function __get(string $name): mixed
- {
- return $this->getConfig($name);
- }
- }
|