@@ -18,9 +18,9 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $this->joinTables(); |
| 20 | 20 | |
| 21 | - if(!empty($tags)) |
|
| 21 | + if (!empty($tags)) |
|
| 22 | 22 | $this->getQuery() |
| 23 | - ->andFilterWhere([ TaxonomyTerms::tableName() . '.term' => $tags ]); |
|
| 23 | + ->andFilterWhere([TaxonomyTerms::tableName().'.term' => $tags]); |
|
| 24 | 24 | |
| 25 | 25 | return $this->getQuery(); |
| 26 | 26 | } |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | |
| 23 | 23 | /** @var ActiveRecord $this->owner */ |
| 24 | 24 | $this->getQuery() |
| 25 | - ->leftJoin($this->taxonomy->table, $this->taxonomy->table . '.object_id = ' . $model::tableName() . '.id') |
|
| 26 | - ->leftJoin(TaxonomyTerms::tableName(), TaxonomyTerms::tableName() . '.id = ' . $this->taxonomy->table . '.term_id'); |
|
| 25 | + ->leftJoin($this->taxonomy->table, $this->taxonomy->table.'.object_id = '.$model::tableName().'.id') |
|
| 26 | + ->leftJoin(TaxonomyTerms::tableName(), TaxonomyTerms::tableName().'.id = '.$this->taxonomy->table.'.term_id'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -13,7 +13,7 @@ |
||
| 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', |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | /* @var $this yii\web\View */ |
| 6 | 6 | /* @var $model nkostadinov\taxonomy\models\TaxonomyDef */ |
| 7 | 7 | |
| 8 | -$this->title = 'Update Taxonomy Def: ' . ' ' . $model->name; |
|
| 8 | +$this->title = 'Update Taxonomy Def: '.' '.$model->name; |
|
| 9 | 9 | $this->params['breadcrumbs'][] = ['label' => 'Taxonomy Defs', 'url' => ['index']]; |
| 10 | 10 | $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; |
| 11 | 11 | $this->params['breadcrumbs'][] = 'Update'; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | ob_start(); |
| 30 | 30 | //$this->migrationPath = Yii::getAlias($migrationPath); |
| 31 | - if($this->beforeAction('up')) |
|
| 31 | + if ($this->beforeAction('up')) |
|
| 32 | 32 | $this->migrateUp($class); |
| 33 | 33 | $result = ob_get_contents(); |
| 34 | 34 | return $result; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | ob_start(); |
| 40 | 40 | //$this->migrationPath = Yii::getAlias($migrationPath); |
| 41 | - if($this->beforeAction('down')) |
|
| 41 | + if ($this->beforeAction('down')) |
|
| 42 | 42 | $this->migrateDown($class); |
| 43 | 43 | $result = ob_get_contents(); |
| 44 | 44 | return $result; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function actionIndex() |
| 71 | 71 | { |
| 72 | - if(!$this->getComponent()->isInstalled()) |
|
| 72 | + if (!$this->getComponent()->isInstalled()) |
|
| 73 | 73 | throw new InvalidConfigException("Please run the migration first!"); |
| 74 | 74 | |
| 75 | 75 | $searchModel = new TaxonomyDefSearch(); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | public function getComponent() |
| 194 | 194 | { |
| 195 | - if(\Yii::$app->has($this->module->component)) |
|
| 195 | + if (\Yii::$app->has($this->module->component)) |
|
| 196 | 196 | return \Yii::$app->{$this->module->component}; |
| 197 | 197 | else |
| 198 | 198 | throw new InvalidConfigException("Cannot find taxonomy component({$this->module->component})"); |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | public function actionInstall() |
| 202 | 202 | { |
| 203 | - if(!$this->getComponent()->isInstalled() and \Yii::$app->request->isPost) { |
|
| 203 | + if (!$this->getComponent()->isInstalled() and \Yii::$app->request->isPost) { |
|
| 204 | 204 | //start installation |
| 205 | - if($this->getComponent()) { |
|
| 205 | + if ($this->getComponent()) { |
|
| 206 | 206 | $this->getComponent()->install(); |
| 207 | 207 | |
| 208 | - $this->redirect(['/'.$this->module->id . '/' . $this->id . '/index']); |
|
| 208 | + $this->redirect(['/'.$this->module->id.'/'.$this->id.'/index']); |
|
| 209 | 209 | } else |
| 210 | 210 | throw new InvalidConfigException("Cannot find taxonomy component({$this->module->component})"); |
| 211 | 211 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | public function getTerm($termName, $reload = false) |
| 64 | 64 | { |
| 65 | - if(!isset($this->_taxonomy[$termName]) || $reload) { |
|
| 65 | + if (!isset($this->_taxonomy[$termName]) || $reload) { |
|
| 66 | 66 | $tax = TaxonomyDef::findOne(['name' => $termName]); |
| 67 | 67 | \Yii::getLogger()->log("Initialising term $termName", Logger::LEVEL_INFO, 'nkostadinov.taxonomy.terms'); |
| 68 | 68 | $this->_taxonomy[$termName] = \Yii::createObject($tax->attributes); |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | $this->joinTables(); |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - if(!empty($name)) |
|
| 20 | + if (!empty($name)) |
|
| 21 | 21 | $this->getQuery() |
| 22 | - ->andFilterWhere([ TaxonomyTerms::tableName() . '.term' => $name ]); |
|
| 22 | + ->andFilterWhere([TaxonomyTerms::tableName().'.term' => $name]); |
|
| 23 | 23 | |
| 24 | - if(!empty($value)) |
|
| 24 | + if (!empty($value)) |
|
| 25 | 25 | $this->getQuery() |
| 26 | - ->andFilterWhere([ $this->taxonomy->table . '.value' => $value ]); |
|
| 26 | + ->andFilterWhere([$this->taxonomy->table.'.value' => $value]); |
|
| 27 | 27 | |
| 28 | 28 | return $this->getQuery(); |
| 29 | 29 | } |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class TagTerm extends BaseTerm |
| 15 | 15 | { |
| 16 | - public $templateFile = '@nkostadinov/taxonomy/migrations/template/tag.php' ; |
|
| 16 | + public $templateFile = '@nkostadinov/taxonomy/migrations/template/tag.php'; |
|
| 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) { |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class CategoryTerm extends TagTerm implements IHierarchicalTerm |
| 13 | 13 | { |
| 14 | - public $templateFile = '@nkostadinov/taxonomy/migrations/template/category.php' ; |
|
| 14 | + public $templateFile = '@nkostadinov/taxonomy/migrations/template/category.php'; |
|
| 15 | 15 | |
| 16 | 16 | public function getTerms($object_id, $name = []) |
| 17 | 17 | { |
| 18 | 18 | $query = (new Query()) |
| 19 | - ->select(TaxonomyTerms::tableName() . '.term') |
|
| 19 | + ->select(TaxonomyTerms::tableName().'.term') |
|
| 20 | 20 | ->from(TaxonomyTerms::tableName()) |
| 21 | - ->innerJoin($this->table, $this->table . '.term_id = taxonomy_terms.id', |
|
| 21 | + ->innerJoin($this->table, $this->table.'.term_id = taxonomy_terms.id', |
|
| 22 | 22 | [':object_id' => $object_id]) |
| 23 | 23 | ->andFilterWhere(['taxonomy_terms.term' => $name]); |
| 24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | $result = []; |
| 30 | - foreach($query->all() as $v) { |
|
| 30 | + foreach ($query->all() as $v) { |
|
| 31 | 31 | $result[] = $v['term']; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $cachedParents = []; |
| 40 | 40 | |
| 41 | - $addTerm = function ($parent, $item) use ($object_id, &$cachedParents) { |
|
| 41 | + $addTerm = function($parent, $item) use ($object_id, &$cachedParents) { |
|
| 42 | 42 | $term = $this->getTaxonomyTerm($item); |
| 43 | 43 | $data['term_id'] = $term->id; |
| 44 | 44 | $data['object_id'] = $object_id; |