Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ed6ee3

Browse files
author
Drak
committed
[DoctribeBridge][SecurityBundle][WebProfiler] Refactor code for HttpFoundation changes.
1 parent7aaf024 commit1ed6ee3

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

‎src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionStorage.php‎

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
namespaceSymfony\Bridge\Doctrine\HttpFoundation;
44

55
useDoctrine\DBAL\Platforms\MySqlPlatform;
6-
useSymfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage;
6+
useSymfony\Component\HttpFoundation\AttributeBagInterface;
7+
useSymfony\Component\HttpFoundation\FlashBagInterface;
8+
useSymfony\Component\HttpFoundation\SessionStorage\AbstractSessionStorage;
9+
useSymfony\Component\HttpFoundation\SessionStorage\SessionSaveHandlerInterface;
710
useDoctrine\DBAL\Driver\Connection;
811

912
/**
@@ -12,39 +15,32 @@
1215
* @author Fabien Potencier <fabien@symfony.com>
1316
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
1417
*/
15-
class DbalSessionStorageextendsNativeSessionStorage
18+
class DbalSessionStorageextendsAbstractSessionStorageimplements SessionSaveHandlerInterface
1619
{
20+
/**
21+
* @var Connection
22+
*/
1723
private$con;
24+
25+
/**
26+
* @var string
27+
*/
1828
private$tableName;
1929

20-
publicfunction__construct(Connection$con,$tableName ='sessions',array$options =array())
30+
/**
31+
*
32+
* @param Connection $con An instance of Connection.
33+
* @param string $tableName Table name.
34+
* @param array $options Session configuration options
35+
* @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag)
36+
* @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
37+
*/
38+
publicfunction__construct(Connection$con,$tableName ='sessions',array$options =array(),AttributeBagInterface$attributes =null,FlashBagInterface$flashes =null)
2139
{
22-
parent::__construct($options);
23-
2440
$this->con =$con;
2541
$this->tableName =$tableName;
26-
}
27-
28-
/**
29-
* Starts the session.
30-
*/
31-
publicfunctionstart()
32-
{
33-
if (self::$sessionStarted) {
34-
return;
35-
}
3642

37-
// use this object as the session handler
38-
session_set_save_handler(
39-
array($this,'sessionOpen'),
40-
array($this,'sessionClose'),
41-
array($this,'sessionRead'),
42-
array($this,'sessionWrite'),
43-
array($this,'sessionDestroy'),
44-
array($this,'sessionGC')
45-
);
46-
47-
parent::start();
43+
parent::__construct($attributes,$flashes,$options);
4844
}
4945

5046
/**
@@ -102,7 +98,7 @@ public function sessionDestroy($id)
10298
*
10399
* @throws \RuntimeException If any old sessions cannot be cleaned
104100
*/
105-
publicfunctionsessionGC($lifetime)
101+
publicfunctionsessionGc($lifetime)
106102
{
107103
try {
108104
$this->con->executeQuery("DELETE FROM{$this->tableName} WHERE sess_time < :time",array(
@@ -140,7 +136,7 @@ public function sessionRead($id)
140136

141137
return'';
142138
}catch (\PDOException$e) {
143-
thrownew \RuntimeException(sprintf('PDOException was thrown when trying tomanipulate session data: %s',$e->getMessage()),0,$e);
139+
thrownew \RuntimeException(sprintf('PDOException was thrown when trying toread the session data: %s',$e->getMessage()),0,$e);
144140
}
145141
}
146142

@@ -181,7 +177,7 @@ public function sessionWrite($id, $data)
181177
$this->createNewSession($id,$data);
182178
}
183179
}catch (\PDOException$e) {
184-
thrownew \RuntimeException(sprintf('PDOException was thrown when trying tomanipulate session data: %s',$e->getMessage()),0,$e);
180+
thrownew \RuntimeException(sprintf('PDOException was thrown when trying towrite the session data: %s',$e->getMessage()),0,$e);
185181
}
186182

187183
returntrue;

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ framework:
1010
default_locale:en
1111
session:
1212
auto_start:true
13-
storage_id:session.storage.filesystem
13+
storage_id:session.storage.mock_file
1414

1515
services:
1616
logger:{ class: Symfony\Component\HttpKernel\Log\NullLogger }

‎src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
useSymfony\Component\HttpKernel\HttpKernelInterface;
1616
useSymfony\Component\HttpKernel\Event\FilterResponseEvent;
1717
useSymfony\Bundle\TwigBundle\TwigEngine;
18+
useSymfony\Component\HttpFoundation\AutoExpireFlashBag;
1819

1920
/**
2021
* WebDebugToolbarListener injects the Web Debug Toolbar.
@@ -70,9 +71,12 @@ public function onKernelResponse(FilterResponseEvent $event)
7071
}
7172

7273
if ($response->headers->has('X-Debug-Token') &&$response->isRedirect() &&$this->interceptRedirects) {
73-
if (null !==$session =$request->getSession()) {
74-
// keep current flashes for one more request
75-
$session->setFlashes($session->getFlashes());
74+
$session =$request->getSession();
75+
if ($sessioninstanceof AutoExpireFlashBag) {
76+
// keep current flashes for one more request if using AutoExpireFlashBag
77+
foreach ($session->getFlashKeys()as$type) {
78+
$session->setFlashes($session->getFlashes($type));
79+
}
7680
}
7781

7882
$response->setContent($this->templating->render('WebProfilerBundle:Profiler:toolbar_redirect.html.twig',array('location' =>$response->headers->get('Location'))));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp