Skip to content

Commit

Permalink
deprecate calling queue method on handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 6, 2017
1 parent d41435a commit 0360cb1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 128 deletions.
86 changes: 0 additions & 86 deletions src/Illuminate/Events/CallQueuedHandler.php

This file was deleted.

27 changes: 2 additions & 25 deletions src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,35 +411,12 @@ protected function handlerShouldBeQueued($class)
protected function createQueuedHandlerCallable($class, $method)
{
return function () use ($class, $method) {
$arguments = array_map(function ($a) {
$this->queueHandler($class, $method, array_map(function ($a) {
return is_object($a) ? clone $a : $a;
}, func_get_args());

if (method_exists($class, 'queue')) {
$this->callQueueMethodOnHandler($class, $method, $arguments);
} else {
$this->queueHandler($class, $method, $arguments);
}
}, func_get_args()));
};
}

/**
* Call the queue method on the handler class.
*
* @param string $class
* @param string $method
* @param array $arguments
* @return void
*/
protected function callQueueMethodOnHandler($class, $method, $arguments)
{
$handler = (new ReflectionClass($class))->newInstanceWithoutConstructor();

$handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [
'class' => $class, 'method' => $method, 'data' => serialize($arguments),
]);
}

/**
* Queue the handler class.
*
Expand Down
17 changes: 0 additions & 17 deletions tests/Events/EventsDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,6 @@ public function testQueuedEventHandlersAreQueued()
$d->fire('some.event', ['foo', 'bar']);
}

public function testQueuedEventHandlersAreQueuedWithCustomHandlers()
{
$d = new Dispatcher;
$queue = m::mock('Illuminate\Contracts\Queue\Queue');
$queue->shouldReceive('push')->once()->with('Illuminate\Events\CallQueuedHandler@call', [
'class' => 'Illuminate\Tests\Events\TestDispatcherQueuedHandlerCustomQueue',
'method' => 'someMethod',
'data' => serialize(['foo', 'bar']),
]);
$d->setQueueResolver(function () use ($queue) {
return $queue;
});

$d->listen('some.event', 'Illuminate\Tests\Events\TestDispatcherQueuedHandlerCustomQueue@someMethod');
$d->fire('some.event', ['foo', 'bar']);
}

public function testClassesWork()
{
unset($_SERVER['__event.test']);
Expand Down

0 comments on commit 0360cb1

Please sign in to comment.