Exemplo n.º 1
0
 /**
  * @param null $name
  * @param null $postcode
  * @return array
  */
 public function getCities($name = null, $postcode = null)
 {
     $cities = array();
     if (isset($this->resultLogin)) {
         if ($postcode) {
             require_once __DIR__ . '/lib/speedy-eps-lib/ver01/ParamFilterSite.class.php';
             $paramFilterSite = new \ParamFilterSite();
             $paramFilterSite->setPostCode($postcode);
             $paramFilterSite->setName($name);
             $listSitesEx = $this->facade->listSitesEx($paramFilterSite);
             $listSites = array();
             /* @var \ResultSiteEx $result */
             foreach ($listSitesEx as $result) {
                 if ($result->isExactMatch()) {
                     $listSites[] = $result->getSite();
                 }
             }
         } else {
             $listSites = $this->facade->listSites(null, $name);
         }
         if ($listSites) {
             /* @var \ResultSite $city */
             foreach ($listSites as $city) {
                 $cities[] = array('id' => $city->getId(), 'label' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'value' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'postcode' => $city->getPostCode(), 'nomenclature' => $city->getAddrNomen()->getValue());
             }
         }
     }
     return $cities;
 }
Exemplo n.º 2
0
 /** Returns cities
  * @param null $name
  * @param null $postcode
  * @return array
  */
 public function getCities($name = null, $postcode = null)
 {
     $this->_error = '';
     $cities = array();
     if (isset($this->resultLogin)) {
         try {
             if ($postcode) {
                 require_once __DIR__ . '/lib/speedy-eps-lib/ver01/ParamFilterSite.class.php';
                 $paramFilterSite = new \ParamFilterSite();
                 $paramFilterSite->setPostCode($postcode);
                 $paramFilterSite->setName($name);
                 $listSitesEx = $this->ePSFacade->listSitesEx($paramFilterSite);
                 $listSites = array();
                 foreach ($listSitesEx as $result) {
                     if ($result->isExactMatch()) {
                         $listSites[] = $result->getSite();
                     }
                 }
             } else {
                 $listSites = $this->ePSFacade->listSites(null, $name);
             }
             if ($listSites) {
                 foreach ($listSites as $city) {
                     $cities[] = array('id' => $city->getId(), 'label' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'value' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'postcode' => $city->getPostCode(), 'nomenclature' => $city->getAddrNomen()->getValue());
                 }
             }
         } catch (\Exception $e) {
             $this->_error = $e->getMessage();
             $this->log->addError('Speedy :: getCities :: ' . $e->getMessage());
         }
     }
     return $cities;
 }