@@ -8,7 +8,6 @@ |
||
8 | 8 | |
9 | 9 | namespace sibds\components; |
10 | 10 | |
11 | -use Yii; |
|
12 | 11 | use yii\behaviors\TimestampBehavior; |
13 | 12 | use sibds\behaviors\UserDataBehavior; |
14 | 13 | use sibds\behaviors\TrashBehavior; |
@@ -148,6 +148,9 @@ |
||
148 | 148 | return ArrayHelper::map($query->all(), $keyField, $valueField); |
149 | 149 | } |
150 | 150 | |
151 | + /** |
|
152 | + * @param string $t |
|
153 | + */ |
|
151 | 154 | public static function is_closure($t) { |
152 | 155 | return is_object($t) && ($t instanceof Closure); |
153 | 156 | } |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | ]; |
102 | 102 | } |
103 | 103 | |
104 | - if($this->isNestedSet()){ |
|
104 | + if ($this->isNestedSet()) { |
|
105 | 105 | $behaviors['tree'] = ArrayHelper::merge([ |
106 | 106 | 'class' => \creocoder\nestedsets\NestedSetsBehavior::className(), |
107 | 107 | 'leftAttribute' => 'lft', |
108 | 108 | 'rightAttribute' => 'rgt', |
109 | 109 | 'depthAttribute' => 'depth', |
110 | - ], ($this->hasAttribute('tree')?['treeAttribute' => 'tree']:[])); |
|
110 | + ], ($this->hasAttribute('tree') ? ['treeAttribute' => 'tree'] : [])); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $behaviors; |
114 | 114 | } |
115 | 115 | |
116 | - public function isNestedSet(){ |
|
117 | - return $this->hasAttribute('lft')&&$this->hasAttribute('rgt')&&$this->hasAttribute('depth'); |
|
116 | + public function isNestedSet() { |
|
117 | + return $this->hasAttribute('lft') && $this->hasAttribute('rgt') && $this->hasAttribute('depth'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public static function listAll($keyField = 'id', $valueField = 'name', $asArray = true) |
142 | 142 | { |
143 | 143 | $query = static::find(); |
144 | - if ($asArray&&!self::is_closure($valueField)) { |
|
144 | + if ($asArray && !self::is_closure($valueField)) { |
|
145 | 145 | $query->select([$keyField, $valueField])->asArray(); |
146 | 146 | } |
147 | 147 |