/**
  * @see sfTask
  */
 protected function executeTask($env, $arguments = array(), $options = array())
 {
     $tasks = PcTaskPeer::doSelect(new Criteria());
     foreach ($tasks as $task) {
         $contextsBlob = $task->getContexts();
         if (strlen($contextsBlob) > 0) {
             $contextIds = explode(',', $contextsBlob);
             foreach ($contextIds as $contextId) {
                 // checking the context exists
                 $context = PcUsersContextsPeer::retrieveByPK($contextId);
                 if (is_object($context)) {
                     $tasksContextsEntry = new PcTasksContexts();
                     $tasksContextsEntry->setTaskId($task->getId())->setUsersContextsId($contextId)->save();
                 }
             }
         }
     }
     echo "\nDone migration to 1.6.7 \n\n";
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PcTasksContexts $value A PcTasksContexts object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PcTasksContexts $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Exemplo n.º 3
0
 /**
  * It is called by the save() method.
  * It populates the pc_tasks_contexts table.
  *
  * @return void
  */
 public function alignTasksContextsTable()
 {
     $contexts = $this->getContexts();
     // first, let's delete all the pre-existing contexts from this task
     $c = new Criteria();
     $c->add(PcTasksContextsPeer::TASK_ID, $this->getId());
     PcTasksContextsPeer::doDelete($c);
     $contexts = $this->getContexts();
     $contextIds = PcUtils::explodeWithEmptyInputDetection(',', $contexts);
     if (count($contextIds)) {
         foreach ($contextIds as $contextId) {
             if (is_numeric($contextId)) {
                 $record = new PcTasksContexts();
                 $record->setTaskId($this->getId())->setUsersContextsId($contextId)->save();
             }
         }
     }
 }