protected function prepareInsert(string $class, $data, array &$options = []): array
    {
        $defaults = [
            self::OPTION_AT => $this->default_at,
            self::OPTION_INTERVAL => $this->default_interval,
            self::OPTION_RETRY => $this->default_retry,
            self::OPTION_RETRY_INTERVAL => $this->default_retry_interval,
            self::OPTION_FORCE_SPAWN => false,
            self::OPTION_TIMEOUT => $this->default_timeout,
            self::OPTION_IGNORE_DATA => false,
        ];

        $options = array_merge($defaults, $options);
        $options = SchedulerValidator::validateOptions($options);

        $document = [
            'class' => $class,
            'status' => JobInterface::STATUS_WAITING,
            'created' => new UTCDateTime(),
            'started' => new UTCDateTime(),
            'ended' => new UTCDateTime(),
            'worker' => new ObjectId(),
            'data' => $data,
        ];

        if (isset($options[self::OPTION_ID])) {
            $id = $options[self::OPTION_ID];
            unset($options[self::OPTION_ID]);
            $document['_id'] = $id;
        }

        $document['options'] = $options;

        return $document;
    }
protected function prepareInsert(string $class, $data, array &$options = []): array
    {
        $defaults = [
            self::OPTION_AT => $this->default_at,
            self::OPTION_INTERVAL => $this->default_interval,
            self::OPTION_RETRY => $this->default_retry,
            self::OPTION_RETRY_INTERVAL => $this->default_retry_interval,
            self::OPTION_FORCE_SPAWN => false,
            self::OPTION_TIMEOUT => $this->default_timeout,
            self::OPTION_IGNORE_DATA => false,
        ];

        $options = array_merge($defaults, $options);
        $options = SchedulerValidator::validateOptions($options);

        $document = [
            'class' => $class,
            'status' => JobInterface::STATUS_WAITING,
            'created' => new UTCDateTime(),
            'started' => new UTCDateTime(),
            'ended' => new UTCDateTime(),
            'worker' => new ObjectId(),
            'data' => $data,
        ];

        if (isset($options[self::OPTION_ID])) {
            $id = $options[self::OPTION_ID];
            unset($options[self::OPTION_ID]);
            $document['_id'] = $id;
        }

        $document['options'] = $options;

        return $document;
    }
protected function prepareInsert ( string $ class , $ data , array & $ options = [ ] ) : array { $ defaults = [ self :: OPTION_AT => $ this -> default_at , self :: OPTION_INTERVAL => $ this -> default_interval , self :: OPTION_RETRY => $ this -> default_retry , self :: OPTION_RETRY_INTERVAL => $ this -> default_retry_interval , self :: OPTION_FORCE_SPAWN => false , self :: OPTION_TIMEOUT => $ this -> default_timeout , self :: OPTION_IGNORE_DATA => false , ] ; $ options = array_merge ( $ defaults , $ options ) ; $ options = SchedulerValidator :: validateOptions ( $ options ) ; $ document = [ 'class' => $ class , 'status' => JobInterface :: STATUS_WAITING , 'created' => new UTCDateTime ( ) , 'started' => new UTCDateTime ( ) , 'ended' => new UTCDateTime ( ) , 'worker' => new ObjectId ( ) , 'data' => $ data , ] ; if ( isset ( $ options [ self :: OPTION_ID ] ) ) { $ id = $ options [ self :: OPTION_ID ] ; unset ( $ options [ self :: OPTION_ID ] ) ; $ document [ '_id' ] = $ id ; } $ document [ 'options' ] = $ options ; return $ document ; }
Prepare insert.
Prepare insert .