Skip to content

Commit a4aaa56

Browse files
author
Eugene Terentev
committed
Basic code reformat
1 parent efc93ea commit a4aaa56

File tree

150 files changed

+2400
-2072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+2400
-2072
lines changed

backend/config/base.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'id' => 'backend',
44
'basePath' => dirname(__DIR__),
55
'components' => [
6-
'urlManager' => require __DIR__.'/_urlManager.php',
6+
'urlManager' => require __DIR__ . '/_urlManager.php',
77
'frontendCache' => require Yii::getAlias('@frontend/config/_cache.php')
88
],
99
];

backend/controllers/ArticleCategoryController.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace backend\controllers;
44

5-
use Yii;
6-
use common\models\ArticleCategory;
75
use backend\models\search\ArticleCategorySearch;
6+
use common\models\ArticleCategory;
7+
use Yii;
8+
use yii\filters\VerbFilter;
89
use yii\helpers\ArrayHelper;
910
use yii\web\Controller;
1011
use yii\web\NotFoundHttpException;
11-
use yii\filters\VerbFilter;
1212

1313
/**
1414
* ArticleCategoryController implements the CRUD actions for ArticleCategory model.
@@ -54,6 +54,22 @@ public function actionView($id)
5454
]);
5555
}
5656

57+
/**
58+
* Finds the ArticleCategory model based on its primary key value.
59+
* If the model is not found, a 404 HTTP exception will be thrown.
60+
* @param integer $id
61+
* @return ArticleCategory the loaded model
62+
* @throws NotFoundHttpException if the model cannot be found
63+
*/
64+
protected function findModel($id)
65+
{
66+
if (($model = ArticleCategory::findOne($id)) !== null) {
67+
return $model;
68+
} else {
69+
throw new NotFoundHttpException('The requested page does not exist.');
70+
}
71+
}
72+
5773
/**
5874
* Creates a new ArticleCategory model.
5975
* If creation is successful, the browser will be redirected to the 'view' page.
@@ -112,20 +128,4 @@ public function actionDelete($id)
112128

113129
return $this->redirect(['index']);
114130
}
115-
116-
/**
117-
* Finds the ArticleCategory model based on its primary key value.
118-
* If the model is not found, a 404 HTTP exception will be thrown.
119-
* @param integer $id
120-
* @return ArticleCategory the loaded model
121-
* @throws NotFoundHttpException if the model cannot be found
122-
*/
123-
protected function findModel($id)
124-
{
125-
if (($model = ArticleCategory::findOne($id)) !== null) {
126-
return $model;
127-
} else {
128-
throw new NotFoundHttpException('The requested page does not exist.');
129-
}
130-
}
131131
}

backend/controllers/ArticleController.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace backend\controllers;
44

5-
use Yii;
6-
use common\models\Article;
75
use backend\models\search\ArticleSearch;
8-
use \common\models\ArticleCategory;
6+
use common\models\Article;
7+
use common\models\ArticleCategory;
8+
use Yii;
9+
use yii\filters\VerbFilter;
910
use yii\web\Controller;
1011
use yii\web\NotFoundHttpException;
11-
use yii\filters\VerbFilter;
1212

1313
/**
1414
* ArticleController implements the CRUD actions for Article model.
@@ -36,7 +36,7 @@ public function actionIndex()
3636
$searchModel = new ArticleSearch();
3737
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
3838
$dataProvider->sort = [
39-
'defaultOrder'=>['published_at'=>SORT_DESC]
39+
'defaultOrder' => ['published_at' => SORT_DESC]
4040
];
4141
return $this->render('index', [
4242
'searchModel' => $searchModel,
@@ -83,19 +83,6 @@ public function actionUpdate($id)
8383
}
8484
}
8585

86-
/**
87-
* Deletes an existing Article model.
88-
* If deletion is successful, the browser will be redirected to the 'index' page.
89-
* @param integer $id
90-
* @return mixed
91-
*/
92-
public function actionDelete($id)
93-
{
94-
$this->findModel($id)->delete();
95-
96-
return $this->redirect(['index']);
97-
}
98-
9986
/**
10087
* Finds the Article model based on its primary key value.
10188
* If the model is not found, a 404 HTTP exception will be thrown.
@@ -111,4 +98,17 @@ protected function findModel($id)
11198
throw new NotFoundHttpException('The requested page does not exist.');
11299
}
113100
}
101+
102+
/**
103+
* Deletes an existing Article model.
104+
* If deletion is successful, the browser will be redirected to the 'index' page.
105+
* @param integer $id
106+
* @return mixed
107+
*/
108+
public function actionDelete($id)
109+
{
110+
$this->findModel($id)->delete();
111+
112+
return $this->redirect(['index']);
113+
}
114114
}

