/** * @return Currency */ public static function getMainCurrency() { return null === static::$mainCurrency ? static::$mainCurrency = Currency::getMainCurrency() : static::$mainCurrency; }
/** * Returns main currency object for this shop with static-cache * * @return Currency Main currency object */ public static function getMainCurrency() { if (static::$mainCurrency === null) { static::$mainCurrency = Yii::$app->cache->get("MainCurrency"); if (static::$mainCurrency === false) { static::$mainCurrency = Currency::find()->where(['is_main' => 1])->one(); if (static::$mainCurrency !== null) { static::$identity_map[static::$mainCurrency->id] = static::$mainCurrency; } Yii::$app->cache->set("MainCurrency", static::$mainCurrency, 604800, new TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag(static::className(), static::$mainCurrency->id)]])); } } return static::$mainCurrency; }