public function menu($patterns = null, $path = '') { if (is_null($patterns)) { $pattern = new Pattern(); $patterns = $pattern->children(); } if (!$patterns->count()) { return null; } $html = ['<ul class="nav">']; foreach ($patterns as $pattern) { if ($pattern->isHidden()) { continue; } $html[] = '<li>'; $html[] = html::a($pattern->url(), '<span>' . $pattern->title() . '</span>', ['class' => $path == $pattern->path() ? 'active' : null]); if ($pattern->isOpen($path)) { $html[] = $this->menu($pattern->children(), $path); } $html[] = '</li>'; } $html[] = '</ul>'; return implode(array_filter($html)); }