I am working on a pre-existing project that uses EasyExtends to extend Sonata's page bundle. The project is based on Symfony 3.3.
There already exists in this project a class in namespace Application\Sonata\PageBundle\Admin
called PageAdmin
extending BasePageAdmin.
It contains definitions two functions -- getPageTypes
and configureFormFields
.
When I try to clone the function configureTabMenu
from the vendor copy of this class -- where it works just fine -- to the Application copy, I get the following complaint from the application:
Warning: Declaration of Application\Sonata\PageBundle\Admin\PageAdmin::configureTabMenu(Application\Sonata\PageBundle\Admin\MenuItemInterface $menu, $action, ?Application\Sonata\PageBundle\Admin\AdminInterface $childAdmin = NULL) should be compatible with Sonata\PageBundle\Admin\PageAdmin::configureTabMenu(Knp\Menu\ItemInterface $menu, $action, ?Sonata\AdminBundle\Admin\AdminInterface $childAdmin = NULL) in . (which is being imported from "/usr/src/app/app/config/routing.yml"). Make sure there is a loader supporting the "sonata_admin" type.
This is frankly a bit more than I easily understand. Is there a simple way to override the existing configureFormFields() method from my vendor folder?
====
Edit #1: Removing the type hinting (which is ill-advised as a long-term strategy but useful for debugging) subs one warning for another. I then get this warning text:
Warning: Declaration of Application\Sonata\PageBundle\Admin\PageAdmin::configureTabMenu($menu, $action, $childAdmin = NULL) should be compatible with Sonata\PageBundle\Admin\PageAdmin::configureTabMenu(Knp\Menu\ItemInterface $menu, $action, ?Sonata\AdminBundle\Admin\AdminInterface $childAdmin = NULL) in . (which is being imported from "/usr/src/app/app/config/routing.yml"). Make sure there is a loader supporting the "sonata_admin" type.
====
Edit #2: Changing the method signature to Knp\Menu\ItemInterface $menu, $action, Sonata\AdminBundle\Admin\AdminInterface $childAdmin = NULL
gives me this instead:
Warning: Declaration of Application\Sonata\PageBundle\Admin\PageAdmin::configureTabMenu(Application\Sonata\PageBundle\Admin\Knp\Menu\ItemInterface $menu, $action, ?Application\Sonata\PageBundle\Admin\Sonata\AdminBundle\Admin\AdminInterface $childAdmin = NULL) should be compatible with Sonata\PageBundle\Admin\PageAdmin::configureTabMenu(Knp\Menu\ItemInterface $menu, $action, ?Sonata\AdminBundle\Admin\AdminInterface $childAdmin = NULL) in . (which is being imported from "/usr/src/app/app/config/routing.yml"). Make sure there is a loader supporting the "sonata_admin" type.
subs one warning for another
it's the same problem, you can't just remove the type hinting they have to be the same class in the hint as that of the parent, or interface. – ArtisticPhoenix