mirror of
https://github.com/flarum/core.git
synced 2025-08-05 07:57:46 +02:00
[1.x] [extensibility] feat: allow classes that extends AbstractJob
to be placed on a specified queue (#4026)
* feat: allow classes that extends AbstractJob to be placed on a specific queue * Apply fixes from StyleCI * php 7.3 compat * Apply fixes from StyleCI * change to to avoid conflicts with extensions that already do this * chore: add docblock explaining that this solution only works for Redis queues * Apply fixes from StyleCI * chore: update docblock * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
@@ -47,6 +47,8 @@ class SendMentionsNotificationsJob extends AbstractJob
|
|||||||
|
|
||||||
public function __construct(CommentPost $post, array $userMentions, array $postMentions, array $groupMentions)
|
public function __construct(CommentPost $post, array $userMentions, array $postMentions, array $groupMentions)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->post = $post;
|
$this->post = $post;
|
||||||
$this->userMentions = $userMentions;
|
$this->userMentions = $userMentions;
|
||||||
$this->postMentions = $postMentions;
|
$this->postMentions = $postMentions;
|
||||||
|
@@ -32,6 +32,8 @@ class ComposerCommandJob extends AbstractJob implements ShouldBeUnique
|
|||||||
|
|
||||||
public function __construct(AbstractActionCommand $command, string $phpVersion)
|
public function __construct(AbstractActionCommand $command, string $phpVersion)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->command = $command;
|
$this->command = $command;
|
||||||
$this->phpVersion = $phpVersion;
|
$this->phpVersion = $phpVersion;
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,8 @@ class SendPusherNotificationsJob extends AbstractJob
|
|||||||
|
|
||||||
public function __construct(BlueprintInterface $blueprint, array $recipients)
|
public function __construct(BlueprintInterface $blueprint, array $recipients)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->blueprint = $blueprint;
|
$this->blueprint = $blueprint;
|
||||||
$this->recipients = $recipients;
|
$this->recipients = $recipients;
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,8 @@ class SendRawEmailJob extends AbstractJob
|
|||||||
|
|
||||||
public function __construct(string $email, string $subject, string $body)
|
public function __construct(string $email, string $subject, string $body)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
|
@@ -28,6 +28,8 @@ class SendEmailNotificationJob extends AbstractJob
|
|||||||
|
|
||||||
public function __construct(MailableInterface $blueprint, User $recipient)
|
public function __construct(MailableInterface $blueprint, User $recipient)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->blueprint = $blueprint;
|
$this->blueprint = $blueprint;
|
||||||
$this->recipient = $recipient;
|
$this->recipient = $recipient;
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,8 @@ class SendNotificationsJob extends AbstractJob
|
|||||||
|
|
||||||
public function __construct(BlueprintInterface $blueprint, array $recipients = [])
|
public function __construct(BlueprintInterface $blueprint, array $recipients = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->blueprint = $blueprint;
|
$this->blueprint = $blueprint;
|
||||||
$this->recipients = $recipients;
|
$this->recipients = $recipients;
|
||||||
}
|
}
|
||||||
|
@@ -19,4 +19,20 @@ class AbstractJob implements ShouldQueue
|
|||||||
use InteractsWithQueue;
|
use InteractsWithQueue;
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the queue on which the job should be placed.
|
||||||
|
*
|
||||||
|
* This is only effective on jobs that extend `\Flarum\Queue\AbstractJob` and dispatched via Redis.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
public static $sendOnQueue = null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if (static::$sendOnQueue) {
|
||||||
|
$this->onQueue(static::$sendOnQueue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@ class RequestPasswordResetJob extends AbstractJob
|
|||||||
|
|
||||||
public function __construct(string $email)
|
public function __construct(string $email)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user