예제 #1
0
 /**
  * @param CM_Model_Location $location
  * @return CM_Model_Location|null
  */
 private function _squashLocationInConstraints(CM_Model_Location $location = null)
 {
     if (null === $location) {
         return null;
     }
     if ($location->getLevel() < $this->_options['levelMin']) {
         return null;
     }
     if ($location->getLevel() > $this->_options['levelMax']) {
         $location = $location->get($this->_options['levelMax']);
     }
     return $location;
 }
예제 #2
0
 public function testGetLevel()
 {
     foreach (self::$_fields as $level => $fields) {
         $location = new CM_Model_Location($level, $fields['id']);
         $this->assertSame($level, $location->getLevel());
     }
 }
예제 #3
0
 /**
  * @param CM_Model_Location $city
  * @param string            $name
  * @param float             $latitude
  * @param float             $longitude
  * @throws CM_Exception_Invalid
  * @return CM_Model_Location
  */
 public static function createZip(CM_Model_Location $city, $name, $latitude, $longitude)
 {
     if (CM_Model_Location::LEVEL_CITY !== $city->getLevel()) {
         throw new CM_Exception_Invalid('The parent location should be a city');
     }
     $zip = CM_Model_Location_Zip::create($city->_getLocation(), $name, $latitude, $longitude);
     return self::fromLocation($zip);
 }
예제 #4
0
파일: Location.php 프로젝트: cargomedia/cm
 /**
  * @param CM_Model_Location $location
  */
 public function filterLocation(CM_Model_Location $location)
 {
     $this->filterTerm('ids.' . $location->getLevel(), $location->getId());
 }