Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active state in RenderService in dev env #3

Open
jazzzpor opened this issue Jul 19, 2017 · 0 comments
Open

Active state in RenderService in dev env #3

jazzzpor opened this issue Jul 19, 2017 · 0 comments

Comments

@jazzzpor
Copy link

When using the "get_menu" Twig function, the active state for the menu items is not properly detected in the 'dev' environment.

The problem lies in the RenderService:

$url = $this->router->generate('_slug', array('url' => $node['nodeTranslation']['url']));

if ($this->router->getContext()->getPathInfo() == $url) {
    $active = true;
}

Because I am working in 'dev' environment, the base url the context of the router is "/app_dev.php".
The path info of the context does not contain the base url so it will never match the generated url.

Currently I implemented a hack like this:

if ($this->router->getContext()->getPathInfo() === str_replace('/app_dev.php', '', $url)) {
     $active = true;
}

It's not pretty so I'm hoping you have a better solution ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant