Created
September 16, 2015 16:13
-
-
Save skl/cbf4580fcbf546eb6fa2 to your computer and use it in GitHub Desktop.
Revisions
-
skl created this gist
Sep 16, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ <?php namespace Application; use Zend\ModuleManager\ModuleEvent; use Zend\ModuleManager\ModuleManager; /** * Class Module * @package Application */ class Module { /** * @param ModuleManager $moduleManager */ public function init(ModuleManager $moduleManager) { $events = $moduleManager->getEventManager(); $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, [$this, 'onMergeConfig']); } /** * @param ModuleEvent $e */ public function onMergeConfig(ModuleEvent $e) { $configListener = $e->getConfigListener(); $config = $configListener->getMergedConfig(false); // If both ZfcTwigViewStrategy and ViewJsonStrategy registered, prioritise ViewJsonStrategy, this fixes an issue // with the zfctwig module where it was trying to load layouts for JsonModel responses. if (isset($config['view_manager']['strategies']) && false !== array_search('ViewJsonStrategy', $config['view_manager']['strategies']) && false !== ($zfcKey = array_search('ZfcTwigViewStrategy', $config['view_manager']['strategies'])) ) { unset($config['view_manager']['strategies'][$zfcKey]); array_push($config['view_manager']['strategies'], 'ZfcTwigViewStrategy'); $configListener->setMergedConfig($config); } }