-
src/Screen/Actions/Menu.php
Open in GitHubclass Menu extends Link { // public function __construct() { $this ->addBeforeRender(function () { $href = $this->get('href'); if ($href !== null) { return; } $slug = $this->getSlug(); $this ->set('data-bs-toggle', 'collapse') ->set('href', '#menu-' . $slug); }) ->addBeforeRender(function () { if ($this->get('active') !== null) { return; } $active = collect([]) ->merge($this->get('list')) ->map(function (Menu $menu) { return $menu->get('href'); }) ->push($this->get('href')) ->filter() ->map(function ($href) { return [ $href, $href . '?*', $href . '/*', ]; }) ->flatten(); $this->set('active', $active->toArray()); }); } // }