Selaa lähdekoodia

switch the typehinting to the KnpLab Menu Interface

Thomas Rabaix 13 vuotta sitten
vanhempi
commit
7992b7d75e

+ 22 - 9
Admin/Admin.php

@@ -36,7 +36,8 @@ use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface;
 use Sonata\AdminBundle\Route\RouteCollection;
 use Sonata\AdminBundle\Model\ModelManagerInterface;
 
-use Knp\Menu\MenuFactory;
+use knp\Menu\FactoryInterface as MenuFactoryInterface;
+use knp\Menu\ItemInterface as MenuItemInterface;
 use Knp\Menu\MenuItem;
 
 abstract class Admin implements AdminInterface, DomainObjectInterface
@@ -332,7 +333,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
     protected $menu;
 
     /**
-     * @var \Knp\Menu\MenuFactory
+     * @var \Knp\Menu\MenuFactoryInterface
      */
     protected $menuFactory;
 
@@ -403,12 +404,12 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
     }
 
     /**
-     * @param \Knp\Menu\MenuItem $menu
+     * @param \knp\Menu\ItemInterface $menu
      * @param $action
      * @param null|Admin $childAdmin
      * @return void
      */
-    protected function configureSideMenu(MenuItem $menu, $action, Admin $childAdmin = null)
+    protected function configureSideMenu(MenuItemInterface $menu, $action, Admin $childAdmin = null)
     {
 
     }
@@ -1647,7 +1648,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
      * @param \Knp\Menu\MenuItem|null $menu
      * @return array
      */
-    public function buildBreadcrumbs($action, MenuItem $menu = null)
+    public function buildBreadcrumbs($action, MenuItemInterface $menu = null)
     {
         if (isset($this->breadcrumbs[$action])) {
             return $this->breadcrumbs[$action];
@@ -2073,31 +2074,43 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         return $this->formTheme;
     }
 
-    public function setFilterTheme($filterTheme)
+    /**
+     * @param array $filterTheme
+     * @return void
+     */
+    public function setFilterTheme(array $filterTheme)
     {
         $this->filterTheme = $filterTheme;
     }
 
+    /**
+     * @return array
+     */
     public function getFilterTheme()
     {
         return $this->filterTheme;
     }
 
+    /**
+     * @param AdminExtensionInterface $extension
+     * @return void
+     */
     public function addExtension(AdminExtensionInterface $extension)
     {
         $this->extensions[] = $extension;
     }
 
     /**
-     * @param \Knp\Menu\MenuFactory $menuFactory
+     * @param \knp\Menu\FactoryInterface $menuFactory
+     * @return void
      */
-    public function setMenuFactory(MenuFactory $menuFactory)
+    public function setMenuFactory(MenuFactoryInterface $menuFactory)
     {
         $this->menuFactory = $menuFactory;
     }
 
     /**
-     * @return \Knp\Menu\MenuFactory
+     * @return \Knp\Menu\FactoryInterface
      */
     public function getMenuFactory()
     {

+ 2 - 1
Resources/doc/reference/advance.rst

@@ -1,5 +1,5 @@
 Advance
-=========
+=======
 
 By default services who are injected to the admin service are
     method name         |    Service Id
@@ -19,6 +19,7 @@ Note: %manager-type% is replace by the manager type (orm, odm...)
 
 If you want to modify the service who are going to be injected, add the following code to your
 application's config file:
+
 .. code-block:: yaml
     # app/config/config.yml
     admins:

+ 1 - 1
Resources/doc/reference/update.rst

@@ -18,7 +18,7 @@ Example :
     use Sonata\AdminBundle\Datagrid\ListMapper;
     use Sonata\AdminBundle\Show\ShowMapper;
 
-    use Knp\Menu\MenuItem;
+    use knp\Menu\ItemInterface as MenuItemInterface;
 
     use Application\Sonata\NewsBundle\Entity\Comment;
 

+ 2 - 2
Resources/doc/tutorial/creating_your_first_admin_class/defining_admin_class.rst

@@ -22,7 +22,7 @@ First, you need to create an Admin/PostAdmin.php file
     use Sonata\AdminBundle\Datagrid\ListMapper;
     use Sonata\AdminBundle\Show\ShowMapper;
 
-    use Knp\Menu\MenuItem;
+    use knp\Menu\ItemInterface as MenuItemInterface;
 
     use Application\Sonata\NewsBundle\Entity\Comment;
 
@@ -99,7 +99,7 @@ First, you need to create an Admin/PostAdmin.php file
             $queryBuilder->setParameter('status', Comment::STATUS_MODERATE);
         }
 
-        protected function configureSideMenu(MenuItem $menu, $action, Admin $childAdmin = null)
+        protected function configureSideMenu(MenuItemInterface $menu, $action, Admin $childAdmin = null)
         {
             if (!$childAdmin && !in_array($action, array('edit'))) {
                 return;