Then maybe we can have menu metadata mapping? Blindly calling getParent just seems wrong to me..


David Buchmann <notifications@github.com> a écrit :

>> +
>> +To enable the prefix voter, set the configuration key
>> +``symfony_cmf_menu.voters.uri_prefix: ~``.
>> +
>> +RequestParentContentIdentityVoter
>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> +
>> +This voter has the same logic of looking for a request attribute to
>get
>> +the current content, but calls ``getParent`` on it. This parent is
>> +compared to the ``content`` of the menu item. That way, content that
>does
>> +not have its own menu entry but a parent that does have a menu item
>can
>> +trigger the right menu entry to be highlighted.
>> +
>> +To use this voter you need to set up a custom service configured
>with
>> +the request attribute to look for the content and your model class
>to
>> +avoid calling getParent on objects that do not have that method.
>This
>
>because it knows nothing of doctrine. it would work with any model
>class. we could do it phpcr-odm specific, but there is also a
>performance penalty. the metadata would be checked at runtime,
>potentially on a lot of menu items. we could then cache of course, but
>i'd rather do it simple here. its not that those classes are huge if
>somebody needs to roll his own...
>
>---
>Reply to this email directly or view it on GitHub:
>https://github.com/symfony-cmf/symfony-cmf-docs/pull/134/files#r4107143

-- 
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.