コード例 #1
0
ファイル: CustomerTitle.php プロジェクト: margery/thelia
 protected function createOrUpdate(CustomerTitleEvent $event, CustomerTitleModel $customerTitle)
 {
     $con = Propel::getConnection(CustomerTitleTableMap::DATABASE_NAME);
     $con->beginTransaction();
     $i18n = $customerTitle->getTranslation($event->getLocale(), $con);
     try {
         $i18n->setShort($event->getShort())->setLong($event->getLong());
         $customerTitle->save($con);
         if ($event->isDefault()) {
             $customerTitle->toggleDefault($con);
             $event->setDefault(false);
         }
         $con->commit();
     } catch (\Exception $e) {
         $con->rollBack();
         throw $e;
     }
     $event->setCustomerTitle($customerTitle);
 }
コード例 #2
0
 /**
  * Filter the query by a related \Thelia\Model\CustomerTitle object
  *
  * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
  */
 public function filterByCustomerTitle($customerTitle, $comparison = null)
 {
     if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
         return $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $customerTitle->getId(), $comparison);
     } elseif ($customerTitle instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCustomerTitle() only accepts arguments of type \\Thelia\\Model\\CustomerTitle or Collection');
     }
 }
コード例 #3
0
ファイル: CustomerTitleI18n.php プロジェクト: shirone/thelia
 /**
  * Declares an association between this object and a ChildCustomerTitle object.
  *
  * @param                  ChildCustomerTitle $v
  * @return                 \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCustomerTitle(ChildCustomerTitle $v = null)
 {
     if ($v === null) {
         $this->setId(NULL);
     } else {
         $this->setId($v->getId());
     }
     $this->aCustomerTitle = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildCustomerTitle object, it will not be re-added.
     if ($v !== null) {
         $v->addCustomerTitleI18n($this);
     }
     return $this;
 }
コード例 #4
0
ファイル: CustomerTitleQuery.php プロジェクト: margery/thelia
 /**
  * Exclude object from result
  *
  * @param   ChildCustomerTitle $customerTitle Object to remove from the list of results
  *
  * @return ChildCustomerTitleQuery The current query, for fluid interface
  */
 public function prune($customerTitle = null)
 {
     if ($customerTitle) {
         $this->addUsingAlias(CustomerTitleTableMap::ID, $customerTitle->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
コード例 #5
0
ファイル: CustomersImport.php プロジェクト: JumBay/ImportT1
 public function importCustomerTitle()
 {
     $con = Propel::getConnection(CustomerTitleTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         CustomerTitleQuery::create()->deleteAll();
         $hdl = $this->t1db->query("select * from raison order by classement");
         while ($hdl && ($raison = $this->t1db->fetch_object($hdl))) {
             $ct = new CustomerTitle();
             $descs = $this->t1db->query_list("select * from raisondesc where raison = ? order by lang asc", array($raison->id));
             foreach ($descs as $desc) {
                 $lang = $this->getT2Lang($desc->lang);
                 $ct->setLocale($lang->getLocale())->setByDefault($raison->defaut ? true : false)->setPosition($raison->classement)->setLong($desc->long)->setShort($desc->court)->save();
             }
         }
         $con->commit();
     } catch (\Exception $ex) {
         $con->rollBack();
         Tlog::getInstance()->error("Failed to import Thelia 1 customer titles (not a problem for Thelia 1.4.x). Cause: " . $ex->getMessage());
     }
 }