From 2f60f63870c1c672561c5503de1b5ed9ababd4ba Mon Sep 17 00:00:00 2001 From: Tobias Feijten Date: Wed, 16 Dec 2015 23:13:58 +0100 Subject: [PATCH] Fixes compatibility for Symfony 3.0 --- src/ORM/Translatable/CurrentLocaleCallable.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ORM/Translatable/CurrentLocaleCallable.php b/src/ORM/Translatable/CurrentLocaleCallable.php index e4757533..9207f46f 100644 --- a/src/ORM/Translatable/CurrentLocaleCallable.php +++ b/src/ORM/Translatable/CurrentLocaleCallable.php @@ -19,13 +19,18 @@ public function __construct(Container $container) public function __invoke() { - if (!$this->container->isScopeActive('request')) { - return; + if (!$this->container->has('request_stack')) { + if(!$this->container->isScopeActive('request')) { + return NULL; + } + $request = $this->container->get('request'); + + return $request->getLocale(); + } else if ($request = $this->container->get('request_stack')->getCurrentRequest()) { + return $request->getLocale(); } - $request = $this->container->get('request'); - - return $request->getLocale(); + return NULL; } }