Ejemplo n.º 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));
 }
Ejemplo n.º 2
0
 public function addCountry(AreaAddCountryEvent $event)
 {
     $countryIds = $event->getCountryId();
     $areaId = $event->getAreaId();
     foreach ($countryIds as $countryId) {
         if (null !== ($country = CountryQuery::create()->findPk($countryId))) {
             $country->setDispatcher($event->getDispatcher());
             $country->setAreaId($areaId)->save();
         }
     }
     $event->setArea(AreaQuery::create()->findPk($areaId));
 }
Ejemplo n.º 3
0
 /**
  * @param AreaModel $area
  * @depends testUpdatePostage
  */
 public function testAddCountry(AreaModel $area)
 {
     $country = CountryQuery::create()->findOne();
     $event = new AreaAddCountryEvent($area->getId(), [$country->getId()]);
     $event->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface"));
     $areaAction = new Area();
     $areaAction->addCountry($event);
     $updatedArea = $event->getArea();
     $updatedCountry = CountryQuery::create()->findOneByAreaId($updatedArea->getId());
     $this->assertInstanceOf('Thelia\\Model\\Area', $updatedArea);
     $this->assertEquals($country->getId(), $updatedCountry->getId());
     return $updatedArea;
 }
Ejemplo n.º 4
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));
 }