Skip to content

Commit

Permalink
Pass failed onto commands / event handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 20, 2015
1 parent dfc4a69 commit 36b6063
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Illuminate/Events/CallQueuedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,19 @@ protected function setJobInstanceIfNecessary(Job $job, $instance)
return $instance;
}

/**
* Call the failed method on the job instance.
*
* @return void
*/
public function failed(array $data)
{
$handler = $this->container->make($data['class']);

if (method_exists($handler, 'failed'))
{
call_user_func_array([$handler, 'failed'], unserialize($data));
}
}

}
15 changes: 15 additions & 0 deletions src/Illuminate/Queue/CallQueuedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,19 @@ protected function setJobInstanceIfNecessary(Job $job, $instance)
return $instance;
}

/**
* Call the failed method on the job instance.
*
* @return void
*/
public function failed(array $data)
{
$handler = $this->dispatcher->resolveHandler($command = unserialize($data['command']));

if (method_exists($handler, 'failed'))
{
call_user_func([$handler, 'failed'], $command);
}
}

}

0 comments on commit 36b6063

Please sign in to comment.