public static function create($target = null, $method = null, array $args = null, $type = null)
 {
     $request = new self();
     $request->setTarget($target);
     $request->setMethod($method);
     $request->setArgs($args);
     $request->setType($type);
     return $request;
 }
    /**
     * Duplicates a job with similar properties to the original.
     *
     * @return NineThousand\Jobqueue\Vendor\Doctrine\Adapter\Job\DoctrineJobAdapter
     */
    public function spawn()
    {
        $entity = new JobEntity;
        $entity->setRetry($this->_jobEntity->getRetry());
        $entity->setCooldown($this->_jobEntity->getCooldown());
        $entity->setMaxRetries($this->_jobEntity->getMaxRetries());
        $entity->setAttempts(0);
        $entity->setExecutable($this->_jobEntity->getExecutable());
        $entity->setType($this->_jobEntity->getType());
        $entity->setStatus(null);
        $entity->setCreateDate(new \DateTime("now"));
        $entity->setLastRunDate(null);
        $entity->setActive(1);
        $entity->setSchedule(null);
        $entity->setParent($this->_jobEntity->getId());
        $this->_em->persist($entity);
        $this->_em->flush();

        //instantiate duplicated job adapter and set params, args, tags
        $jobAdapter = new self($this->_options, $entity, $this->_em, $this->_logger);
        if (count($params = $this->getParams())) $jobAdapter->setParams($params);
        if (count($args = $this->getArgs())) $jobAdapter->setArgs($args);
        if (count($tags = $this->getTags())) $jobAdapter->setTags($tags);
        
        return $jobAdapter;
    }