浏览代码

Fix menu builder listener code sample (#4293)

The icon is now defined onto the extras options
and the label can be set directly from child creation options.
Sullivan SENECHAL 8 年之前
父节点
当前提交
4c060971c1
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      Resources/doc/cookbook/recipe_knp_menu.rst

+ 5 - 5
Resources/doc/cookbook/recipe_knp_menu.rst

@@ -151,12 +151,12 @@ You can modify the menu via events easily. You can register as many listeners as
         {
             $menu = $event->getMenu();
 
-            $child = $menu->addChild('reports', array(
+            $child = $menu->addChild('reports', [
+                'label' => 'Daily and monthly reports',
                 'route' => 'app_reports_index',
-                'labelAttributes' => array('icon' => 'fa fa-bar-chart'),
-            ));
-
-            $child->setLabel('Daily and monthly reports');
+            ])->setExtras([
+                'icon' => '<i class="fa fa-bar-chart"></i>',
+            ]);
         }
     }