public static function findByCountryAndState(Country $country, State $state = null) { $response = null; if (null !== $state) { $countryAreaList = self::create()->filterByCountryId($country->getId())->filterByStateId($state->getId())->find(); if (count($countryAreaList) > 0) { return $countryAreaList; } } $countryAreaList = self::create()->filterByCountryId($country->getId())->filterByStateId(null)->find(); return $countryAreaList; }
/** * @param CountryModel $country * @depends testUpdate */ public function testDelete(CountryModel $country) { $event = new CountryDeleteEvent($country->getId()); $action = new Country(); $action->delete($event, null, $this->getMockEventDispatcher()); $deletedCountry = $event->getCountry(); $this->assertInstanceOf('Thelia\\Model\\Country', $deletedCountry); $this->assertTrue($deletedCountry->isDeleted()); }
/** * Check if a delivery module is suitable for the given country. * * @param Country $country * @param Module $module * @return null|AreaDeliveryModule * @throws \Propel\Runtime\Exception\PropelException */ public function findByCountryAndModule(Country $country, Module $module) { $response = null; $countryInAreaList = CountryAreaQuery::create()->filterByCountryId($country->getId())->find(); foreach ($countryInAreaList as $countryInArea) { $response = $this->filterByAreaId($countryInArea->getAreaId())->filterByModule($module)->findOne(); if ($response !== null) { break; } } return $response; }
public function loadTaxRule(TaxRule $taxRule, Country $country, Product $product) { $this->product = null; $this->country = null; $this->taxRulesCollection = null; if ($taxRule->getId() === null) { throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); } if ($country->getId() === null) { throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); } if ($product->getId() === null) { throw new TaxEngineException('Product id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_PRODUCT); } $this->country = $country; $this->product = $product; $key = $product->getTaxRule()->getId() . '-' . $country->getId(); if (!isset(self::$taxRulesMap[$key])) { self::$taxRulesMap[$key] = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); } $this->taxRulesCollection = self::$taxRulesMap[$key]; return $this; }
/** * @param TaxRule $taxRule * @param Country $country * * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection */ public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country, State $state = null) { $key = sprintf('%s-%s-%s', $taxRule->getId(), $country->getId(), $state !== null ? $state->getId() : 0); if (array_key_exists($key, self::$caches)) { return self::$caches[$key]; } $taxRuleQuery = TaxRuleCountryQuery::create()->filterByCountry($country, Criteria::EQUAL)->filterByTaxRuleId($taxRule->getId()); if (null !== $state) { $taxRuleCount = $taxRuleQuery->filterByStateId($state->getId(), Criteria::EQUAL)->count(); if (0 === $taxRuleCount) { $taxRuleQuery->filterByStateId(null, Criteria::EQUAL); } } $search = TaxQuery::create()->filterByTaxRuleCountry($taxRuleQuery->find())->withColumn(TaxRuleCountryTableMap::POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)->orderBy(self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION, Criteria::ASC); return self::$caches[$key] = $search->find(); }
public function loadTaxRuleWithoutProduct(TaxRule $taxRule, Country $country) { $this->product = null; $this->country = null; $this->taxRulesCollection = null; if ($taxRule->getId() === null) { throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); } if ($country->getId() === null) { throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); } $this->country = $country; $this->product = new Product(); $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); return $this; }
/** * Filter the query by a related \Thelia\Model\Country object * * @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByCountry($country, $comparison = null) { if ($country instanceof \Thelia\Model\Country) { return $this->addUsingAlias(CountryI18nTableMap::ID, $country->getId(), $comparison); } elseif ($country instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(CountryI18nTableMap::ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCountry() only accepts arguments of type \\Thelia\\Model\\Country or Collection'); } }
/** * Declares an association between this object and a ChildCountry object. * * @param ChildCountry $v * @return \Thelia\Model\OrderAddress The current object (for fluent API support) * @throws PropelException */ public function setCountry(ChildCountry $v = null) { if ($v === null) { $this->setCountryId(NULL); } else { $this->setCountryId($v->getId()); } $this->aCountry = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildCountry object, it will not be re-added. if ($v !== null) { $v->addOrderAddress($this); } return $this; }
/** * Exclude object from result * * @param ChildCountry $country Object to remove from the list of results * * @return ChildCountryQuery The current query, for fluid interface */ public function prune($country = null) { if ($country) { $this->addUsingAlias(CountryTableMap::ID, $country->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Returns the object ID from the object * * @param \Thelia\Model\Country $object */ protected function getObjectId($object) { return $object->getId(); }