Skip to content

Commit

Permalink
Add used methods to interface specification (#489)
Browse files Browse the repository at this point in the history
These methods are used in the EventManager, but were not part of the EventInterface. As the manager specifies that the Event class implements the interface, these methods should be part of the interface as well (and makes it guaranteed that general values can be appended to all event
implementations).
  • Loading branch information
matslindh authored and christeredvartsen committed Sep 27, 2016
1 parent eb39edf commit 3545ea4
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 29 deletions.
37 changes: 8 additions & 29 deletions src/EventManager/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,14 @@ public function __construct(array $arguments = []) {
}

/**
* Get the event name
*
* @return string
* {@inheritdoc}
*/
public function getName() {
return $this->name;
}

/**
* Sets the event name
*
* @param string $name
* @return self
* {@inheritdoc}
*/
public function setName($name) {
$this->name = $name;
Expand All @@ -65,16 +60,14 @@ public function setName($name) {
}

/**
* Check if propagation has been stopped
*
* @return boolean
* {@inheritdoc}
*/
public function isPropagationStopped() {
return $this->propagationStopped;
}

/**
* Stops the propagation of the event
* {@inheritdoc}
*/
public function stopPropagation() {
$this->propagationStopped = true;
Expand All @@ -83,11 +76,7 @@ public function stopPropagation() {
}

/**
* Get argument
*
* @param string $key
* @throws InvalidArgumentException
* @return mixed
* {@inheritdoc}
*/
public function getArgument($key) {
if ($this->hasArgument($key)) {
Expand All @@ -98,11 +87,7 @@ public function getArgument($key) {
}

/**
* Add argument
*
* @param string $key
* @param mixed $value
* @return self
* {@inheritdoc}
*/
public function setArgument($key, $value) {
$this->arguments[$key] = $value;
Expand All @@ -111,10 +96,7 @@ public function setArgument($key, $value) {
}

/**
* Set arguments
*
* @param array $arguments
* @return self
* {@inheritdoc}
*/
public function setArguments(array $arguments = []) {
$this->arguments = $arguments;
Expand All @@ -123,10 +105,7 @@ public function setArguments(array $arguments = []) {
}

/**
* See if the event has an argument
*
* @param string $key
* @return boolean
* {@inheritdoc}
*/
public function hasArgument($key) {
return isset($this->arguments[$key]);
Expand Down
61 changes: 61 additions & 0 deletions src/EventManager/EventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,67 @@
* @package Event
*/
interface EventInterface {
/**
* Get the event name
*
* @return string
*/
public function getName();

/**
* Sets the event name
*
* @param string $name
* @return self
*/
public function setName($name);

/**
* Check if propagation has been stopped
*
* @return boolean
*/
public function isPropagationStopped();

/**
* Stops the propagation of the event
*/
public function stopPropagation();

/**
* Get argument
*
* @param string $key
* @throws InvalidArgumentException
* @return mixed
*/
public function getArgument($key);

/**
* Add argument
*
* @param string $key
* @param mixed $value
* @return self
*/
public function setArgument($key, $value);

/**
* Set arguments
*
* @param array $arguments
* @return self
*/
public function setArguments(array $arguments = []);

/**
* See if the event has an argument
*
* @param string $key
* @return boolean
*/
public function hasArgument($key);

/**
* Get the request parameter
*
Expand Down

0 comments on commit 3545ea4

Please sign in to comment.