Commit 9c92600b by Carsten Brandt

Merge pull request #3728 from umneeq/gii-codestyle-fixes

Gii codestyle fixes
parents 03efbc4c 27a9bc75
...@@ -310,7 +310,7 @@ abstract class Generator extends Model ...@@ -310,7 +310,7 @@ abstract class Generator extends Model
*/ */
public function render($template, $params = []) public function render($template, $params = [])
{ {
$view = new View; $view = new View();
$params['generator'] = $this; $params['generator'] = $this;
return $view->renderFile($this->getTemplatePath() . '/' . $template, $params, $this); return $view->renderFile($this->getTemplatePath() . '/' . $template, $params, $this);
......
...@@ -64,8 +64,8 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas ...@@ -64,8 +64,8 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
public function actionIndex() public function actionIndex()
{ {
<?php if (!empty($generator->searchModelClass)): ?> <?php if (!empty($generator->searchModelClass)): ?>
$searchModel = new <?= isset($searchModelAlias) ? $searchModelAlias : $searchModelClass ?>; $searchModel = new <?= isset($searchModelAlias) ? $searchModelAlias : $searchModelClass ?>();
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
...@@ -101,7 +101,7 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas ...@@ -101,7 +101,7 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
*/ */
public function actionCreate() public function actionCreate()
{ {
$model = new <?= $modelClass ?>; $model = new <?= $modelClass ?>();
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', <?= $urlParams ?>]); return $this->redirect(['view', <?= $urlParams ?>]);
......
...@@ -9,7 +9,7 @@ use yii\helpers\StringHelper; ...@@ -9,7 +9,7 @@ use yii\helpers\StringHelper;
*/ */
/** @var \yii\db\ActiveRecord $model */ /** @var \yii\db\ActiveRecord $model */
$model = new $generator->modelClass; $model = new $generator->modelClass();
$safeAttributes = $model->safeAttributes(); $safeAttributes = $model->safeAttributes();
if (empty($safeAttributes)) { if (empty($safeAttributes)) {
$safeAttributes = $model->attributes(); $safeAttributes = $model->attributes();
......
...@@ -148,7 +148,7 @@ EOD; ...@@ -148,7 +148,7 @@ EOD;
public function getModelAttributes() public function getModelAttributes()
{ {
/** @var Model $model */ /** @var Model $model */
$model = new $this->modelClass; $model = new $this->modelClass();
if (!empty($this->scenarioName)) { if (!empty($this->scenarioName)) {
$model->setScenario($this->scenarioName); $model->setScenario($this->scenarioName);
} }
......
...@@ -14,7 +14,7 @@ echo "<?php\n"; ...@@ -14,7 +14,7 @@ echo "<?php\n";
public function action<?= Inflector::id2camel(trim(basename($generator->viewName), '_')) ?>() public function action<?= Inflector::id2camel(trim(basename($generator->viewName), '_')) ?>()
{ {
$model = new <?= $generator->modelClass ?><?= empty($generator->scenarioName) ? "" : "(['scenario' => '{$generator->scenarioName}'])" ?>; $model = new <?= $generator->modelClass ?><?= empty($generator->scenarioName) ? "()" : "(['scenario' => '{$generator->scenarioName}'])" ?>;
if ($model->load(Yii::$app->request->post())) { if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) { if ($model->validate()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment