예제 #1
0
 protected function parseImportCategories(SimpleXMLElement $xml)
 {
     if (false === ($importCategories = $xml->xpath('//config:import_categories/config:import_category'))) {
         return;
     }
     $con = Propel::getWriteConnection(ImportCategoryTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         /** @var SimpleXMLElement $importCategory */
         foreach ($importCategories as $importCategory) {
             $id = (string) $importCategory->getAttributeAsPhp("id");
             $importCategoryModel = ImportCategoryQuery::create()->findOneByRef($id);
             if ($importCategoryModel === null) {
                 $importCategoryModel = new ImportCategory();
                 $importCategoryModel->setRef($id)->save($con);
             }
             /** @var SimpleXMLElement $child */
             foreach ($importCategory->children() as $child) {
                 $locale = (string) $child->getAttributeAsPhp("locale");
                 $value = (string) $child;
                 $importCategoryModel->setLocale($locale)->setTitle($value)->save($con);
             }
         }
         $con->commit();
     } catch (\Exception $e) {
         $con->rollBack();
         Tlog::getInstance()->error($e->getMessage());
     }
 }
예제 #2
0
 /**
  * Filter the query by a related \Thelia\Model\ImportCategory object
  *
  * @param \Thelia\Model\ImportCategory|ObjectCollection $importCategory The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildImportCategoryI18nQuery The current query, for fluid interface
  */
 public function filterByImportCategory($importCategory, $comparison = null)
 {
     if ($importCategory instanceof \Thelia\Model\ImportCategory) {
         return $this->addUsingAlias(ImportCategoryI18nTableMap::ID, $importCategory->getId(), $comparison);
     } elseif ($importCategory instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ImportCategoryI18nTableMap::ID, $importCategory->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByImportCategory() only accepts arguments of type \\Thelia\\Model\\ImportCategory or Collection');
     }
 }
예제 #3
0
파일: Import.php 프로젝트: margery/thelia
 /**
  * Declares an association between this object and a ChildImportCategory object.
  *
  * @param                  ChildImportCategory $v
  * @return                 \Thelia\Model\Import The current object (for fluent API support)
  * @throws PropelException
  */
 public function setImportCategory(ChildImportCategory $v = null)
 {
     if ($v === null) {
         $this->setImportCategoryId(NULL);
     } else {
         $this->setImportCategoryId($v->getId());
     }
     $this->aImportCategory = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildImportCategory object, it will not be re-added.
     if ($v !== null) {
         $v->addImport($this);
     }
     return $this;
 }
예제 #4
0
 /**
  * Exclude object from result
  *
  * @param   ChildImportCategory $importCategory Object to remove from the list of results
  *
  * @return ChildImportCategoryQuery The current query, for fluid interface
  */
 public function prune($importCategory = null)
 {
     if ($importCategory) {
         $this->addUsingAlias(ImportCategoryTableMap::ID, $importCategory->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }