GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 951ad1...29ba67 )
by Alexey
08:55
created

BFacetedProductParamVariant::reindex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 16
loc 16
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 8.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2016 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
Yii::import('backend.modules.product.components.FacetIndexer');
9
/**
10
 * Class BFacetedProductParamVariant
11
 * @property BProductParamVariant $owner
12
 * @mixin DaoParametersBehavior
13
 */
14
class BFacetedProductParamVariant extends SActiveRecordBehavior
15
{
16
  protected $oldName;
17
18
  public function init()
19
  {
20
    parent::init();
21
22
    $this->attachBehavior('daoParametersBehavior', 'frontend.share.behaviors.DaoParametersBehavior');
23
  }
24
25
  public function afterFind($event)
26
  {
27
    $this->oldName = $this->owner->name;
28
  }
29
30
  public function afterSave($event)
31
  {
32
    parent::afterSave($event);
33
34
    if( $this->oldName != $this->owner->name )
35
      $this->reindex();
36
  }
37
38
39
  /**
40
   * @return string
41
   */
42 View Code Duplication
  private function reindex()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
  {
44
    $reindexProductIdList = $this->getReindexProductIdList($this->owner->param_id);
45
    $removeParameterNameId = $this->owner->param_id;
46
    Yii::app()->attachEventHandler('onEndRequest', function($event) use($reindexProductIdList, $removeParameterNameId) {
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
      ViewHelper::showFlash('Индексация фильтра началсь и может занять несколько минут');
48
49
      Utils::finishRequest();
50
      Utils::longLife(60);
51
52
      $facetIndexer = new FacetIndexer();
53
54
      $facetIndexer->clearIndexByParameterNameIdList(array($removeParameterNameId));
55
      $facetIndexer->reindexProducts($reindexProductIdList);
56
    });
57
  }
58
59 View Code Duplication
  private function getReindexProductIdList($parameterNameId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
  {
61
    $criteria = new CDbCriteria();
62
    $criteria->distinct = true;
63
    $criteria->select = 'product_id';
64
    $criteria->compare('param_id', $parameterNameId);
65
66
    return CHtml::listData($this->getParametersByCriteria($criteria, false, 'product_id'), 'product_id', 'product_id');
67
  }
68
}