Problem/Motivation
As discussed at DrupalCon Atlanta, we want to extend the MenuSource UIPatterns Source plugin so we can decorate it with the rendered content of each menu item (from menu item extras).
This fails with a not found exception, because the method we want to override is private.
Steps to reproduce
Create a new plugin that extends the MenuContent plugin, and attempt to implement getMenuItems().
Whitescreen error.
Proposed resolution
Make MenuSource::getMenuItems a protected method instead of private.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork ui_patterns-3516308
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
freelockMR created.
Comment #4
freelockUpdating status.
Comment #5
mortona2k commentedFixed the error for me.
Comment #6
just_like_good_vibesHello,
thank you for this issue.
the method you want to expose as protected was not really designed to be opened to subclassas and be treated like an internal API.
why not using directly getPropValue to get the tree of items ?
Comment #7
freelockHi,
Ok, I see that method returns the result of getMenuItems(). We can definitely extend that instead, if that's the only place it gets called.
Cheers,
John
Comment #8
freelockOh sorry, looking again, we're not subclassing that method -- we're just calling it. As a private function we cannot use it -- it needs to be protected so we can call it from our subclass's getPropValue() function.
You can see our usage here: https://git.drupalcode.org/project/megamenu_sdc/-/blame/1.0.x/src/Plugin...
... we could create another copy of this code, but much easier to call existing...
Comment #9
just_like_good_vibesHello. i don’t understand your point ?
you can override getPropValue in your subclass to return what your source is supposed to return, at the same time you can also use getPropValue from the parent class, which is not private.
Comment #10
freelockHi,
You're right, I get the same thing from the parent getPropValue method.
Cheers,
John
Comment #11
just_like_good_vibesyou are welcome, we are so happy people enjoy ui patterns 2 :)