Exemple #1
0
 public function addCountry(AreaAddCountryEvent $event)
 {
     $countryIds = $event->getCountryId();
     $areaId = $event->getAreaId();
     foreach ($countryIds as $countryId) {
         $countryArea = new CountryArea();
         $countryArea->setAreaId($areaId)->setCountryId($countryId)->save();
     }
     $event->setArea(AreaQuery::create()->findPk($areaId));
 }
Exemple #2
0
 public function addCountry(AreaAddCountryEvent $event)
 {
     $countryIds = $event->getCountryId();
     $areaId = $event->getAreaId();
     foreach ($countryIds as $countryId) {
         $countryArea = new CountryArea();
         $country = explode('-', $countryId);
         if (count($country) === 1) {
             $country[1] = null;
         }
         if ($country[1] == 0) {
             $country[1] = null;
         }
         $countryArea->setAreaId($areaId)->setCountryId($country[0])->setStateId($country[1])->save();
     }
     $event->setArea(AreaQuery::create()->findPk($areaId));
 }
Exemple #3
0
 /**
  * Exclude object from result
  *
  * @param   ChildCountryArea $countryArea Object to remove from the list of results
  *
  * @return ChildCountryAreaQuery The current query, for fluid interface
  */
 public function prune($countryArea = null)
 {
     if ($countryArea) {
         $this->addUsingAlias(CountryAreaTableMap::ID, $countryArea->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemple #4
0
 /**
  * Filter the query by a related \Thelia\Model\CountryArea object
  *
  * @param \Thelia\Model\CountryArea|ObjectCollection $countryArea  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildAreaQuery The current query, for fluid interface
  */
 public function filterByCountryArea($countryArea, $comparison = null)
 {
     if ($countryArea instanceof \Thelia\Model\CountryArea) {
         return $this->addUsingAlias(AreaTableMap::ID, $countryArea->getAreaId(), $comparison);
     } elseif ($countryArea instanceof ObjectCollection) {
         return $this->useCountryAreaQuery()->filterByPrimaryKeys($countryArea->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByCountryArea() only accepts arguments of type \\Thelia\\Model\\CountryArea or Collection');
     }
 }
Exemple #5
0
 /**
  * @param    Country $country The country object to add.
  */
 protected function doAddCountry($country)
 {
     $countryArea = new ChildCountryArea();
     $countryArea->setCountry($country);
     $this->addCountryArea($countryArea);
     // set the back reference to this object directly as using provided method either results
     // in endless loop or in multiple relations
     if (!$country->getAreas()->contains($this)) {
         $foreignCollection = $country->getAreas();
         $foreignCollection[] = $this;
     }
 }