Browse Source

Remove the 'getSideMenu' from the CRUDController

Thomas 14 years ago
parent
commit
533e054579
2 changed files with 18 additions and 19 deletions
  1. 15 1
      Admin/Admin.php
  2. 3 18
      Controller/CRUDController.php

+ 15 - 1
Admin/Admin.php

@@ -1002,12 +1002,26 @@ abstract class Admin implements AdminInterface
      *
      * @return MenuItem|false
      */
-    public function getSideMenu($action)
+    public function buildSideMenu($action)
     {
 
         return false;
     }
 
+    /**
+     * @param string $action
+     * @return Knplabs\MenuBundle\Menu
+     */
+    public function getSideMenu($action)
+    {
+
+        if ($this->isChild()) {
+            return $this->getParent()->getSideMenu($action, $this);
+        }
+
+        return $this->buildSideMenu($action);
+    }
+
     /**
      * return the root code
      *

+ 3 - 18
Controller/CRUDController.php

@@ -131,7 +131,7 @@ class CRUDController extends Controller
             'list'              => $this->admin->getList(),
             'admin'             => $this->admin,
             'base_template'     => $this->getBaseTemplate(),
-            'side_menu'         => $this->getSideMenu('list'),
+            'side_menu'         => $this->admin->getSideMenu('list'),
             'breadcrumbs'       => $this->admin->getBreadcrumbs('list'),
         ));
     }
@@ -224,7 +224,7 @@ class CRUDController extends Controller
             'form_groups'    => $this->admin->getFormGroups(),
             'admin'          => $this->admin,
             'base_template'  => $this->getBaseTemplate(),
-            'side_menu'      => $this->getSideMenu('edit'),
+            'side_menu'      => $this->admin->getSideMenu('edit'),
             'breadcrumbs'    => $this->admin->getBreadcrumbs('edit'),
         ));
     }
@@ -321,23 +321,8 @@ class CRUDController extends Controller
             'form_groups'   => $this->admin->getFormGroups(),
             'admin'         => $this->admin,
             'base_template' => $this->getBaseTemplate(),
-            'side_menu'     => $this->getSideMenu('create'),
+            'side_menu'     => $this->admin->getSideMenu('create'),
             'breadcrumbs'   => $this->admin->getBreadcrumbs('create'),
         ));
     }
-
-    /**
-     * @param string $action
-     * @return Knplabs\MenuBundle\Menu
-     */
-    public function getSideMenu($action)
-    {
-        
-        if ($this->admin->isChild()) {
-            return $this->admin->getParent()->getSideMenu($action, $this->admin);
-        }
-
-        return $this->admin->getSideMenu($action);
-    }
-
 }