/** * @param StateModel $state * @depends testUpdate */ public function testDelete(StateModel $state) { $event = new StateDeleteEvent($state->getId()); $action = new State(); $action->delete($event); $deletedState = $event->getState(); $this->assertInstanceOf('Thelia\\Model\\State', $deletedState); $this->assertTrue($deletedState->isDeleted()); }
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 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 create(StateCreateEvent $event) { $state = new StateModel(); $state->setVisible($event->isVisible())->setCountryId($event->getCountry())->setIsocode($event->getIsocode())->setLocale($event->getLocale())->setTitle($event->getTitle())->save(); $event->setState($state); }
/** * Declares an association between this object and a ChildState object. * * @param ChildState $v * @return \Thelia\Model\StateI18n The current object (for fluent API support) * @throws PropelException */ public function setState(ChildState $v = null) { if ($v === null) { $this->setId(NULL); } else { $this->setId($v->getId()); } $this->aState = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildState object, it will not be re-added. if ($v !== null) { $v->addStateI18n($this); } return $this; }
/** * Filter the query by a related \Thelia\Model\State object * * @param \Thelia\Model\State|ObjectCollection $state The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAddressQuery The current query, for fluid interface */ public function filterByState($state, $comparison = null) { if ($state instanceof \Thelia\Model\State) { return $this->addUsingAlias(AddressTableMap::STATE_ID, $state->getId(), $comparison); } elseif ($state instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(AddressTableMap::STATE_ID, $state->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByState() only accepts arguments of type \\Thelia\\Model\\State or Collection'); } }
/** * Exclude object from result * * @param ChildState $state Object to remove from the list of results * * @return ChildStateQuery The current query, for fluid interface */ public function prune($state = null) { if ($state) { $this->addUsingAlias(StateTableMap::ID, $state->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related \Thelia\Model\State object * * @param \Thelia\Model\State|ObjectCollection $state the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCountryQuery The current query, for fluid interface */ public function filterByState($state, $comparison = null) { if ($state instanceof \Thelia\Model\State) { return $this->addUsingAlias(CountryTableMap::ID, $state->getCountryId(), $comparison); } elseif ($state instanceof ObjectCollection) { return $this->useStateQuery()->filterByPrimaryKeys($state->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByState() only accepts arguments of type \\Thelia\\Model\\State or Collection'); } }
/** * Returns the object ID from the object * * @param \Thelia\Model\State $object */ protected function getObjectId($object) { return $object->getId(); }