protected function iterateMenu($children) { foreach ($children as $key => $row) { $isEditable = !empty($row['script_admin_url']) || !empty($row['document_name']); if (!$isEditable) { unset($children[$key]); continue; } $item = new SitemapModel($row); $children[$key] = ['name' => $row['name'], 'link' => '#', 'children' => [['name' => 'Редактировать', 'link' => $item->getEditLink()]]]; if (!empty($row['aChild'])) { $children[$key]['children'] = array_merge($children[$key]['children'], $this->iterateMenu($row['aChild'])); } } return $children; }