/** * @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; }
public function testGetLevel() { foreach (self::$_fields as $level => $fields) { $location = new CM_Model_Location($level, $fields['id']); $this->assertSame($level, $location->getLevel()); } }
/** * @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); }
/** * @param CM_Model_Location $location */ public function filterLocation(CM_Model_Location $location) { $this->filterTerm('ids.' . $location->getLevel(), $location->getId()); }