@@ -18,9 +18,10 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $this->joinTables(); |
| 20 | 20 | |
| 21 | - if(!empty($tags)) |
|
| 22 | - $this->getQuery() |
|
| 21 | + if(!empty($tags)) { |
|
| 22 | + $this->getQuery() |
|
| 23 | 23 | ->andFilterWhere([ TaxonomyTerms::tableName() . '.term' => $tags ]); |
| 24 | + } |
|
| 24 | 25 | |
| 25 | 26 | return $this->getQuery(); |
| 26 | 27 | } |
@@ -96,8 +96,9 @@ |
||
| 96 | 96 | ->innerJoin($this->getTable(), $this->getTable() . '.term_id = taxonomy_terms.id and ' . $this->getTable() . '.object_id=:object_id', |
| 97 | 97 | [':object_id' => $object_id]) |
| 98 | 98 | ->andFilterWhere([TaxonomyTerms::tableName() . '.term' => $name]); |
| 99 | - foreach($query->all() as $v) |
|
| 100 | - $result[$v['term']] = $v['value']; |
|
| 99 | + foreach($query->all() as $v) { |
|
| 100 | + $result[$v['term']] = $v['value']; |
|
| 101 | + } |
|
| 101 | 102 | return isset($result) ? $result : []; |
| 102 | 103 | } |
| 103 | 104 | } |
@@ -13,13 +13,14 @@ |
||
| 13 | 13 | $message = Yii::$app->session->getFlash('info'); |
| 14 | 14 | ?> |
| 15 | 15 | <div class="taxonomy-def-index"> |
| 16 | - <?php if(isset($message)) |
|
| 16 | + <?php if(isset($message)) { |
|
| 17 | 17 | echo Alert::widget([ |
| 18 | 18 | 'options' => [ |
| 19 | 19 | 'class' => 'alert-info', |
| 20 | 20 | ], |
| 21 | 21 | 'body' => nl2br($message), |
| 22 | 22 | ]); |
| 23 | +} |
|
| 23 | 24 | ?> |
| 24 | 25 | |
| 25 | 26 | <h1><?= Html::encode($this->title) ?></h1> |
@@ -28,8 +28,9 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | ob_start(); |
| 30 | 30 | //$this->migrationPath = Yii::getAlias($migrationPath); |
| 31 | - if($this->beforeAction('up')) |
|
| 32 | - $this->migrateUp($class); |
|
| 31 | + if($this->beforeAction('up')) { |
|
| 32 | + $this->migrateUp($class); |
|
| 33 | + } |
|
| 33 | 34 | $result = ob_get_contents(); |
| 34 | 35 | return $result; |
| 35 | 36 | } |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | ob_start(); |
| 40 | 41 | //$this->migrationPath = Yii::getAlias($migrationPath); |
| 41 | - if($this->beforeAction('down')) |
|
| 42 | - $this->migrateDown($class); |
|
| 42 | + if($this->beforeAction('down')) { |
|
| 43 | + $this->migrateDown($class); |
|
| 44 | + } |
|
| 43 | 45 | $result = ob_get_contents(); |
| 44 | 46 | return $result; |
| 45 | 47 | } |
@@ -69,8 +71,9 @@ discard block |
||
| 69 | 71 | */ |
| 70 | 72 | public function actionIndex() |
| 71 | 73 | { |
| 72 | - if(!$this->getComponent()->isInstalled()) |
|
| 73 | - throw new InvalidConfigException("Please run the migration first!"); |
|
| 74 | + if(!$this->getComponent()->isInstalled()) { |
|
| 75 | + throw new InvalidConfigException("Please run the migration first!"); |
|
| 76 | + } |
|
| 74 | 77 | |
| 75 | 78 | $searchModel = new TaxonomyDefSearch(); |
| 76 | 79 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
@@ -192,10 +195,11 @@ discard block |
||
| 192 | 195 | |
| 193 | 196 | public function getComponent() |
| 194 | 197 | { |
| 195 | - if(\Yii::$app->has($this->module->component)) |
|
| 196 | - return \Yii::$app->{$this->module->component}; |
|
| 197 | - else |
|
| 198 | - throw new InvalidConfigException("Cannot find taxonomy component({$this->module->component})"); |
|
| 198 | + if(\Yii::$app->has($this->module->component)) { |
|
| 199 | + return \Yii::$app->{$this->module->component}; |
|
| 200 | + } else { |
|
| 201 | + throw new InvalidConfigException("Cannot find taxonomy component({$this->module->component})"); |
|
| 202 | + } |
|
| 199 | 203 | } |
| 200 | 204 | |
| 201 | 205 | public function actionInstall() |
@@ -206,8 +210,9 @@ discard block |
||
| 206 | 210 | $this->getComponent()->install(); |
| 207 | 211 | |
| 208 | 212 | $this->redirect(['/'.$this->module->id . '/' . $this->id . '/index']); |
| 209 | - } else |
|
| 210 | - throw new InvalidConfigException("Cannot find taxonomy component({$this->module->component})"); |
|
| 213 | + } else { |
|
| 214 | + throw new InvalidConfigException("Cannot find taxonomy component({$this->module->component})"); |
|
| 215 | + } |
|
| 211 | 216 | } |
| 212 | 217 | return $this->render('install'); |
| 213 | 218 | } |
@@ -17,13 +17,15 @@ |
||
| 17 | 17 | $this->joinTables(); |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - if(!empty($name)) |
|
| 21 | - $this->getQuery() |
|
| 20 | + if(!empty($name)) { |
|
| 21 | + $this->getQuery() |
|
| 22 | 22 | ->andFilterWhere([ TaxonomyTerms::tableName() . '.term' => $name ]); |
| 23 | + } |
|
| 23 | 24 | |
| 24 | - if(!empty($value)) |
|
| 25 | - $this->getQuery() |
|
| 25 | + if(!empty($value)) { |
|
| 26 | + $this->getQuery() |
|
| 26 | 27 | ->andFilterWhere([ $this->taxonomy->table . '.value' => $value ]); |
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | return $this->getQuery(); |
| 29 | 31 | } |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | if ($this->db->driverName === 'mysql') { |
| 12 | 12 | // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
| 13 | 13 | return 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
| 14 | - } else |
|
| 15 | - throw new Exception('Unsupported database.'); |
|
| 14 | + } else { |
|
| 15 | + throw new Exception('Unsupported database.'); |
|
| 16 | + } |
|
| 16 | 17 | } |
| 17 | 18 | |
| 18 | 19 | public function up() |
@@ -64,8 +64,9 @@ discard block |
||
| 64 | 64 | ->andFilterWhere(['taxonomy_terms.term' => $name]); |
| 65 | 65 | |
| 66 | 66 | $result = []; |
| 67 | - foreach($query->all() as $v) |
|
| 68 | - $result[] = $v['term']; |
|
| 67 | + foreach($query->all() as $v) { |
|
| 68 | + $result[] = $v['term']; |
|
| 69 | + } |
|
| 69 | 70 | return $result; |
| 70 | 71 | } |
| 71 | 72 | |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | } |
| 111 | 112 | |
| 112 | 113 | public function canInstall() { |
| 113 | - if(!$this->getTable()) |
|
| 114 | - return 'Missing "table" property'; |
|
| 114 | + if(!$this->getTable()) { |
|
| 115 | + return 'Missing "table" property'; |
|
| 116 | + } |
|
| 115 | 117 | return true; |
| 116 | 118 | } |
| 117 | 119 | |
@@ -131,10 +133,12 @@ discard block |
||
| 131 | 133 | |
| 132 | 134 | public function getRefTableName() |
| 133 | 135 | { |
| 134 | - if(strpos($this->refTable, '\\') === FALSE) //not an AR class but a table name |
|
| 136 | + if(strpos($this->refTable, '\\') === FALSE) { |
|
| 137 | + //not an AR class but a table name |
|
| 135 | 138 | return $this->refTable; |
| 136 | - else |
|
| 137 | - return call_user_func([$this->refTable, 'tableName']); |
|
| 139 | + } else { |
|
| 140 | + return call_user_func([$this->refTable, 'tableName']); |
|
| 141 | + } |
|
| 138 | 142 | } |
| 139 | 143 | |
| 140 | 144 | public function getTable() |