sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Support for the latest version of the KNPMenu bundle #1712

Closed ozzmaster closed 10 years ago

ozzmaster commented 10 years ago

The Mopa-Bootstrap bundle, which I use in my project, gives an error:

PHP Fatal error: Interface 'Knp\Menu\Factory\ExtensionInterface' not found in /home/otto/wwwroots/BitBucket/iga-core-symfony/iga-core-2.1/vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Navbar/Factory/NavbarExtension.php on line 9

I know this is not this project, but this project surely needs to look at staying current.

When will this project use the latest version of KNPMenu Bundle? Is there something i can do to update the KNPMenu bundle version used by this project?

Thanks!

ozzmaster commented 10 years ago

I got this tip from someone replying to the issue I logged on the Mopa Bootstrap bundle:

``A temporary solution for this issue is to define the knp-menu/knp-menu-bundle in composer as follows:

"knplabs/knp-menu": "dev-master as 1.1",
"knplabs/knp-menu-bundle": "dev-master as 1.1",

The issue is that Sonata-Admin has a requirement of KnpMenu 1.1, but 2.0 is fully compatible as well. So you just need to install KnpMenu 2.0, but trick Sonata Admin to think it's actually 1.1, to satistfy it's dependencies.``

Is it possible to just update the requirements of the Sonata Admin Bundle to use version 2 of the KnpMenu bundle?

stof commented 10 years ago

@ozzmaster 2.0 and 1.1 are not fully compatible (otherwise it would not be a v2)

ozzmaster commented 10 years ago

@stof I saw that, yes. Implementing the "alias" in composer.json allowed me to continue development on my frontend which uses MopaBootstrap.

I am using MopaBootstrap's base template like this: {% extends('MopaBootstrapBundle::base.html.twig') %} Only on my public site.

The Sonata Admin bundle handles the entire admin site. I am really able to do everything I need to using this admin bundle. Great work!

Using version "dev-master" of KnpMenuBundle I get the dashboard of Sonata admin bundle open, but on another page I get: "Call to undefined method Knp\Menu\MenuItem::setCurrentUri()"

I am carrying on with frontend development, because much of my admin site work for this phase of my project is DONE.

Are there any plans to use the latest version of KNPMenuBundle in Sonata Admin Bundle?

stof commented 10 years ago

Well, it currently uses the latest stable version.

I don't know if supporting both 1.x and 2.0-dev in Sonata would be possible with some sort of adapter (I haven't used SonataAdminBundle since a while), but dropping the support of the stable version to require the unstable version of KnpMenu seems a bad idea

ozzmaster commented 10 years ago

@stof Agreed.

Well, my project is an internal one and luckily I'm kept busy by other paid work. I'll keep an eye out for a stable KNPMenu Bundle version 2.

I'll ask the KNPMenu bundle people what I might be able to do to get their V2 stable.

phiamo commented 10 years ago

@stof i am using sonata admin bundle knp menu bundle and mopa bootstrap bundle in a few projects together all i needed to do to get the trick done was adding a check on the setCurrentUri call in Admin.php and PhpcrMenuProvider.php in CmfMenuBundle:

Admin.php line 1394

        // intemediate fix to support both knp menu 1.1 and knp menu 2.0 
        if (is_callable($menu, 'setCurrentUri')) {
            $menu->setCurrentUri($this->getRequest()->getBaseUrl().$this->getRequest()->getPathInfo());
        }

PhpcrMenuProvider.php line 140:

        // intemediate fix to support both knp menu 1.1 and knp menu 2.0 
        if (is_callable($menuItem, 'setCurrentUri')) {
            $menuItem->setCurrentUri($this->request->getRequestUri());
        }

this is atm a local hack, but would be nice to at least be abled to use sonataadmin until everything else is updated in a dev env

stof commented 10 years ago

@phiamo this is not the only difference between KnpMenu 1.1 and 2.0

phiamo commented 10 years ago

sure it isnt but its the most complained reason why e.g. mopabootstrapbundle >=3.0 doesnt work with sonataadminbundle .... it only allows a "working" evn which doesnt throw exceptions into one's face .... its not meant to be the solution. just a little help for projects currently developed and probably going up the versions of sonataadmin if its finally released with knpmenu 2.0 support

scr4tchy commented 10 years ago

Hello,

Could you patch to be able to solve this bug. It lasts since more than one month and is really annoying ... One month that I hope for a fix and developing other parts of the website... but now..

At least, create a branch.. You won't be able to stay at V1.1 forever... =/ And we can't use the awesome phiamo MopaBootstrapBundle which is Top6 on KnpBundles... You'll lost your Top2 position or going to be forked if it continues like that... Nobody uses KnpMenu 1.1 anymore...

scr4tchy commented 10 years ago

Oh, by the way. I wanted to mention that in addition to the problem about KnpMenu, the layout is completely broken for many users, either with KnpMenu 1 or 2. A lot of topics on StackOverflow, Google & The Google Groups..

rande commented 10 years ago

without a screenshot is very hard to see the trouble with the layout