skeeks\cms\models\CmsSite::getByCode PHP Method

getByCode() public static method

public static getByCode ( (string) $code ) : static
$code (string)
return static
    public static function getByCode($code)
    {
        if (!array_key_exists($code, static::$sites)) {
            static::$sites[$code] = static::find()->where(['code' => (string) $code])->active()->one();
        }
        return static::$sites[$code];
    }

Usage Example

コード例 #1
0
 /**
  * @return CmsSite
  */
 public function getSite()
 {
     //return $this->hasOne(CmsSite::className(), ['code' => 'site_code']);
     return CmsSite::getByCode($this->site_code);
 }