InvokeQueuedClosure.php
TLDR
This file contains the InvokeQueuedClosure
class which handles the execution of a closure or callback function.
Methods
handle
This method handles the execution of a closure. It takes a SerializableClosure
object and an array of arguments as parameters. It calls call_user_func
to invoke the closure with the provided arguments.
failed
This method handles a job failure. It takes a SerializableClosure
object, an array of arguments, an array of catch callbacks, and an exception object as parameters. It adds the exception to the arguments array and then invokes each catch callback with the updated arguments.
<?php
namespace Illuminate\Events;
class InvokeQueuedClosure
{
/**
* Handle the event.
*
* @param \Laravel\SerializableClosure\SerializableClosure $closure
* @param array $arguments
* @return void
*/
public function handle($closure, array $arguments)
{
call_user_func($closure->getClosure(), ...$arguments);
}
/**
* Handle a job failure.
*
* @param \Laravel\SerializableClosure\SerializableClosure $closure
* @param array $arguments
* @param array $catchCallbacks
* @param \Throwable $exception
* @return void
*/
public function failed($closure, array $arguments, array $catchCallbacks, $exception)
{
$arguments[] = $exception;
collect($catchCallbacks)->each->__invoke(...$arguments);
}
}