Skip to content

Commit

Permalink
fix: dispatch event for extending the system configuration (pimcore#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig authored Apr 24, 2023
1 parent 5e7c400 commit 9c76a27
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
use Pimcore;
use Pimcore\Cache\RuntimeCache;
use Pimcore\Config\ReportConfigWriter;
use Pimcore\Event\SystemEvents;
use Pimcore\Model\Element\ElementInterface;
use Pimcore\Model\Tool\SettingsStore;
use Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\Yaml\Yaml;

final class Config implements ArrayAccess
Expand Down Expand Up @@ -152,7 +154,16 @@ public static function getSystemConfiguration(string $offset = null): ?array
{
if (null === static::$systemConfig && $container = Pimcore::getContainer()) {

static::$systemConfig = $container->getParameter('pimcore.config');
$settings = $container->getParameter('pimcore.config');

$saveSettingsEvent = new GenericEvent(null, [
'settings' => $settings,
]);
$eventDispatcher = $container->get('event_dispatcher');
$eventDispatcher->dispatch($saveSettingsEvent, SystemEvents::GET_SYSTEM_CONFIGURATION);
$settings = $saveSettingsEvent->getArgument('settings');

static::$systemConfig = $settings;
}

if (null !== $offset) {
Expand Down
9 changes: 9 additions & 0 deletions lib/Event/SystemEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,13 @@ final class SystemEvents
* @var string
*/
const SAVE_ACTION_SYSTEM_SETTINGS = 'pimcore.system.settings.saveAction';

/**
* The GET_SYSTEM_CONFIGURATION event is triggered when the system configuration is requested.
*
* @Event("Symfony\Component\EventDispatcher\GenericEvent")
*
* @var string
*/
const GET_SYSTEM_CONFIGURATION = 'pimcore.system.configuration.get';
}

0 comments on commit 9c76a27

Please sign in to comment.