| @@ 189-216 (lines=28) @@ | ||
| 186 | * |
|
| 187 | * @return int The job id |
|
| 188 | */ |
|
| 189 | public function addForObject($action, $object, $delay = null, $priority = null, $ttr = null) |
|
| 190 | { |
|
| 191 | $executor = $this->executorPool->getExecutor($action); |
|
| 192 | ||
| 193 | if (!$executor instanceof ObjectPayloadInterface) { |
|
| 194 | throw new \LogicException( |
|
| 195 | sprintf( |
|
| 196 | 'The executor for action "%s" cannot be used for objects. Implement the ObjectPayloadInterface in class "%s" to enable this.', |
|
| 197 | $action, |
|
| 198 | get_class($executor) |
|
| 199 | ) |
|
| 200 | ); |
|
| 201 | } |
|
| 202 | ||
| 203 | if (!$executor->supportsObject($object)) { |
|
| 204 | throw new InvalidArgumentException( |
|
| 205 | sprintf( |
|
| 206 | 'The executor for action "%s" does not support %s objects', |
|
| 207 | $action, |
|
| 208 | get_class($object) |
|
| 209 | ) |
|
| 210 | ); |
|
| 211 | } |
|
| 212 | ||
| 213 | $payload = $executor->getObjectPayload($object); |
|
| 214 | ||
| 215 | return $this->add($action, $payload, $delay, $priority, $ttr); |
|
| 216 | } |
|
| 217 | ||
| 218 | /** |
|
| 219 | * Reschedules a job. |
|
| @@ 277-304 (lines=28) @@ | ||
| 274 | * |
|
| 275 | * @return int The job id |
|
| 276 | */ |
|
| 277 | public function addForObject($action, $object, $delay = null, $priority = null, $ttr = null) |
|
| 278 | { |
|
| 279 | $executor = $this->getExecutor($action); |
|
| 280 | ||
| 281 | if (!$executor instanceof ObjectPayloadInterface) { |
|
| 282 | throw new \LogicException( |
|
| 283 | sprintf( |
|
| 284 | 'The executor for action "%s" cannot be used for objects. Implement the ObjectPayloadInterface in class "%s" to enable this.', |
|
| 285 | $action, |
|
| 286 | get_class($executor) |
|
| 287 | ) |
|
| 288 | ); |
|
| 289 | } |
|
| 290 | ||
| 291 | if (!$executor->supportsObject($object)) { |
|
| 292 | throw new \InvalidArgumentException( |
|
| 293 | sprintf( |
|
| 294 | 'The executor for action "%s" does not support %s objects', |
|
| 295 | $action, |
|
| 296 | get_class($object) |
|
| 297 | ) |
|
| 298 | ); |
|
| 299 | } |
|
| 300 | ||
| 301 | $payload = $executor->getObjectPayload($object); |
|
| 302 | ||
| 303 | return $this->add($action, $payload, $delay, $priority, $ttr); |
|
| 304 | } |
|
| 305 | ||
| 306 | /** |
|
| 307 | * Reschedules a job. |
|