public function addQueued(string $alias): bool
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.alias = :alias')
            ->setParameter('alias', $alias)
            ->getQuery();

        try {
            /** @var EdgarCron $edgarCron */
            $edgarCron = $query->setMaxResults(1)->getOneOrNullResult();
        } catch (NonUniqueResultException $e) {
            $edgarCron = new EdgarCron();
            $edgarCron->setAlias($alias);
        }

        if (!$edgarCron) {
            $edgarCron = new EdgarCron();
            $edgarCron->setAlias($alias);
        }

        try {
            $now = new \DateTime('now');
            $edgarCron->setQueued($now);
            $edgarCron->setStarted(null);
            $edgarCron->setEnded(null);
            $edgarCron->setStatus(self::STATUS_INIT);
            $this->getEntityManager()->persist($edgarCron);
            $this->getEntityManager()->flush();
        } catch (ORMException $e) {
            return false;
        }

        return true;
    }
public function addQueued(string $alias): bool
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.alias = :alias')
            ->setParameter('alias', $alias)
            ->getQuery();

        try {
            /** @var EdgarCron $edgarCron */
            $edgarCron = $query->setMaxResults(1)->getOneOrNullResult();
        } catch (NonUniqueResultException $e) {
            $edgarCron = new EdgarCron();
            $edgarCron->setAlias($alias);
        }

        if (!$edgarCron) {
            $edgarCron = new EdgarCron();
            $edgarCron->setAlias($alias);
        }

        try {
            $now = new \DateTime('now');
            $edgarCron->setQueued($now);
            $edgarCron->setStarted(null);
            $edgarCron->setEnded(null);
            $edgarCron->setStatus(self::STATUS_INIT);
            $this->getEntityManager()->persist($edgarCron);
            $this->getEntityManager()->flush();
        } catch (ORMException $e) {
            return false;
        }

        return true;
    }
public function addQueued ( string $ alias ) : bool { $ query = $ this -> createQueryBuilder ( 'c' ) -> where ( 'c.alias = :alias' ) -> setParameter ( 'alias' , $ alias ) -> getQuery ( ) ; try { /** @var EdgarCron $edgarCron */ $ edgarCron = $ query -> setMaxResults ( 1 ) -> getOneOrNullResult ( ) ; } catch ( NonUniqueResultException $ e ) { $ edgarCron = new EdgarCron ( ) ; $ edgarCron -> setAlias ( $ alias ) ; } if ( ! $ edgarCron ) { $ edgarCron = new EdgarCron ( ) ; $ edgarCron -> setAlias ( $ alias ) ; } try { $ now = new \ DateTime ( 'now' ) ; $ edgarCron -> setQueued ( $ now ) ; $ edgarCron -> setStarted ( null ) ; $ edgarCron -> setEnded ( null ) ; $ edgarCron -> setStatus ( self :: STATUS_INIT ) ; $ this -> getEntityManager ( ) -> persist ( $ edgarCron ) ; $ this -> getEntityManager ( ) -> flush ( ) ; } catch ( ORMException $ e ) { return false ; } return true ; }
Add cron to queued.

@param string $alias cron alias

@return bool
Add cron to queued .