Преглед изворни кода

switch the typehinting to the KnpLab Menu Interface

Thomas Rabaix пре 13 година
родитељ
комит
7992b7d75e

+ 22 - 9
Admin/Admin.php

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

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

@@ -1,5 +1,5 @@
 Advance
 Advance
-=========
+=======
 
 
 By default services who are injected to the admin service are
 By default services who are injected to the admin service are
     method name         |    Service Id
     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
 If you want to modify the service who are going to be injected, add the following code to your
 application's config file:
 application's config file:
+
 .. code-block:: yaml
 .. code-block:: yaml
     # app/config/config.yml
     # app/config/config.yml
     admins:
     admins:

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

@@ -18,7 +18,7 @@ Example :
     use Sonata\AdminBundle\Datagrid\ListMapper;
     use Sonata\AdminBundle\Datagrid\ListMapper;
     use Sonata\AdminBundle\Show\ShowMapper;
     use Sonata\AdminBundle\Show\ShowMapper;
 
 
-    use Knp\Menu\MenuItem;
+    use knp\Menu\ItemInterface as MenuItemInterface;
 
 
     use Application\Sonata\NewsBundle\Entity\Comment;
     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\Datagrid\ListMapper;
     use Sonata\AdminBundle\Show\ShowMapper;
     use Sonata\AdminBundle\Show\ShowMapper;
 
 
-    use Knp\Menu\MenuItem;
+    use knp\Menu\ItemInterface as MenuItemInterface;
 
 
     use Application\Sonata\NewsBundle\Entity\Comment;
     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);
             $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'))) {
             if (!$childAdmin && !in_array($action, array('edit'))) {
                 return;
                 return;