@@ 115-133 (lines=19) @@ | ||
112 | ||
113 | $result = []; |
|
114 | ||
115 | foreach ($rows as $row) { |
|
116 | $parent = ArrayHelper::getValue($row, $this->modelParentAttribute, 0); |
|
117 | $item = [ |
|
118 | 'id' => ArrayHelper::getValue($row, $this->modelIdAttribute, 0), |
|
119 | 'parent' => $parent ?: '#', |
|
120 | 'text' => ArrayHelper::getValue($row, $this->modelLabelAttribute, 'item'), |
|
121 | 'a_attr' => [ |
|
122 | 'data-id' => $row[$this->modelIdAttribute], |
|
123 | 'data-parent_id' => $row[$this->modelParentAttribute] |
|
124 | ], |
|
125 | 'children' => true, |
|
126 | ]; |
|
127 | ||
128 | if (null !== $this->varyByTypeAttribute) { |
|
129 | $item['type'] = $row[$this->varyByTypeAttribute]; |
|
130 | } |
|
131 | ||
132 | $result[$row[$this->modelIdAttribute]] = $item; |
|
133 | } |
|
134 | ||
135 | Yii::$app->cache->set( |
|
136 | $cacheKey, |
@@ 128-145 (lines=18) @@ | ||
125 | ||
126 | $result = []; |
|
127 | ||
128 | foreach ($rows as $row) { |
|
129 | $parent = ArrayHelper::getValue($row, $this->modelParentAttribute, 0); |
|
130 | $item = [ |
|
131 | 'id' => ArrayHelper::getValue($row, $this->modelIdAttribute, 0), |
|
132 | 'parent' => ($parent) ? $parent : '#', |
|
133 | 'text' => ArrayHelper::getValue($row, $this->modelLabelAttribute, 'item'), |
|
134 | 'a_attr' => [ |
|
135 | 'data-id' => $row[$this->modelIdAttribute], |
|
136 | 'data-parent_id' => $row[$this->modelParentAttribute] |
|
137 | ], |
|
138 | ]; |
|
139 | ||
140 | if (null !== $this->varyByTypeAttribute) { |
|
141 | $item['type'] = $row[$this->varyByTypeAttribute]; |
|
142 | } |
|
143 | ||
144 | $result[$row[$this->modelIdAttribute]] = $item; |
|
145 | } |
|
146 | ||
147 | if ($this->cacheJson) { |
|
148 | $encoded = json_encode(array_values($result)); |