Example #1
0
 /**
  * Sets the properties of the current object to the value they had at a specific version
  *
  * @param ChildOrderVersion $version The version object to use
  * @param ConnectionInterface   $con the connection to use
  * @param array                 $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
  *
  * @return ChildOrder The current object (for fluent API support)
  */
 public function populateFromVersion($version, $con = null, &$loadedObjects = array())
 {
     $loadedObjects['ChildOrder'][$version->getId()][$version->getVersion()] = $this;
     $this->setId($version->getId());
     $this->setRef($version->getRef());
     $this->setCustomerId($version->getCustomerId());
     $this->setInvoiceOrderAddressId($version->getInvoiceOrderAddressId());
     $this->setDeliveryOrderAddressId($version->getDeliveryOrderAddressId());
     $this->setInvoiceDate($version->getInvoiceDate());
     $this->setCurrencyId($version->getCurrencyId());
     $this->setCurrencyRate($version->getCurrencyRate());
     $this->setTransactionRef($version->getTransactionRef());
     $this->setDeliveryRef($version->getDeliveryRef());
     $this->setInvoiceRef($version->getInvoiceRef());
     $this->setDiscount($version->getDiscount());
     $this->setPostage($version->getPostage());
     $this->setPostageTax($version->getPostageTax());
     $this->setPostageTaxRuleTitle($version->getPostageTaxRuleTitle());
     $this->setPaymentModuleId($version->getPaymentModuleId());
     $this->setDeliveryModuleId($version->getDeliveryModuleId());
     $this->setStatusId($version->getStatusId());
     $this->setLangId($version->getLangId());
     $this->setCartId($version->getCartId());
     $this->setCreatedAt($version->getCreatedAt());
     $this->setUpdatedAt($version->getUpdatedAt());
     $this->setVersion($version->getVersion());
     $this->setVersionCreatedAt($version->getVersionCreatedAt());
     $this->setVersionCreatedBy($version->getVersionCreatedBy());
     if ($fkValue = $version->getCustomerId()) {
         if (isset($loadedObjects['ChildCustomer']) && isset($loadedObjects['ChildCustomer'][$fkValue]) && isset($loadedObjects['ChildCustomer'][$fkValue][$version->getCustomerIdVersion()])) {
             $related = $loadedObjects['ChildCustomer'][$fkValue][$version->getCustomerIdVersion()];
         } else {
             $related = new ChildCustomer();
             $relatedVersion = ChildCustomerVersionQuery::create()->filterById($fkValue)->filterByVersion($version->getCustomerIdVersion())->findOne($con);
             $related->populateFromVersion($relatedVersion, $con, $loadedObjects);
             $related->setNew(false);
         }
         $this->setCustomer($related);
     }
     return $this;
 }
Example #2
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see CustomerVersion::setDeleted()
  * @see CustomerVersion::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(CustomerVersionTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildCustomerVersionQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #3
0
 /**
  * retrieve the last $number versions.
  *
  * @param Integer $number the number of record to return.
  * @return PropelCollection|array \Thelia\Model\CustomerVersion[] List of \Thelia\Model\CustomerVersion objects
  */
 public function getLastVersions($number = 10, $criteria = null, $con = null)
 {
     $criteria = ChildCustomerVersionQuery::create(null, $criteria);
     $criteria->addDescendingOrderByColumn(CustomerVersionTableMap::VERSION);
     $criteria->limit($number);
     return $this->getCustomerVersions($criteria, $con);
 }
 /**
  * Performs an INSERT on the database, given a CustomerVersion or Criteria object.
  *
  * @param mixed               $criteria Criteria or CustomerVersion object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(CustomerVersionTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from CustomerVersion object
     }
     // Set the correct dbName
     $query = CustomerVersionQuery::create()->mergeWith($criteria);
     try {
         // use transaction because $criteria could contain info
         // for more than one table (I guess, conceivably)
         $con->beginTransaction();
         $pk = $query->doInsert($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     return $pk;
 }