فهرست منبع

Update advance.rst

*
zhil 12 سال پیش
والد
کامیت
ab08dfd0f1
1فایلهای تغییر یافته به همراه32 افزوده شده و 0 حذف شده
  1. 32 0
      Resources/doc/reference/advance.rst

+ 32 - 0
Resources/doc/reference/advance.rst

@@ -70,6 +70,38 @@ You have 2 ways of defining the dependencies inside a ``services.xml``.
             </call>
             </call>
         </service>
         </service>
 
 
+If you want to create your own RouteBuilder, you can do it using code like
+
+```xml
+        <service id="acme.admin.route.entity" class="Acme\AdminBundle\Route\EntityRouterBuilder">
+            <argument type="service" id="sonata.admin.audit.manager" />
+        </service>
+```
+
+```php
+<?php
+namespace Acme\AdminBundle\Route;
+
+use Sonata\AdminBundle\Builder\RouteBuilderInterface;
+use Sonata\AdminBundle\Admin\AdminInterface;
+use Sonata\AdminBundle\Model\AuditManagerInterface;
+use Sonata\AdminBundle\Route\PathInfoBuilder;
+use Sonata\AdminBundle\Route\RouteCollection;
+
+class EntityRouterBuilder extends PathInfoBuilder implements RouteBuilderInterface
+{
+    /**
+     * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
+     * @param \Sonata\AdminBundle\Route\RouteCollection $collection
+     */
+    public function build(AdminInterface $admin, RouteCollection $collection)
+    {
+        parent::build($admin,$collection);
+        $collection->add('yourSubAction');
+    }
+}
+```
+
 
 
 If you want to modify the service that is going to be injected, add the following code to your
 If you want to modify the service that is going to be injected, add the following code to your
 application's config file:
 application's config file: