craue/TwigExtensionsBundle — Issue #1: call to undefined method getLocale()
Author: ibizaman
Created: 2011-10-21 12:15:43+00:00
State: open

Hi,

With the last update of Symfony2 and TwigExtensionsBundle, this exception appears at every loading of a page :

```
Fatal error: Call to undefined method Symfony\Component\HttpFoundation\Request::getLocale()
in symfony2/vendor/bundles/Craue/TwigExtensionsBundle/Twig/Extension/AbstractLocaleAwareExtension.php on line 40
```

Here is the incriminated function :

```php
public function setLocale($value) {
if ($value === null) {
return;
}

if (is_string($value)) {
$this->locale = $value;
return;
}

if ($value instanceof ContainerInterface && $value->isScopeActive('request') && $value->has('request')) {
$value = $value->get('request'); // THIS LINE
}

if ($value instanceof Request) {
$this->locale = $value->getLocale();
}
}
```

Changing "THIS LINE" to this works :

```
$value = $value->session->get('request');
```

I don't know if it's the best way to fix it, but it works for me,
Ibiz