예제 #1
0
 /**
  * Exchange the rank of the object with the one passed as argument, and saves both objects
  *
  * @param     ChildDeliveryPeriodic $object
  * @param     ConnectionInterface $con optional connection
  *
  * @return    $this|ChildDeliveryPeriodic the current object
  *
  * @throws Exception if the database cannot execute the two updates
  */
 public function swapWith($object, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(DeliveryPeriodicTableMap::DATABASE_NAME);
     }
     $con->transaction(function () use($con, $object) {
         $oldScope = $this->getScopeValue();
         $newScope = $object->getScopeValue();
         if ($oldScope != $newScope) {
             $this->setScopeValue($newScope);
             $object->setScopeValue($oldScope);
         }
         $oldRank = $this->getSortableRank();
         $newRank = $object->getSortableRank();
         $this->setSortableRank($newRank);
         $object->setSortableRank($oldRank);
         $this->save($con);
         $object->save($con);
     });
     return $this;
 }