Code Duplication    Length = 18-19 lines in 2 locations

src/actions/AdjacencyList/FullTreeDataAction.php 1 location

@@ 104-121 (lines=18) @@
101
102
            $result = [];
103
104
            foreach ($rows as $row) {
105
                $parent = ArrayHelper::getValue($row, $this->modelParentAttribute, 0);
106
                $item = [
107
                    'id' => ArrayHelper::getValue($row, $this->modelIdAttribute, 0),
108
                    'parent' => ($parent) ? $parent : '#',
109
                    'text' => ArrayHelper::getValue($row, $this->modelLabelAttribute, 'item'),
110
                    'a_attr' => [
111
                        'data-id' => $row[$this->modelIdAttribute],
112
                        'data-parent_id' => $row[$this->modelParentAttribute]
113
                    ],
114
                ];
115
116
                if (null !== $this->varyByTypeAttribute) {
117
                    $item['type'] = $row[$this->varyByTypeAttribute];
118
                }
119
120
                $result[$row[$this->modelIdAttribute]] = $item;
121
            }
122
123
            Yii::$app->cache->set(
124
                $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,