Skip to content

Commit

Permalink
CS-5931: Persists locale from Symfony request to Zend Smarty View
Browse files Browse the repository at this point in the history
  • Loading branch information
m038 committed Jan 6, 2016
1 parent eb3388a commit e07139e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion newscoop/library/Newscoop/SmartyView.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ public function _run()
$this->smarty->assign($key, $val);
}

$context = $this->smarty->context();
$locale = \Zend_Controller_Front::getInstance()->getParam('locale');
$em = \Zend_Registry::get('container')->getService('em');
try {
$language = $em->getRepository('Newscoop\Entity\Language')
->findOneByCode($locale);
$context->language = new \MetaLanguage($language->getId());
} catch (\Exception $e) {
// Do nothing, default language will be used
}

$this->smarty->assign('view', $this);
$this->smarty->assign('gimme', $this->smarty->context());
$this->smarty->assign('gimme', $context);

$file = array_shift(func_get_args());
$this->smarty->display($file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function indexAction(Request $request)
}

$front->setParam('bootstrap', $bootstrap);
$front->setParam('locale', $request->getLocale());
$front->setBaseUrl('/');
$response = $front->dispatch();

Expand Down

0 comments on commit e07139e

Please sign in to comment.