feature to pause events
This commit is contained in:
parent
9bbab6afeb
commit
b5379f0f0c
2 changed files with 28 additions and 0 deletions
|
@ -46,6 +46,7 @@ class Event
|
||||||
protected array $context = [];
|
protected array $context = [];
|
||||||
protected ?Document $project = null;
|
protected ?Document $project = null;
|
||||||
protected ?Document $user = null;
|
protected ?Document $user = null;
|
||||||
|
protected bool $paused = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $queue
|
* @param string $queue
|
||||||
|
@ -263,6 +264,10 @@ class Event
|
||||||
*/
|
*/
|
||||||
public function trigger(): string|bool
|
public function trigger(): string|bool
|
||||||
{
|
{
|
||||||
|
if($this->paused) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return Resque::enqueue($this->queue, $this->class, [
|
return Resque::enqueue($this->queue, $this->class, [
|
||||||
'project' => $this->project,
|
'project' => $this->project,
|
||||||
'user' => $this->user,
|
'user' => $this->user,
|
||||||
|
@ -468,4 +473,22 @@ class Event
|
||||||
*/
|
*/
|
||||||
return \array_values($events);
|
return \array_values($events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of paused
|
||||||
|
*/
|
||||||
|
public function isPaused(): bool
|
||||||
|
{
|
||||||
|
return $this->paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of paused
|
||||||
|
*/
|
||||||
|
public function setPaused(bool $paused): self
|
||||||
|
{
|
||||||
|
$this->paused = $paused;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,10 @@ class Func extends Event
|
||||||
*/
|
*/
|
||||||
public function trigger(): string|bool
|
public function trigger(): string|bool
|
||||||
{
|
{
|
||||||
|
if($this->paused) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$client = new Client($this->queue, $this->connection);
|
$client = new Client($this->queue, $this->connection);
|
||||||
|
|
||||||
$events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null;
|
$events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null;
|
||||||
|
@ -174,6 +178,7 @@ class Func extends Event
|
||||||
$this->payload = $event->getPayload();
|
$this->payload = $event->getPayload();
|
||||||
$this->event = $event->getEvent();
|
$this->event = $event->getEvent();
|
||||||
$this->params = $event->getParams();
|
$this->params = $event->getParams();
|
||||||
|
$this->paused = $event->isPaused();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue