/** {@inheritdoc} */
 private function ensureRelatedData()
 {
     $this->_model = ServerHelper::getAvailablePackages(null, $this->tariff_id);
     if ($this->_model === null) {
         throw new InvalidConfigException('Failed to find tariff');
     }
     $this->_image = Osimage::find()->where(['osimage' => $this->osimage, 'type' => $this->_model->getType()])->one();
     if ($this->_image === null) {
         throw new InvalidConfigException('Failed to find osimage');
     }
     $this->name = $this->_model->getName();
     $this->description = Yii::t('hipanel:server:order', 'Order');
 }
Exemplo n.º 2
0
 /**
  * Gets array of [[Osimage]] for $type
  *
  * @param string $type
  * @return Osimage[]|null
  */
 public static function getOsimages($type = null)
 {
     return Yii::$app->cache->getTimeCached(3600, [$type], function ($type) {
         return Osimage::find()->andFilterWhere(['type' => $type])->all();
     });
 }
 protected function getOsimagesLiveCd()
 {
     $models = Yii::$app->cache->getTimeCached(3600, [true], function ($livecd) {
         return Osimage::findAll(['livecd' => $livecd]);
     });
     if ($models !== null) {
         return $models;
     }
     throw new NotFoundHttpException('The requested page does not exist.');
 }