Augmentation vers version 3.3.0
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @link http://github.com/zendframework/zend-eventmanager for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @license https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
namespace Zend\EventManager;
|
||||
@@ -32,7 +32,7 @@ class Event implements EventInterface
|
||||
/**
|
||||
* @var array|ArrayAccess|object The event parameters
|
||||
*/
|
||||
protected $params = array();
|
||||
protected $params = [];
|
||||
|
||||
/**
|
||||
* @var bool Whether or not to stop propagation
|
||||
@@ -91,19 +91,17 @@ class Event implements EventInterface
|
||||
* Overwrites parameters
|
||||
*
|
||||
* @param array|ArrayAccess|object $params
|
||||
* @return Event
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function setParams($params)
|
||||
{
|
||||
if (!is_array($params) && !is_object($params)) {
|
||||
if (! is_array($params) && ! is_object($params)) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
sprintf('Event parameters must be an array or object; received "%s"', gettype($params))
|
||||
);
|
||||
}
|
||||
|
||||
$this->params = $params;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +127,7 @@ class Event implements EventInterface
|
||||
{
|
||||
// Check in params that are arrays or implement array access
|
||||
if (is_array($this->params) || $this->params instanceof ArrayAccess) {
|
||||
if (!isset($this->params[$name])) {
|
||||
if (! isset($this->params[$name])) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
@@ -137,7 +135,7 @@ class Event implements EventInterface
|
||||
}
|
||||
|
||||
// Check in normal objects
|
||||
if (!isset($this->params->{$name})) {
|
||||
if (! isset($this->params->{$name})) {
|
||||
return $default;
|
||||
}
|
||||
return $this->params->{$name};
|
||||
@@ -147,24 +145,20 @@ class Event implements EventInterface
|
||||
* Set the event name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Event
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = (string) $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the event target/context
|
||||
*
|
||||
* @param null|string|object $target
|
||||
* @return Event
|
||||
*/
|
||||
public function setTarget($target)
|
||||
{
|
||||
$this->target = $target;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,25 +166,23 @@ class Event implements EventInterface
|
||||
*
|
||||
* @param string|int $name
|
||||
* @param mixed $value
|
||||
* @return Event
|
||||
*/
|
||||
public function setParam($name, $value)
|
||||
{
|
||||
if (is_array($this->params) || $this->params instanceof ArrayAccess) {
|
||||
// Arrays or objects implementing array access
|
||||
$this->params[$name] = $value;
|
||||
} else {
|
||||
// Objects
|
||||
$this->params->{$name} = $value;
|
||||
return;
|
||||
}
|
||||
return $this;
|
||||
|
||||
// Objects
|
||||
$this->params->{$name} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop further event propagation
|
||||
*
|
||||
* @param bool $flag
|
||||
* @return void
|
||||
*/
|
||||
public function stopPropagation($flag = true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user