Updated Symfony HttpFoundation to 2.1.6.
This commit is contained in:
@@ -75,7 +75,15 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek($type, $default = null)
|
||||
public function add($type, $message)
|
||||
{
|
||||
$this->flashes['new'][$type][] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek($type, array $default = array())
|
||||
{
|
||||
return $this->has($type) ? $this->flashes['display'][$type] : $default;
|
||||
}
|
||||
@@ -85,13 +93,13 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function peekAll()
|
||||
{
|
||||
return array_key_exists('display', $this->flashes) ? (array)$this->flashes['display'] : array();
|
||||
return array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($type, $default = null)
|
||||
public function get($type, array $default = array())
|
||||
{
|
||||
$return = $default;
|
||||
|
||||
@@ -129,9 +137,9 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($type, $message)
|
||||
public function set($type, $messages)
|
||||
{
|
||||
$this->flashes['new'][$type] = $message;
|
||||
$this->flashes['new'][$type] = (array) $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +147,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function has($type)
|
||||
{
|
||||
return array_key_exists($type, $this->flashes['display']);
|
||||
return array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,9 +171,6 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$return = $this->all();
|
||||
$this->flashes = array('display' => array(), 'new' => array());
|
||||
|
||||
return $return;
|
||||
return $this->all();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Symfony\Component\HttpFoundation\Session\Flash;
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
class FlashBag implements FlashBagInterface
|
||||
class FlashBag implements FlashBagInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
private $name = 'flashes';
|
||||
|
||||
@@ -68,7 +68,15 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek($type, $default = null)
|
||||
public function add($type, $message)
|
||||
{
|
||||
$this->flashes[$type][] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek($type, array $default =array())
|
||||
{
|
||||
return $this->has($type) ? $this->flashes[$type] : $default;
|
||||
}
|
||||
@@ -84,7 +92,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($type, $default = null)
|
||||
public function get($type, array $default = array())
|
||||
{
|
||||
if (!$this->has($type)) {
|
||||
return $default;
|
||||
@@ -111,9 +119,9 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($type, $message)
|
||||
public function set($type, $messages)
|
||||
{
|
||||
$this->flashes[$type] = $message;
|
||||
$this->flashes[$type] = (array) $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +137,7 @@ class FlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function has($type)
|
||||
{
|
||||
return array_key_exists($type, $this->flashes);
|
||||
return array_key_exists($type, $this->flashes) && $this->flashes[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,4 +163,24 @@ class FlashBag implements FlashBagInterface
|
||||
{
|
||||
return $this->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator for flashes.
|
||||
*
|
||||
* @return \ArrayIterator An \ArrayIterator instance
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator($this->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of flashes.
|
||||
*
|
||||
* @return int The number of flashes
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->flashes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,51 +21,59 @@ use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
||||
interface FlashBagInterface extends SessionBagInterface
|
||||
{
|
||||
/**
|
||||
* Registers a message for a given type.
|
||||
* Adds a flash message for type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
*/
|
||||
function set($type, $message);
|
||||
public function add($type, $message);
|
||||
|
||||
/**
|
||||
* Gets flash message for a given type.
|
||||
* Registers a message for a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function set($type, $message);
|
||||
|
||||
/**
|
||||
* Gets flash messages for a given type.
|
||||
*
|
||||
* @param string $type Message category type.
|
||||
* @param string $default Default value if $type doee not exist.
|
||||
* @param array $default Default value if $type does not exist.
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
function peek($type, $default = null);
|
||||
public function peek($type, array $default = array());
|
||||
|
||||
/**
|
||||
* Gets all flash messages.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function peekAll();
|
||||
public function peekAll();
|
||||
|
||||
/**
|
||||
* Gets and clears flash from the stack.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $default Default value if $type doee not exist.
|
||||
* @param array $default Default value if $type does not exist.
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
function get($type, $default = null);
|
||||
public function get($type, array $default = array());
|
||||
|
||||
/**
|
||||
* Gets and clears flashes from the stack.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function all();
|
||||
public function all();
|
||||
|
||||
/**
|
||||
* Sets all flash messages.
|
||||
*/
|
||||
function setAll(array $messages);
|
||||
public function setAll(array $messages);
|
||||
|
||||
/**
|
||||
* Has flash messages for a given type?
|
||||
@@ -74,12 +82,12 @@ interface FlashBagInterface extends SessionBagInterface
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function has($type);
|
||||
public function has($type);
|
||||
|
||||
/**
|
||||
* Returns a list of all defined types.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function keys();
|
||||
public function keys();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user