File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed
Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 1515 'options ' => [
1616 'label ' => 'Dashboard ' ,
1717 'route ' => [
18- 'route_name ' => 'app::index-redirect ' ,
18+ 'route_name ' => 'dashboard::dashboard-view ' ,
1919 ],
2020 'icon ' => 'c-blue-500 ti-home ' ,
2121 ],
Original file line number Diff line number Diff line change 66
77use Dot \DependencyInjection \Attribute \Inject ;
88use Mezzio \Helper \UrlHelper ;
9+ use Mezzio \Router \RouteResult ;
10+ use Psr \Http \Message \UriInterface ;
911use Twig \Extension \AbstractExtension ;
1012use Twig \TwigFunction ;
1113
@@ -25,22 +27,21 @@ public function getFunctions(): array
2527 ];
2628 }
2729
28- public function getCurrentRoute (): ?string
30+ public function getCurrentRoute (): ?RouteResult
2931 {
30- return $ this ->urlHelper ->getRequest ()?->getUri()?->getPath ();
32+ return $ this ->urlHelper ->getRouteResult ();
3133 }
3234
33- public function isRoute (?string $ route ): bool
35+ public function isRoute (?string $ routeName ): bool
3436 {
35- if (null === $ route ) {
37+ if (null === $ routeName ) {
3638 return false ;
3739 }
3840
39- $ currentRoute = $ this ->getCurrentRoute ();
40- if (null === $ currentRoute ) {
41+ if (null === $ this ->getCurrentRoute ()) {
4142 return false ;
4243 }
4344
44- return $ currentRoute === $ route ;
45+ return $ this -> getCurrentRoute ()-> getMatchedRouteName () === $ routeName ;
4546 }
4647}
Original file line number Diff line number Diff line change 55 {% for page in container %}
66 {% if navigation.isAllowed (page ) %}
77 {% if page.hasChildren () %}
8- <li class =" nav-item dropdown nav-group {% if loop .first %} mT-30 {% endif %} {% if isRoute(page.getOption (' uri ' ) ) %} open {% endif %}" >
8+ <li class =" nav-item dropdown nav-group {% if loop .first %} mT-30 {% endif %} {% if isRoute(page.getOption (' route ' )[ ' route_name ' ] ?? ' ' ) %} open current-route {% endif %}" >
99 <a class =" dropdown-toggle cur-p" {% autoescape false %}{{ pageAttributes(page ) ~ extraAttributes }}{% endautoescape %}>
1010 <span class =" icon-holder" >
1111 <i class =" {{ page.getOption (' icon' ) }}" ></i >
2323 {% else %}
2424 {% if page.hasParent () %}
2525 <li class =" nav-item dropdown" >
26- <a href =" {{ navigation.getHref (page ) }}" class =" {% if isRoute(page.getOption (' uri ' ) ) %} text-primary fw-medium current-route {% endif %} {% autoescape false %}{{ pageAttributes(page ) ~ extraAttributes }}{% endautoescape %}" >
26+ <a href =" {{ navigation.getHref (page ) }}" class =" {% if isRoute(page.getOption (' route ' )[ ' route_name ' ] ?? ' ' ) %} text-primary fw-medium current-route {% endif %} {% autoescape false %}{{ pageAttributes(page ) ~ extraAttributes }}{% endautoescape %}" >
2727 <span >{{ page.getOption (' label' ) }}</span >
2828 </a >
2929 </li >
3030 {% else %}
3131 <li class =" nav-item {% if loop .first %} mT-30 {% endif %}" >
32- <a class =" sidebar-link {% if isRoute(page.getOption (' uri ' ) ) %} text-primary fw-medium current-route {% endif %}" href =" {{ navigation.getHref (page ) }}" {% autoescape false %}{{ pageAttributes(page ) ~ extraAttributes }}{% endautoescape %}>
32+ <a class =" sidebar-link {% if isRoute(page.getOption (' route ' )[ ' route_name ' ] ?? ' ' ) %} text-primary fw-medium current-route {% endif %}" href =" {{ navigation.getHref (page ) }}" {% autoescape false %}{{ pageAttributes(page ) ~ extraAttributes }}{% endautoescape %}>
3333 <span class =" icon-holder" >
3434 <i class =" {{ page.getOption (' icon' ) }}" ></i >
3535 </span >
You can’t perform that action at this time.
0 commit comments