Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "~4.0"
"illuminate/support": "~4.0 || ^13"
},
"require-dev": {
"phpspec/phpspec": "~2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Laracasts/Commander/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function dispatch(array $events)
{
$eventName = $this->getEventName($event);

$this->event->fire($eventName, $event);
$this->event->dispatch($eventName, $event);

$this->log->info("{$eventName} was fired.");
}
Expand Down
22 changes: 22 additions & 0 deletions src/Laracasts/Commander/Events/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ abstract class EventListener {
*/
public function handle($event)
{
$event = static::unwrapEvent(...func_get_args());

$eventName = $this->getEventName($event);

if ($this->listenerIsRegistered($eventName))
Expand All @@ -20,6 +22,26 @@ public function handle($event)
}
}

/**
* L13's event dispatcher invokes wildcard listeners as ($eventName, $payload); the
* pre-L5 dispatcher passed the event object directly. Kept as a one-param signature so
* subclasses that override handle($event) stay compatible; use func_get_args() to reach
* the payload. Returns the domain event object.
*
* @param mixed $event
* @param array $payload
* @return mixed
*/
protected static function unwrapEvent($event, $payload = [])
{
if (is_string($event) && isset($payload[0]) && is_object($payload[0]))
{
return $payload[0];
}

return $event;
}

/**
* Figure out what the name of the class is.
*
Expand Down