Merge branch '3.4' into 4.4
* 3.4: [FrameworkBundle] start session on flashbag injection [Validator] Remove commas in translations
This commit is contained in:
commit
74011262dd
@ -13,8 +13,6 @@
|
||||
|
||||
<service id="session" class="Symfony\Component\HttpFoundation\Session\Session" public="true">
|
||||
<argument type="service" id="session.storage" />
|
||||
<argument type="service" id="session.attribute_bag" />
|
||||
<argument type="service" id="session.flash_bag" />
|
||||
</service>
|
||||
|
||||
<service id="Symfony\Component\HttpFoundation\Session\SessionInterface" alias="session" />
|
||||
@ -37,10 +35,14 @@
|
||||
<argument type="service" id="session.storage.metadata_bag" />
|
||||
</service>
|
||||
|
||||
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag" />
|
||||
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag">
|
||||
<factory service="session" method="getFlashBag"/>
|
||||
</service>
|
||||
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
|
||||
|
||||
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag" />
|
||||
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
|
||||
<factory service="session" method="getAttributeBag"/>
|
||||
</service>
|
||||
|
||||
<service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage">
|
||||
<argument>%kernel.cache_dir%/sessions</argument>
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
|
||||
class InjectedFlashbagSessionController
|
||||
{
|
||||
/**
|
||||
* @var FlashBagInterface
|
||||
*/
|
||||
private $flashBag;
|
||||
|
||||
/**
|
||||
* @var RouterInterface
|
||||
*/
|
||||
private $router;
|
||||
|
||||
public function __construct(
|
||||
FlashBagInterface $flashBag,
|
||||
RouterInterface $router
|
||||
) {
|
||||
$this->flashBag = $flashBag;
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
public function setFlashAction(Request $request, $message)
|
||||
{
|
||||
$this->flashBag->add('notice', $message);
|
||||
|
||||
return new RedirectResponse($this->router->generate('session_showflash'));
|
||||
}
|
||||
}
|
@ -18,6 +18,10 @@ session_setflash:
|
||||
path: /session_setflash/{message}
|
||||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::setFlashAction }
|
||||
|
||||
injected_flashbag_session_setflash:
|
||||
path: injected_flashbag/session_setflash/{message}
|
||||
defaults: { _controller: TestBundle:InjectedFlashbagSession:setFlash}
|
||||
|
||||
session_showflash:
|
||||
path: /session_showflash
|
||||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::showFlashAction }
|
||||
|
@ -69,6 +69,29 @@ class SessionTest extends AbstractWebTestCase
|
||||
$this->assertStringContainsString('No flash was set.', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests flash messages work when flashbag service is injected to the constructor.
|
||||
*
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testFlashOnInjectedFlashbag($config, $insulate)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
// set flash
|
||||
$client->request('GET', '/injected_flashbag/session_setflash/Hello%20world.');
|
||||
|
||||
// check flash displays on redirect
|
||||
$this->assertStringContainsString('Hello world.', $client->followRedirect()->text());
|
||||
|
||||
// check flash is gone
|
||||
$crawler = $client->request('GET', '/session_showflash');
|
||||
$this->assertStringContainsString('No flash was set.', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* See if two separate insulated clients can run without
|
||||
* polluting each other's session data.
|
||||
|
@ -5,3 +5,7 @@ services:
|
||||
Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SubRequestController:
|
||||
tags:
|
||||
- { name: controller.service_arguments, action: indexAction, argument: handler, id: fragment.handler }
|
||||
|
||||
Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\InjectedFlashbagSessionController:
|
||||
autowire: true
|
||||
tags: ['controller.service_arguments']
|
||||
|
@ -192,7 +192,7 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="51">
|
||||
<source>No temporary folder was configured in php.ini.</source>
|
||||
<target>Ninguna carpeta temporal fue configurada en php.ini.</target>
|
||||
<target>Ninguna carpeta temporal fue configurada en php.ini o la carpeta configurada no existe.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="52">
|
||||
<source>Cannot write temporary file to disk.</source>
|
||||
|
@ -192,7 +192,7 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="51">
|
||||
<source>No temporary folder was configured in php.ini.</source>
|
||||
<target>Nie skonfigurowano folderu tymczasowego w php.ini, lub skonfigurowany folder nie istnieje.</target>
|
||||
<target>Nie skonfigurowano folderu tymczasowego w php.ini lub skonfigurowany folder nie istnieje.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="52">
|
||||
<source>Cannot write temporary file to disk.</source>
|
||||
|
Reference in New Issue
Block a user