Quellcode durchsuchen

add functionalities : add items in dashboard

Charley Maillot vor 13 Jahren
Ursprung
Commit
f8616a82b4

+ 8 - 3
DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

@@ -79,12 +79,17 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
             $groups = $settings['dashboard_groups'];
             $groups = $settings['dashboard_groups'];
 
 
             foreach ($groups as $group_name => $group) {
             foreach ($groups as $group_name => $group) {
-                if(empty($group['items'])) {
+                if (empty($group['items'])) {
                     $groups[$group_name]['items'] = $groupDefaults[$group_name]['items'];
                     $groups[$group_name]['items'] = $groupDefaults[$group_name]['items'];
                 }
                 }
-                if(empty($group['label'])) {
+
+                if (empty($group['label'])) {
                     $groups[$group_name]['label'] = $groupDefaults[$group_name]['label'];
                     $groups[$group_name]['label'] = $groupDefaults[$group_name]['label'];
                 }
                 }
+
+                if (!empty($groups[$group_name]['item_adds'])) {
+                    $groups[$group_name]['items'] = array_merge($groupDefaults[$group_name]['items'], $groups[$group_name]['item_adds']);
+                }
             }
             }
         }
         }
         else {
         else {
@@ -157,7 +162,7 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
         foreach ($defaultAddServices as $attr => $addServiceId) {
         foreach ($defaultAddServices as $attr => $addServiceId) {
             $method = 'set'.$this->camelize($attr);
             $method = 'set'.$this->camelize($attr);
 
 
-            if(isset($addServices[$attr]) || !$definition->hasMethodCall($method)) {
+            if (isset($addServices[$attr]) || !$definition->hasMethodCall($method)) {
                 $definition->addMethodCall($method, array(new Reference(isset($addServices[$attr]) ? $addServices[$attr] : $addServiceId)));
                 $definition->addMethodCall($method, array(new Reference(isset($addServices[$attr]) ? $addServices[$attr] : $addServiceId)));
             }
             }
         }
         }

+ 3 - 0
DependencyInjection/Configuration.php

@@ -54,6 +54,9 @@ class Configuration implements ConfigurationInterface
                             ->arrayNode('items')
                             ->arrayNode('items')
                                 ->prototype('scalar')->end()
                                 ->prototype('scalar')->end()
                             ->end()
                             ->end()
+                            ->arrayNode('item_adds')
+                                ->prototype('scalar')->end()
+                            ->end()
                         ->end()
                         ->end()
                     ->end()
                     ->end()
                 ->end()
                 ->end()

+ 23 - 9
Resources/doc/reference/dashboard.rst

@@ -14,15 +14,15 @@ application's config file:
 
 
 
 
 Some examples of config file:
 Some examples of config file:
-1 - Set the label group
+1 - Set the label group & add all the default items
 .. code-block:: yaml
 .. code-block:: yaml
 
 
     # app/config/config.yml
     # app/config/config.yml
     sonata_admin:
     sonata_admin:
         dashboard:
         dashboard:
-          sonata_page:
-            label: Page
-            items: ~
+            sonata_page:
+                label: Page
+                items: ~
 
 
 2 - Set items group
 2 - Set items group
 .. code-block:: yaml
 .. code-block:: yaml
@@ -30,17 +30,31 @@ Some examples of config file:
     # app/config/config.yml
     # app/config/config.yml
     sonata_admin:
     sonata_admin:
         dashboard:
         dashboard:
-          sonata_page:
-            items:
-                - sonata.page.admin.page
+            sonata_page:
+                items:
+                    - sonata.page.admin.page
 
 
-3 - Add an item of the group
+3 - Add a group with all the default items
 .. code-block:: yaml
 .. code-block:: yaml
 
 
     # app/config/config.yml
     # app/config/config.yml
     sonata_admin:
     sonata_admin:
         dashboard:
         dashboard:
-          sonata_page: ~
+            sonata_page: ~
+
+4 - Add some items in a group
+.. code-block:: yaml
+
+    # app/config/config.yml
+    sonata_admin:
+        dashboard:
+            sonata_page:
+                item_adds:
+                    - sonata.page.admin.myitem1
+                    - sonata.page.admin.myitem2
+
+
+
 
 
 
 
 .. image:: ../images/dashboard.png
 .. image:: ../images/dashboard.png