Skip to content

Commit

Permalink
Allow the Batch and Chain onQueue method to accept Backed Enums (#53359)
Browse files Browse the repository at this point in the history
  • Loading branch information
onlime authored Oct 31, 2024
1 parent 6720fb1 commit 01c2659
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/Illuminate/Bus/PendingBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Laravel\SerializableClosure\SerializableClosure;
use Throwable;

use function Illuminate\Support\enum_value;

class PendingBatch
{
use Conditionable;
Expand Down Expand Up @@ -261,12 +263,12 @@ public function connection()
/**
* Specify the queue that the batched jobs should run on.
*
* @param string $queue
* @param \BackedEnum|string|null $queue
* @return $this
*/
public function onQueue(string $queue)
public function onQueue($queue)
{
$this->options['queue'] = $queue;
$this->options['queue'] = enum_value($queue);

return $this;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Events/QueuedClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Closure;
use Laravel\SerializableClosure\SerializableClosure;

use function Illuminate\Support\enum_value;

class QueuedClosure
{
/**
Expand Down Expand Up @@ -69,12 +71,12 @@ public function onConnection($connection)
/**
* Set the desired queue for the job.
*
* @param string|null $queue
* @param \BackedEnum|string|null $queue
* @return $this
*/
public function onQueue($queue)
{
$this->queue = $queue;
$this->queue = enum_value($queue);

return $this;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Foundation/Bus/PendingChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Illuminate\Support\Traits\Conditionable;
use Laravel\SerializableClosure\SerializableClosure;

use function Illuminate\Support\enum_value;

class PendingChain
{
use Conditionable;
Expand Down Expand Up @@ -83,12 +85,12 @@ public function onConnection($connection)
/**
* Set the desired queue for the job.
*
* @param string|null $queue
* @param \BackedEnum|string|null $queue
* @return $this
*/
public function onQueue($queue)
{
$this->queue = $queue;
$this->queue = enum_value($queue);

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ protected function setGlobalToAndRemoveCcAndBcc($message)
* Queue a new mail message for sending.
*
* @param \Illuminate\Contracts\Mail\Mailable|string|array $view
* @param string|null $queue
* @param \BackedEnum|string|null $queue
* @return mixed
*
* @throws \InvalidArgumentException
Expand All @@ -486,7 +486,7 @@ public function queue($view, $queue = null)
/**
* Queue a new mail message for sending on the given queue.
*
* @param string $queue
* @param \BackedEnum|string|null $queue
* @param \Illuminate\Contracts\Mail\Mailable $view
* @return mixed
*/
Expand Down

0 comments on commit 01c2659

Please sign in to comment.