protected function parseExportCategories(SimpleXMLElement $xml) { if (false === ($exportCategories = $xml->xpath('//config:export_categories/config:export_category'))) { return; } $con = Propel::getWriteConnection(ExportCategoryTableMap::DATABASE_NAME); $con->beginTransaction(); try { /** @var SimpleXMLElement $exportCategory */ foreach ($exportCategories as $exportCategory) { $id = (string) $exportCategory->getAttributeAsPhp("id"); $exportCategoryModel = ExportCategoryQuery::create()->findOneByRef($id); if ($exportCategoryModel === null) { $exportCategoryModel = new ExportCategory(); $exportCategoryModel->setRef($id)->save($con); } /** @var SimpleXMLElement $child */ foreach ($exportCategory->children() as $child) { $locale = (string) $child->getAttributeAsPhp("locale"); $value = (string) $child; $exportCategoryModel->setLocale($locale)->setTitle($value)->save($con); } } $con->commit(); } catch (\Exception $e) { $con->rollBack(); Tlog::getInstance()->error($e->getMessage()); } }
/** * Filter the query by a related \Thelia\Model\ExportCategory object * * @param \Thelia\Model\ExportCategory|ObjectCollection $exportCategory The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildExportCategoryI18nQuery The current query, for fluid interface */ public function filterByExportCategory($exportCategory, $comparison = null) { if ($exportCategory instanceof \Thelia\Model\ExportCategory) { return $this->addUsingAlias(ExportCategoryI18nTableMap::ID, $exportCategory->getId(), $comparison); } elseif ($exportCategory instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(ExportCategoryI18nTableMap::ID, $exportCategory->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByExportCategory() only accepts arguments of type \\Thelia\\Model\\ExportCategory or Collection'); } }
/** * Declares an association between this object and a ChildExportCategory object. * * @param ChildExportCategory $v * @return \Thelia\Model\Export The current object (for fluent API support) * @throws PropelException */ public function setExportCategory(ChildExportCategory $v = null) { if ($v === null) { $this->setExportCategoryId(NULL); } else { $this->setExportCategoryId($v->getId()); } $this->aExportCategory = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildExportCategory object, it will not be re-added. if ($v !== null) { $v->addExport($this); } return $this; }
/** * Exclude object from result * * @param ChildExportCategory $exportCategory Object to remove from the list of results * * @return ChildExportCategoryQuery The current query, for fluid interface */ public function prune($exportCategory = null) { if ($exportCategory) { $this->addUsingAlias(ExportCategoryTableMap::ID, $exportCategory->getId(), Criteria::NOT_EQUAL); } return $this; }