Last active
September 2, 2016 16:38
-
-
Save alexwilson/6750fee1078dbe2e9e200a9071644f1e to your computer and use it in GitHub Desktop.
EzPublish Legacy Configuration Mapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace EzPublish\AppBundle\EventListener; | |
use eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent; | |
use eZ\Publish\Core\MVC\Legacy\LegacyEvents; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
class LegacyConfigurationMapper implements EventSubscriberInterface | |
{ | |
/** | |
* Settings to inject into the legacy stack. | |
* | |
* @var array | |
*/ | |
protected $settings; | |
/** | |
* {@inheritdoc} | |
* | |
* @return array | |
*/ | |
public static function getSubscribedEvents() | |
{ | |
return [ | |
LegacyEvents::PRE_BUILD_LEGACY_KERNEL => ["onBuildKernel", 128] | |
]; | |
} | |
/** | |
* Maps a setting to legacy stack configuration settings. | |
* | |
* @param string $namespace A full namespace (e.g. `site.ini/RegionalSettings/Locale`) | |
* @param string $value Setting | |
* | |
* @return void | |
*/ | |
public function addSetting($namespace, $value) | |
{ | |
$this->settings[$namespace] = $value; | |
} | |
/** | |
* {@inheritdoc} | |
* | |
* @param PreBuildKernelEvent $e | |
* | |
* @return void | |
*/ | |
public function onBuildKernel(PreBuildKernelEvent $e) | |
{ | |
$e->getParameters()->set( | |
"injected-settings", | |
$this->settings+(array)$e->getParameters()->get("injected-settings") | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
# Event Listeners | |
ezpublish.event_listeners.legacy_configuration_mapper: | |
class: EzPublish\AppBundle\EventListener\LegacyConfigurationMapper | |
tags: [{ name: kernel.event_subscriber }] | |
calls: | |
- [addSetting, ["ezjscore.ini/Packer/CustomHosts", { 0: null, ".js": @=service('request_stack').getMasterRequest().getSchemeAndHttpHost() ~ "/" } ]] | |
- [addSetting, ["acmecorp.ini/Settings/ContentRemoteId", %content.remote_id%]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment