Procházet zdrojové kódy

Add option show_in_dashboard

Pascal Burkhard před 14 roky
rodič
revize
1d7d3f7bb9

+ 19 - 0
Admin/Pool.php

@@ -41,6 +41,25 @@ class Pool
 
         return $groups;
     }
+    
+    public function getDashboardGroups()
+    {
+
+        $groups = array();
+
+        foreach ($this->configuration as $configuration) {
+            
+            if($configuration['options']['show_in_dashboard']) {
+                if (!isset($groups[$configuration['group']])) {
+                    $groups[$configuration['group']] = array();
+                }
+
+                $groups[$configuration['group']][$configuration['code']] = $this->getInstance($configuration['code']);
+            }
+        }
+
+        return $groups;
+    }
 
     /**
      * The admin classes are lazy loaded to avoid overhead

+ 1 - 1
Controller/CoreController.php

@@ -202,7 +202,7 @@ class CoreController extends Controller
     {
 
         return $this->render('SonataBaseApplicationBundle:Core:dashboard.html.twig', array(
-            'groups' => $this->get('sonata_base_application.admin.pool')->getGroups(),
+            'groups' => $this->get('sonata_base_application.admin.pool')->getDashboardGroups(),
             'base_template'  => $this->getBaseTemplate(),
         ));
     }

+ 8 - 0
DependencyInjection/SonataBaseApplicationExtension.php

@@ -87,6 +87,14 @@ class SonataBaseApplicationExtension extends Extension
             if (!isset($configuration['children'])) {
                 $configuration['children'] = array();
             }
+            
+            if (!isset($configuration['options'])) {
+                $configuration['options'] = array();
+            }
+            
+            if (!isset($configuration['options']['show_in_dashboard'])) {
+                $configuration['options']['show_in_dashboard'] = true;
+            }
 
             $definition->addMethodCall('addConfiguration', array($code, $configuration));
         }