Code Duplication    Length = 18-19 lines in 2 locations

src/actions/AdjacencyList/FullTreeDataAction.php 1 location

@@ 112-129 (lines=18) @@
109
110
            $result = [];
111
112
            foreach ($rows as $row) {
113
                $parent = ArrayHelper::getValue($row, $this->modelParentAttribute, 0);
114
                $item = [
115
                    'id' => ArrayHelper::getValue($row, $this->modelIdAttribute, 0),
116
                    'parent' => ($parent) ? $parent : '#',
117
                    'text' => ArrayHelper::getValue($row, $this->modelLabelAttribute, 'item'),
118
                    'a_attr' => [
119
                        'data-id' => $row[$this->modelIdAttribute],
120
                        'data-parent_id' => $row[$this->modelParentAttribute]
121
                    ],
122
                ];
123
124
                if (null !== $this->varyByTypeAttribute) {
125
                    $item['type'] = $row[$this->varyByTypeAttribute];
126
                }
127
128
                $result[$row[$this->modelIdAttribute]] = $item;
129
            }
130
131
            Yii::$app->cache->set(
132
                $cacheKey,

src/actions/AdjacencyList/PartialTreeDataAction.php 1 location

@@ 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,