* Build the arguments for adding a job. * * @param Job $job * @return array */
(Job $job)
| 175 | * @return array<mixed> |
| 176 | */ |
| 177 | public function addJobArgs(Job $job): array |
| 178 | { |
| 179 | $jsonData = json_encode($job->data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
| 180 | $packedOpts = $this->packer->pack($job->opts->toArray()); |
| 181 | |
| 182 | $parent = $job->parent; |
| 183 | $parentKey = $job->parentKey; |
| 184 | |
| 185 | // Build deduplication key if deduplication ID exists |
| 186 | $deduplicationKey = null; |
| 187 | $deduplication = $job->opts->deduplication; |
| 188 | if ($deduplication !== null && isset($deduplication['id']) && $deduplication['id'] !== '') { |
| 189 | $deduplicationKey = $this->keys[''] . 'de:' . $deduplication['id']; |
| 190 | } |
| 191 | |
| 192 | $packedArgs = $this->packer->pack([ |
| 193 | $this->keys[''], |
| 194 | $job->id ?? '', |
| 195 | $job->name, |
| 196 | $job->timestamp, |
| 197 | $job->parentKey, |
| 198 | $parentKey !== null ? "{$parentKey}:dependencies" : null, |
| 199 | $parent, |
| 200 | null, // repeatJobKey (not yet supported in PHP) |
| 201 | $deduplicationKey, |
| 202 | ]); |
| 203 | |
| 204 | return [$packedArgs, $jsonData, $packedOpts]; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Add a job to the queue. |
no test coverage detected