backend/controllers/CacheController.php

+60-61
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use yii\caching\Cache;
1010
use yii\caching\TagDependency;
1111
use yii\data\ArrayDataProvider;
12-
use yii\filters\VerbFilter;
1312
use yii\web\Controller;
1413
use yii\web\HttpException;
1514

@@ -24,56 +23,61 @@ class CacheController extends Controller
2423
*/
2524
public function actionIndex()
2625
{
27-
$dataProvider = new ArrayDataProvider(['allModels'=>$this->findCaches()]);
28-
return $this->render('index', ['dataProvider'=>$dataProvider]);
26+
$dataProvider = new ArrayDataProvider(['allModels' => $this->findCaches()]);
27+
return $this->render('index', ['dataProvider' => $dataProvider]);
2928
}
3029

3130
/**
32-
* @param $id
33-
* @return \yii\web\Response
34-
* @throws HttpException
31+
* Returns array of caches in the system, keys are cache components names, values are class names.
32+
* @param array $cachesNames caches to be found
33+
* @return array
3534
*/
36-
public function actionFlushCache($id)
35+
private function findCaches(array $cachesNames = [])
3736
{
38-
if ($this->getCache($id)->flush()) {
39-
Yii::$app->session->setFlash('alert', [
40-
'body'=>\Yii::t('backend', 'Cache has been successfully flushed'),
41-
'options'=>['class'=>'alert-success']
42-
]);
43-
};
44-
return $this->redirect(['index']);
37+
$caches = [];
38+
$components = Yii::$app->getComponents();
39+
$findAll = ($cachesNames == []);
40+
41+
foreach ($components as $name => $component) {
42+
if (!$findAll && !in_array($name, $cachesNames)) {
43+
continue;
44+
}
45+
46+
if ($component instanceof Cache) {
47+
$caches[$name] = ['name' => $name, 'class' => get_class($component)];
48+
} elseif (is_array($component) && isset($component['class']) && $this->isCacheClass($component['class'])) {
49+
$caches[$name] = ['name' => $name, 'class' => $component['class']];
50+
} elseif (is_string($component) && $this->isCacheClass($component)) {
51+
$caches[$name] = ['name' => $name, 'class' => $component];
52+
}
53+
}
54+
55+
return $caches;
4556
}
4657

4758
/**
48-
* @param $id
49-
* @param $key
50-
* @return \yii\web\Response
51-
* @throws HttpException
59+
* Checks if given class is a Cache class.
60+
* @param string $className class name.
61+
* @return boolean
5262
*/
53-
public function actionFlushCacheKey($id, $key)
63+
private function isCacheClass($className)
5464
{
55-
if ($this->getCache($id)->delete($key)) {
56-
Yii::$app->session->setFlash('alert', [
57-
'body'=>\Yii::t('backend', 'Cache entry has been successfully deleted'),
58-
'options'=>['class'=>'alert-success']
59-
]);
60-
};
61-
return $this->redirect(['index']);
65+
return is_subclass_of($className, Cache::className());
6266
}
6367

6468
/**
6569
* @param $id
66-
* @param $tag
6770
* @return \yii\web\Response
6871
* @throws HttpException
6972
*/
70-
public function actionFlushCacheTag($id, $tag)
73+
public function actionFlushCache($id)
7174
{
72-
TagDependency::invalidate($this->getCache($id), $tag);
73-
Yii::$app->session->setFlash('alert', [
74-
'body'=>\Yii::t('backend', 'TagDependency was invalidated'),
75-
'options'=>['class'=>'alert-success']
76-
]);
75+
if ($this->getCache($id)->flush()) {
76+
Yii::$app->session->setFlash('alert', [
77+
'body' => \Yii::t('backend', 'Cache has been successfully flushed'),
78+
'options' => ['class' => 'alert-success']
79+
]);
80+
};
7781
return $this->redirect(['index']);
7882
}
7983

@@ -92,40 +96,35 @@ protected function getCache($id)
9296
}
9397

