-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[WIP][HttpFoundation] Move flash messages out of Session class and change to bucket system. #2592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
7390a1e
b60e84e
1b3d8d4
cedc1f0
91342f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,9 @@ | |
namespace Symfony\Component\HttpFoundation; | ||
|
||
/** | ||
* FlashBagInterface. | ||
* | ||
* @author Drak <[email protected]> | ||
*/ | ||
interface FlashBagInterface | ||
{ | ||
|
@@ -21,61 +23,61 @@ interface FlashBagInterface | |
* | ||
* @param array $flashes | ||
*/ | ||
public function initialize(array $flashes); | ||
function initialize(array $flashes); | ||
|
||
/** | ||
* Adds a flash to the stack for a given type. | ||
*/ | ||
public function add($type, $message); | ||
function add($type, $message); | ||
|
||
/** | ||
* Gets flash messages for a given type. | ||
* | ||
* @return array | ||
*/ | ||
public function get($type); | ||
function get($type); | ||
|
||
/** | ||
* Sets an array of flash messages for a given type. | ||
* | ||
* @param string $type | ||
* @param array $array | ||
*/ | ||
public function set($type, array $array); | ||
function set($type, array $array); | ||
|
||
/** | ||
* Hass flash messages for a given type? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo here. |
||
* | ||
* @return boolean | ||
*/ | ||
public function has($type); | ||
function has($type); | ||
|
||
/** | ||
* Returns a list of all defined types. | ||
* | ||
* @return array | ||
*/ | ||
public function getTypes(); | ||
function getTypes(); | ||
|
||
/** | ||
* Gets all flash messages. | ||
* | ||
* @return array | ||
*/ | ||
public function all(); | ||
function all(); | ||
|
||
/** | ||
* Clears flash messages for a given type. | ||
*/ | ||
public function clear($type); | ||
function clear($type); | ||
|
||
/** | ||
* Clears all flash messages. | ||
*/ | ||
public function clearAll(); | ||
function clearAll(); | ||
|
||
/** | ||
* Removes flash messages set in a previous request. | ||
*/ | ||
public function purgeOldFlashes(); | ||
function purgeOldFlashes(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,19 +31,19 @@ class Session implements \Serializable | |
* | ||
* @var \Symfony\Component\HttpFoundation\FlashBagInterface | ||
*/ | ||
protected $flashes; | ||
protected $flashBag; | ||
protected $closed; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should not add trailing slashes here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont see any trailing slashes, what am I missing? I think my IDE must have truncated the line or changed the line ending? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, not slashes but spaces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and it applies to all the blank lines of your patch as most of them are not really blank lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is my IDE stripping spaces from empty lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, it is your IDE adding them. Stripping them is what you should do to follow the coding standards |
||
/** | ||
* Constructor. | ||
* | ||
* @param SessionStorageInterface $storage A SessionStorageInterface instance. | ||
* @param FlashBagInterface $flashes A FlashBagInterface instance. | ||
* @param SessionStorageInterface $storage A SessionStorageInterface instance. | ||
* @param FlashBagInterface $flashBag A FlashBagInterface instance. | ||
*/ | ||
public function __construct(SessionStorageInterface $storage, FlashBagInterface $flashes) | ||
public function __construct(SessionStorageInterface $storage, FlashBagInterface $flashBag = null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This indicates that flashBag's are optional, but it's not clear what the expected behaviour is if it's null. The rest of the code appears to assume that flashBag is always set, and I don't see any guards or exceptions thrown. |
||
{ | ||
$this->storage = $storage; | ||
$this->flashes = $flashes; | ||
$this->flashBag = $flashBag; | ||
$this->attributes = array(); | ||
$this->started = false; | ||
$this->closed = false; | ||
|
@@ -60,7 +60,7 @@ public function getFlashBag() | |
$this->start(); | ||
} | ||
|
||
return $this->flashes; | ||
return $this->flashBag; | ||
} | ||
|
||
/** | ||
|
@@ -80,7 +80,7 @@ public function start() | |
|
||
if (isset($attributes['attributes'])) { | ||
$this->attributes = $attributes['attributes']; | ||
$this->flashes->initialize($attributes['flashes']); | ||
$this->flashBag->initialize($attributes['flashes']); | ||
} | ||
|
||
$this->started = true; | ||
|
@@ -190,7 +190,7 @@ public function clear() | |
} | ||
|
||
$this->attributes = array(); | ||
$this->flashes->clearAll(); | ||
$this->flashBag->clearAll(); | ||
} | ||
|
||
/** | ||
|
@@ -238,11 +238,11 @@ public function save() | |
} | ||
|
||
// expire old flashes | ||
$this->flashes->purgeOldFlashes(); | ||
$this->flashBag->purgeOldFlashes(); | ||
|
||
$this->storage->write('_symfony2', array( | ||
'attributes' => $this->attributes, | ||
'flashes' => $this->flashes->all(), | ||
'flashes' => $this->flashBag->all(), | ||
)); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here.