PartKeepr\CronLoggerBundle\Entity\CronLogger::setCronjob PHP Method

setCronjob() public method

Sets the cronjob for this entry.
public setCronjob ( string $cronjob )
$cronjob string the title for this entry
    public function setCronjob($cronjob)
    {
        $this->cronjob = $cronjob;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Marks a specific cronjob as ran.
  *
  * @param string $cronjob The name of the cronjob
  *
  * @return CronLogger The cron logger entity
  */
 public function markCronRun($cronjob)
 {
     $dql = "SELECT c FROM PartKeepr\\CronLoggerBundle\\Entity\\CronLogger c WHERE c.cronjob = :cronjob";
     $query = $this->entityManager->createQuery($dql);
     $query->setParameter('cronjob', $cronjob);
     try {
         $result = $query->getSingleResult();
     } catch (\Exception $e) {
         $result = new CronLogger();
         $result->setCronjob($cronjob);
         $this->entityManager->persist($result);
     }
     $result->setLastRunDate(new \DateTime());
     $this->entityManager->flush();
     return $result;
 }