class CityComponent extends Component {
public $_city;
public function getCity(){
if ($this->_city) {
return $this->_city;
} else {
$sdn = explode('.', $_SERVER['HTTP_HOST']);
if(count($sdn) == 4 ) {
$city = City::find()->where(['uri'=>$sdn[0]])->one();
} else {
$city = City::find()->where(['uri'=>'kem'])->one();
}
$this->_city = $city;
return $city;
}
}
}