9498
/**
95-
* Returns array of caches in the system, keys are cache components names, values are class names.
96-
* @param array $cachesNames caches to be found
97-
* @return array
99+
* @param $id
100+
* @param $key
101+
* @return \yii\web\Response
102+
* @throws HttpException
98103
*/
99-
private function findCaches(array $cachesNames = [])
104+
public function actionFlushCacheKey($id, $key)
100105
{
101-
$caches = [];
102-
$components = Yii::$app->getComponents();
103-
$findAll = ($cachesNames == []);
104-
105-
foreach ($components as $name => $component) {
106-
if (!$findAll && !in_array($name, $cachesNames)) {
107-
continue;
108-
}
109-
110-
if ($component instanceof Cache) {
111-
$caches[$name] = ['name'=>$name, 'class'=>get_class($component)];
112-
} elseif (is_array($component) && isset($component['class']) && $this->isCacheClass($component['class'])) {
113-
$caches[$name] = ['name'=>$name, 'class'=>$component['class']];
114-
} elseif (is_string($component) && $this->isCacheClass($component)) {
115-
$caches[$name] = ['name'=>$name, 'class'=>$component];
116-
}
117-
}
118-
119-
return $caches;
106+
if ($this->getCache($id)->delete($key)) {
107+
Yii::$app->session->setFlash('alert', [
108+
'body' => \Yii::t('backend', 'Cache entry has been successfully deleted'),
109+
'options' => ['class' => 'alert-success']
110+
]);
111+
};
112+
return $this->redirect(['index']);
120113
}
121114

122115
/**
123-
* Checks if given class is a Cache class.
124-
* @param string $className class name.
125-
* @return boolean
116+
* @param $id
117+
* @param $tag
118+
* @return \yii\web\Response
119+
* @throws HttpException
126120
*/
127-
private function isCacheClass($className)
121+
public function actionFlushCacheTag($id, $tag)
128122
{
129-
return is_subclass_of($className, Cache::className());
123+
TagDependency::invalidate($this->getCache($id), $tag);
124+
Yii::$app->session->setFlash('alert', [
125+
'body' => \Yii::t('backend', 'TagDependency was invalidated'),
126+
'options' => ['class' => 'alert-success']
127+
]);
128+
return $this->redirect(['index']);
130129
}
131130
}

backend/controllers/FileStorageController.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace backend\controllers;
44

5-
use Yii;
6-
use common\models\FileStorageItem;
75
use backend\models\search\FileStorageItemSearch;
6+
use common\models\FileStorageItem;
7+
use Yii;
8+
use yii\filters\VerbFilter;
89
use yii\web\Controller;
910
use yii\web\NotFoundHttpException;
10-
use yii\filters\VerbFilter;
1111

1212
/**
1313
* FileStorageController implements the CRUD actions for FileStorageItem model.
@@ -41,7 +41,7 @@ public function actions()
4141
'upload-imperavi' => [
4242
'class' => 'trntv\filekit\actions\UploadAction',
4343
'fileparam' => 'file',
44-
'responseUrlParam'=> 'filelink',
44+
'responseUrlParam' => 'filelink',
4545
'multiple' => false,
4646
'disableCsrf' => true
4747
]
@@ -57,7 +57,7 @@ public function actionIndex()
5757
$searchModel = new FileStorageItemSearch();
5858
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
5959
$dataProvider->sort = [
60-
'defaultOrder'=>['created_at'=>SORT_DESC]
60+
'defaultOrder' => ['created_at' => SORT_DESC]
6161
];
6262
$components = \yii\helpers\ArrayHelper::map(
6363
FileStorageItem::find()->select('component')->distinct()->all(),
@@ -86,19 +86,6 @@ public function actionView($id)
8686
]);
8787
}
8888

89-
/**
90-
* Deletes an existing FileStorageItem model.
91-
* If deletion is successful, the browser will be redirected to the 'index' page.
92-
* @param integer $id
93-
* @return mixed
94-
*/
95-
public function actionDelete($id)
96-
{
97-
$this->findModel($id)->delete();
98-
99-
return $this->redirect(['index']);
100-
}
101-
10289
/**
10390
* Finds the FileStorageItem model based on its primary key value.
10491
* If the model is not found, a 404 HTTP exception will be thrown.
@@ -114,4 +101,17 @@ protected function findModel($id)
114101
throw new NotFoundHttpException('The requested page does not exist.');
115102
}
116103
}
104+
105+
/**
106+
* Deletes an existing FileStorageItem model.
107+
* If deletion is successful, the browser will be redirected to the 'index' page.
108+
* @param integer $id
109+
* @return mixed
110+
*/
111+
public function actionDelete($id)
112+
{
113+
$this->findModel($id)->delete();
114+
115+
return $this->redirect(['index']);
116+
}
117117
}

0 commit comments

Comments
 (0)