@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | |
36 | 36 | public function removeTerm($object_id, $params = []) |
37 | 37 | { |
38 | - if(empty($params)) { |
|
38 | + if (empty($params)) { |
|
39 | 39 | $params = $this->getTerms($object_id); |
40 | 40 | } |
41 | 41 | |
42 | - foreach($params as $item) { |
|
42 | + foreach ($params as $item) { |
|
43 | 43 | $term = $this->getTaxonomyTerm($item); |
44 | 44 | $data['term_id'] = $term->id; |
45 | 45 | $data['object_id'] = $object_id; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->getDb()->createCommand()->delete($this->table, $data)->execute(); |
50 | 50 | |
51 | 51 | $term->updateCounters(['total_count' => -1]); |
52 | - Taxonomydef::updateAllCounters(['total_count' => -1], [ 'id' => $this->id ]); |
|
52 | + Taxonomydef::updateAllCounters(['total_count' => -1], ['id' => $this->id]); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | public function getTerms($object_id, $name = []) |
58 | 58 | { |
59 | 59 | $query = (new Query()) |
60 | - ->select(TaxonomyTerms::tableName() . '.term') |
|
60 | + ->select(TaxonomyTerms::tableName().'.term') |
|
61 | 61 | ->from(TaxonomyTerms::tableName()) |
62 | - ->innerJoin($this->table, $this->table . '.term_id = taxonomy_terms.id and ' . $this->table . '.object_id=:object_id', |
|
62 | + ->innerJoin($this->table, $this->table.'.term_id = taxonomy_terms.id and '.$this->table.'.object_id=:object_id', |
|
63 | 63 | [':object_id' => $object_id]) |
64 | 64 | ->andFilterWhere(['taxonomy_terms.term' => $name]); |
65 | 65 | |
66 | 66 | $result = []; |
67 | - foreach($query->all() as $v) |
|
67 | + foreach ($query->all() as $v) |
|
68 | 68 | $result[] = $v['term']; |
69 | 69 | return $result; |
70 | 70 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | public function canInstall() { |
113 | - if(!$this->getTable()) |
|
113 | + if (!$this->getTable()) |
|
114 | 114 | return 'Missing "table" property'; |
115 | 115 | return true; |
116 | 116 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function getTaxonomyTerm($name, $create = true) |
119 | 119 | { |
120 | 120 | $term = TaxonomyTerms::findOne(['term'=>$name, 'taxonomy_id' => $this->id]); |
121 | - if($create and !isset($term)) |
|
121 | + if ($create and !isset($term)) |
|
122 | 122 | { |
123 | 123 | $term = new TaxonomyTerms(); |
124 | 124 | $term->taxonomy_id = $this->id; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | public function getRefTableName() |
133 | 133 | { |
134 | - if(strpos($this->refTable, '\\') === FALSE) //not an AR class but a table name |
|
134 | + if (strpos($this->refTable, '\\') === FALSE) //not an AR class but a table name |
|
135 | 135 | return $this->refTable; |
136 | 136 | else |
137 | 137 | return call_user_func([$this->refTable, 'tableName']); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | if (!preg_match('/^\w+$/', $this->name)) { |
153 | 153 | throw new Exception('The migration name should contain letters, digits and/or underscore characters only.'); |
154 | 154 | } |
155 | - $name = 'm' . gmdate('ymd_His') . '_' . $this->name; |
|
155 | + $name = 'm'.gmdate('ymd_His').'_'.$this->name; |
|
156 | 156 | return $name; |
157 | 157 | } |
158 | 158 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | |
162 | 162 | $name = $this->getMigrationFile(); |
163 | - $file = Yii::getAlias($this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php'); |
|
163 | + $file = Yii::getAlias($this->migrationPath.DIRECTORY_SEPARATOR.$name.'.php'); |
|
164 | 164 | |
165 | 165 | //$data = get_object_vars($this); |
166 | 166 | $data = []; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $data['migration'] = $name; |
172 | 172 | |
173 | 173 | $this->migration = $name; |
174 | - $content = Yii::$app->getView()->renderFile(Yii::getAlias($this->templateFile), [ 'data' => $data ]); |
|
174 | + $content = Yii::$app->getView()->renderFile(Yii::getAlias($this->templateFile), ['data' => $data]); |
|
175 | 175 | file_put_contents($file, $content); |
176 | 176 | return $name; |
177 | 177 | } |
@@ -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() |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function addTerm($object_id, $params) |
19 | 19 | { |
20 | - foreach($params as $item) { |
|
20 | + foreach ($params as $item) { |
|
21 | 21 | $term = $this->getTaxonomyTerm($item); |
22 | 22 | $data['term_id'] = $term->id; |
23 | 23 | $data['object_id'] = $object_id; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $this->getDb()->createCommand()->insert($this->table, $data)->execute(); |
30 | 30 | |
31 | 31 | $term->updateCounters(['total_count' => 1]); |
32 | - TaxonomyDef::updateAllCounters(['total_count' => 1], [ 'id' => $this->id ]); |
|
32 | + TaxonomyDef::updateAllCounters(['total_count' => 1], ['id' => $this->id]); |
|
33 | 33 | |
34 | 34 | $transaction->commit(); |
35 | 35 | } catch (Exception $e) { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | if ($object_id) { |
23 | 23 | $query->innerJoin($this->table, $this->table . '.term_id = taxonomy_terms.id') |
24 | - ->onCondition("$this->table.object_id = $object_id"); |
|
24 | + ->onCondition("$this->table.object_id = $object_id"); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | return ArrayHelper::getColumn($query->all(), 'term'); |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | public function getTerms($object_id, $name = []) |
17 | 17 | { |
18 | 18 | $query = TaxonomyTerms::find() |
19 | - ->select(TaxonomyTerms::tableName() . '.term') |
|
19 | + ->select(TaxonomyTerms::tableName().'.term') |
|
20 | 20 | ->andFilterWhere(['taxonomy_terms.term' => $name]); |
21 | 21 | |
22 | 22 | if ($object_id) { |
23 | - $query->innerJoin($this->table, $this->table . '.term_id = taxonomy_terms.id') |
|
23 | + $query->innerJoin($this->table, $this->table.'.term_id = taxonomy_terms.id') |
|
24 | 24 | ->onCondition("$this->table.object_id = $object_id"); |
25 | 25 | } |
26 | 26 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $cachedParents = []; |
46 | 46 | |
47 | - $addTerm = function ($parent, $item) use ($object_id, &$cachedParents) { |
|
47 | + $addTerm = function($parent, $item) use ($object_id, &$cachedParents) { |
|
48 | 48 | if ($this->detectLoop($parent, $item)) { |
49 | 49 | throw new InvalidCallException('Loop detected! Cannot add parent as a child!'); |
50 | 50 | } |