setRestart example

/** * @return \Generator<MessageContext, object> */
    public function getMessages(): \Generator
    {
        $checkpoint = $this->checkpoint();

        if ($this->schedule?->shouldRestart()) {
            unset($this->triggerHeap);
            $this->waitUntil = new \DateTimeImmutable('@0');
            $this->schedule->setRestart(false);
        }

        if (!$this->waitUntil
            || $this->waitUntil > ($now = $this->clock->now())
            || !$checkpoint->acquire($now)
        ) {
            return;
        }

        $startTime = $checkpoint->from();
        $lastTime = $checkpoint->time();
        
public static function with(RecurringMessage $message, RecurringMessage ...$messages)static
    {
        return static::doAdd(new self()$message, ...$messages);
    }

    /** * @return $this */
    public function add(RecurringMessage $message, RecurringMessage ...$messages)static
    {
        $this->setRestart(true);

        return static::doAdd($this$message, ...$messages);
    }

    private static function doAdd(self $schedule, RecurringMessage $message, RecurringMessage ...$messages)static
    {
        foreach ([$message, ...$messages] as $m) {
            if (isset($schedule->messages[$m->getId()])) {
                throw new LogicException('Duplicated schedule message.');
            }

            
Home | Imprint | This part of the site doesn't use cookies.