public function addForObject($action, $object, $delay = null, $priority = null, $ttr = null)
    {
        $executor = $this->getExecutor($action);

        if (!$executor instanceof ObjectPayloadInterface) {
            throw new \LogicException(
                sprintf(
                    'The executor for action "%s" cannot be used for objects. Implement the ObjectPayloadInterface in class "%s" to enable this.',
                    $action,
                    get_class($executor)
                )
            );
        }

        if (!$executor->supportsObject($object)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'The executor for action "%s" does not support %s objects',
                    $action,
                    get_class($object)
                )
            );
        }

        $payload = $executor->getObjectPayload($object);

        return $this->add($action, $payload, $delay, $priority, $ttr);
    }
public function addForObject($action, $object, $delay = null, $priority = null, $ttr = null)
    {
        $executor = $this->getExecutor($action);

        if (!$executor instanceof ObjectPayloadInterface) {
            throw new \LogicException(
                sprintf(
                    'The executor for action "%s" cannot be used for objects. Implement the ObjectPayloadInterface in class "%s" to enable this.',
                    $action,
                    get_class($executor)
                )
            );
        }

        if (!$executor->supportsObject($object)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'The executor for action "%s" does not support %s objects',
                    $action,
                    get_class($object)
                )
            );
        }

        $payload = $executor->getObjectPayload($object);

        return $this->add($action, $payload, $delay, $priority, $ttr);
    }
public function addForObject ( $ action , $ object , $ delay = null , $ priority = null , $ ttr = null ) { $ executor = $ this -> getExecutor ( $ action ) ; if ( ! $ executor instanceof ObjectPayloadInterface ) { throw new \ LogicException ( sprintf ( 'The executor for action "%s" cannot be used for objects. Implement the ObjectPayloadInterface in class "%s" to enable this.' , $ action , get_class ( $ executor ) ) ) ; } if ( ! $ executor -> supportsObject ( $ object ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The executor for action "%s" does not support %s objects' , $ action , get_class ( $ object ) ) ) ; } $ payload = $ executor -> getObjectPayload ( $ object ) ; return $ this -> add ( $ action , $ payload , $ delay , $ priority , $ ttr ) ; }
Adds a job to the queue for an object.

@param string     $action   The action
@param object     $object   The object to add a job for
@param string|int $delay    The delay after which the job can be reserved.
Can be a number of seconds, or a date-diff
string relative from now, like "10 seconds".
@param int        $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
@param int        $ttr      Time To Run: seconds a job can be reserved for

@throws \LogicException           If the executor does not accepts objects as payloads
@throws \InvalidArgumentException If the executor does not accept the given object
@throws \InvalidArgumentException When the action is not defined

@return int The job id
Adds a job to the queue for an object .