Exemple #1
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;
 }