コード例 #1
0
 /**
  * @param integer $id Tariff ID
  * @param array $options that will be passed to the object as configuration
  * @return AbstractTariffManager|object
  * @throws NotFoundHttpException
  */
 public static function createById($id, $options = [])
 {
     $model = Tariff::find()->byId($id)->details()->one();
     if ($model === null) {
         throw new NotFoundHttpException('Tariff was not found');
     }
     $model->scenario = ArrayHelper::getValue($options, 'scenario', $model::SCENARIO_DEFAULT);
     return Yii::createObject(array_merge(['class' => static::buildClassName($model->type), 'tariff' => $model], $options));
 }
コード例 #2
0
ファイル: MainColumn.php プロジェクト: hiqdev/hipanel-core
 /** {@inheritdoc} */
 protected function renderDataCellContent($model, $key, $index)
 {
     if ($this->value !== null) {
         if (is_string($this->value)) {
             $value = ArrayHelper::getValue($model, $this->value);
         } else {
             $value = call_user_func($this->value, $model, $key, $index, $this);
         }
     } else {
         $value = $this->renderViewLink($model, $key, $index);
     }
     $note = $this->renderNoteLink($model, $key, $index);
     $extra = $this->renderExtra($model);
     $badges = $this->badges instanceof Closure ? call_user_func($this->badges, $model, $key, $index) : $this->badges;
     return $value . $extra . ($badges ? ' ' . $badges : '') . ($note ? '<br>' . $note : '');
 }