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

Set current uri #55

Merged
merged 4 commits into from
Jul 30, 2011
Merged

Set current uri #55

merged 4 commits into from
Jul 30, 2011

Conversation

uwej711
Copy link
Contributor

@uwej711 uwej711 commented Jul 30, 2011

This PR extends #53 to automatically set the current uri from the request in MenuHelper.

benjamindulau and others added 4 commits July 27, 2011 22:29
Also, the depth default value is now 1 instead of null, which is IMO the most common use case.
* Default of the depth option is back to "null"
To make adding the class current to the current menu item work, there
needs to be a way to inform the menu of the current request uri. This
can be done, when the menu is fetched from the menu provider in the
helper.
mbontemps added a commit that referenced this pull request Jul 30, 2011
@mbontemps mbontemps merged commit 9ef5600 into KnpLabs:master Jul 30, 2011
@@ -37,7 +37,9 @@ class MenuHelper extends Helper implements \ArrayAccess
*/
public function get($name)
{
return $this->provider->getMenu($name);
$menu = $this->provider->getMenu($name);
$menu->setCurrentUri($this->container->get('request')->getRequestUri());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes an issue when rendering the menu in a subrequest as the request uri will be the wrong one and you force using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make this configurable? I think there are cases where no subrequests are used ... or is there a better way to find out the original uri?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a subrequest, you cannot know the main request uri, even more when the subrequest is delayed by using ESI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what do you think about making that configurable? From what you said I guess marking the current menu item automatically will never work when using sub request.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you find a solution to the issue? or how could an ESI sub request for the menu with correct highlighting work? pass a magical parameter to highlight the right entry? maybe we could add support for passing the highlighted path as a get parameter with configurable name?...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, makes more sense than randomly adding something and the users of the lib needing to roll their own thing. shall we create an issue on the issue tracker for this topic?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah probably. It would be easier to track it that way than commenting on another PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this also has a relation to the issue 48 #48 by @cirpo . should we create a new issue or discuss in 48?

@uwej711: or was there a different reason for needing the request url known in the menu?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is just about lazyness to avoid having to set the current uri when building the menu :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #56 to track this further. its a general issue in fact. but i think uwe should still check out #48 because we wanted to solve that problem originally...

@bamarni bamarni mentioned this pull request Nov 9, 2012
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

Successfully merging this pull request may close these issues.

5 participants