Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

add method to remove MenuItem from menu #113

Merged
merged 2 commits into from
Jan 14, 2020
Merged

add method to remove MenuItem from menu #113

merged 2 commits into from
Jan 14, 2020

Conversation

lduer
Copy link
Contributor

@lduer lduer commented Jan 10, 2020

Contribution to #111

As I haven't worked with KnpMenu, I've only added the suggested Code from the Issue.

Is it correct to detect the MenuItem by $name?

And the KnpMenuBundle is no requirement, so I need to detect by Knp\Menu\MenuItem class as string?

if (is_subclass_of($item, 'Knp\Menu\MenuItem') && isset($this->menuRootItems[$item->getName()])) {
            unset($this->menuRootItems[$item->getName()]);

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I updated the documentation (see here)
  • I agree that this code is used in AdminLTEBundle and will be published under the MIT license

@kevinpapst
Copy link
Owner

I am not sure without checking the code myself. The KnpMenu integration is something that was already there when I forked the bundle.

But I added KnpMenu support to the Demo application, you just have to clone/composer install & then switch this config key for testing:
https://github.com/kevinpapst/AdminLTEBundle-Demo/blob/master/config/packages/admint_lte.yaml#L41

@lduer
Copy link
Contributor Author

lduer commented Jan 14, 2020

Hi Kevin,
After checking the AdminLTEBundle-Demo, this is the result:

  • removeItem() is working for the MenuEvent with the commited code.
  • The KnpMenu uses the KnpMenuEvent and the KnpMenu already has a removeChildren()function inside the MenuItem-Class which is used there.

So I think the submitted code is enough.

Copy link
Owner

@kevinpapst kevinpapst left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for the detailed test @lduer 👍

@kevinpapst kevinpapst merged commit f5a450b into kevinpapst:master Jan 14, 2020
@kevinpapst kevinpapst added the enhancement New feature or request label Jan 14, 2020
@kevinpapst
Copy link
Owner

I created a new release, if you need it asap: https://github.com/kevinpapst/AdminLTEBundle/releases/tag/3.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
2 participants