Skip to content

Commit

Permalink
Merge pull request #310 from NobletSolutions/hotfix-injectRequest
Browse files Browse the repository at this point in the history
injected request into controller action
  • Loading branch information
Nyholm committed Mar 23, 2016
2 parents 92ca81f + 31a3e44 commit 6f87e0e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Controller/TranslateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\HttpFoundation\Request;

/**
* Translate Controller.
Expand All @@ -32,9 +33,6 @@
*/
class TranslateController
{
/** @DI\Inject */
private $request;

/** @DI\Inject("jms_translation.config_factory") */
private $configFactory;

Expand All @@ -47,12 +45,13 @@ class TranslateController
/**
* @Route("/", name="jms_translation_index", options = {"i18n" = false})
* @Template
* @param Request $request
* @return array
*/
public function indexAction()
public function indexAction(Request $request)
{
$configs = $this->configFactory->getNames();
$config = $this->request->query->get('config') ?: reset($configs);
$config = $request->query->get('config') ?: reset($configs);
if (!$config) {
throw new RuntimeException('You need to configure at least one config under "jms_translation.configs".');
}
Expand All @@ -64,15 +63,15 @@ public function indexAction()
}

$domains = array_keys($files);
if ((!$domain = $this->request->query->get('domain')) || !isset($files[$domain])) {
if ((!$domain = $request->query->get('domain')) || !isset($files[$domain])) {
$domain = reset($domains);
}

$locales = array_keys($files[$domain]);

natsort($locales);

if ((!$locale = $this->request->query->get('locale')) || !isset($files[$domain][$locale])) {
if ((!$locale = $request->query->get('locale')) || !isset($files[$domain][$locale])) {
$locale = reset($locales);
}

Expand Down

0 comments on commit 6f87e0e

Please sign in to comment.