Пример #1
0
 /**
  * batch getOrCreateScheduler returns a scheduler by name, create it if doesnt exist
  * 
  * @param KalturaScheduler $scheduler
  * @return Scheduler
  */
 private function getOrCreateScheduler(KalturaScheduler $scheduler)
 {
     $c = new Criteria();
     $c->add(SchedulerPeer::CONFIGURED_ID, $scheduler->configuredId);
     $schedulerDb = SchedulerPeer::doSelectOne($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
     if ($schedulerDb) {
         if (strlen($schedulerDb->getHost()) && $schedulerDb->getHost() != $scheduler->host) {
             throw new KalturaAPIException(KalturaErrors::SCHEDULER_HOST_CONFLICT, $scheduler->configuredId, $scheduler->host, $schedulerDb->getHost());
         }
         if ($schedulerDb->getName() != $scheduler->name || $schedulerDb->getHost() != $scheduler->host) {
             $schedulerDb->setName($scheduler->name);
             $schedulerDb->setHost($scheduler->host);
             $schedulerDb->save();
         }
         return $schedulerDb;
     }
     $schedulerDb = new Scheduler();
     $schedulerDb->setLastStatus(time());
     $schedulerDb->setName($scheduler->name);
     $schedulerDb->setHost($scheduler->host);
     $schedulerDb->setConfiguredId($scheduler->configuredId);
     $schedulerDb->setDescription('');
     $schedulerDb->save();
     return $schedulerDb;
 }