mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-07 01:54:27 +00:00
PHRAS-4111: Default language in the configuration file not taken into account on the homepage. (#4570)
* taken account default langage * test
This commit is contained in:
@@ -64,13 +64,6 @@ class PhraseaLocaleSubscriber implements EventSubscriberInterface
|
||||
if ($event->getRequest()->cookies->has('locale')
|
||||
&& isset($this->app['locales.available'][$event->getRequest()->cookies->get('locale')])) {
|
||||
$event->getRequest()->setLocale($event->getRequest()->cookies->get('locale'));
|
||||
} else {
|
||||
foreach ($event->getRequest()->getLanguages() as $code) {
|
||||
$data = preg_split('/[-_]/', $code);
|
||||
if (in_array($data[0], array_keys($this->app['locales.available']), true)) {
|
||||
$event->getRequest()->setLocale($data[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->locale = $this->app['locale'] = $event->getRequest()->getLocale();
|
||||
|
@@ -48,7 +48,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetTestCase
|
||||
$client = new Client($app);
|
||||
$client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr_FR,fr;q=0.9']);
|
||||
|
||||
$this->assertEquals('fr', $client->getResponse()->getContent());
|
||||
$this->assertEquals('en', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testWithHeadersUsingMinus()
|
||||
@@ -58,7 +58,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetTestCase
|
||||
$client = new Client($app);
|
||||
$client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.9']);
|
||||
|
||||
$this->assertEquals('fr', $client->getResponse()->getContent());
|
||||
$this->assertEquals('en', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testCookieIsSet()
|
||||
@@ -75,7 +75,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetTestCase
|
||||
}
|
||||
|
||||
$this->assertNotNull($settedCookie);
|
||||
$this->assertEquals('fr', $settedCookie->getValue());
|
||||
$this->assertEquals('en', $settedCookie->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user