/** * {@inheritdoc} */ public function enqueue(JobInterface $job, $channel = QueueInterface::MAIN_CHANNEL) { $job_data = $job->getData(); $extract = []; foreach ($this->extract_properties_to_fields as $property) { $extract['`' . $property . '`'] = $this->connection->escapeValue($job->getData()[$property]); } $extract_fields = empty($extract) ? '' : ', ' . implode(', ', array_keys($extract)); $extract_values = empty($extract) ? '' : ', ' . implode(', ', $extract); $available_at_timestamp = date('Y-m-d H:i:s', time() + $job->getFirstJobDelay()); $this->connection->execute('INSERT INTO `' . self::JOBS_TABLE_NAME . '` (`type`, `channel`, `batch_id`, `data`, `available_at`' . $extract_fields . ') VALUES (?, ?, ?, ?, ?' . $extract_values . ')', get_class($job), $channel, $job->getBatchId(), json_encode($job_data), $available_at_timestamp); $job_id = $this->connection->lastInsertId(); if ($this->log) { $this->log->info('Job #{job_id} ({job_type}) enqueued. Becomes available at {available_at}', ['job_id' => $job_id, 'job_type' => get_class($job), 'available_at' => $available_at_timestamp]); } return $job_id; }