Selaa lähdekoodia

update documentation

Thomas 14 vuotta sitten
vanhempi
commit
d1e65ef98c

+ 5 - 4
Resources/doc/reference/architecture.rst

@@ -12,9 +12,10 @@ The ``Admin`` class is the CRUD definition of one Doctrine entity. It contains
 all the configuration necessary to display a rich CRUD for the entity. From
 within an admin class, the following information can be defined:
 
-* ``list_fields``: The fields displayed in the list table;
-* ``filter_fields``: The fields available for filter the list;
-* ``form_fields``: The fields used to edit the entity;
+* ``listFields``: The fields displayed in the list table;
+* ``filterFields``: The fields available for filter the list;
+* ``formFields``: The fields used to edit the entity;
+* ``formGroups``: The group definition where a field must be displayed (edit form)
 * The batch actions: Actions that can be performed on a group of entities
   (e.g. bulk delete)
 
@@ -32,7 +33,7 @@ do things such as:
 Field Definition
 ----------------
 
-A field definition is an simple array. There is one definition per list
+A field definition is a FieldDescription object. There is one definition per list
 field.
 
 The definition contains:

+ 9 - 8
Resources/doc/reference/filter_field_definition.rst

@@ -19,7 +19,7 @@ Example
 
         protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
 
-        protected $filter_fields = array(
+        protected $filterFields = array(
             'title',
             'enabled',
             'tags' => array('filter_field_options' => array('expanded' => true, 'multiple' => true))
@@ -27,13 +27,14 @@ Example
 
         public function configureFilterFields()
         {
-            $this->filter_fields['with_open_comments'] = array(
-                'type'           => 'callback',
-                'filter_options' => array(
-                    'filter'  => array($this, 'getWithOpenCommentFilter'),
-                    'field'   => array($this, 'getWithOpenCommentField')
-                )
-            );
+            $this->filterFields['with_open_comments'] = new FieldDescription;
+            $this->filterFields['with_open_comments']->setName('label');
+            $this->filterFields['with_open_comments']->setTemplate('Sonata\BaseApplicationBundle:CRUD:filter_callback.twig');
+            $this->filterFields['with_open_comments']->setType('callback');
+            $this->filterFields['with_open_comments']->setOption('filter_options', array(
+                'filter' => array($this, 'getWithOpenCommentFilter'),
+                'field'  => array($this, 'getWithOpenCommentField')
+            ));
         }
 
         public function getWithOpenCommentFilter($query_builder, $alias, $field, $value)

+ 7 - 3
Resources/doc/reference/form_field_definition.rst

@@ -18,7 +18,7 @@ Example
 
         protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
 
-        protected $form_fields = array(
+        protected $formFields = array(
             'enabled',
             'title',
             'abstract',
@@ -31,8 +31,12 @@ Example
 
         public function configureFormFields()
         {
-            $this->form_fields['comments_default_status']['type'] = 'choice';
-            $this->form_fields['comments_default_status']['options']['choices'] = \Application\Sonata\NewsBundle\Entity\Comment::getStatusList();
+            $this->formFields['comments_default_status']->setType('choice');
+    
+            $options = $this->formFields['comments_default_status']->getOption('form_field_options', array());
+            $options['choices'] = Comment::getStatusList();
+
+            $this->formFields['comments_default_status']->setOption('form_field_options', $options);
         }
     }
 

+ 4 - 0
Resources/doc/reference/installation.rst

@@ -46,6 +46,10 @@ code to your application's routing file:
         resource: BaseApplicationBundle/Resources/config/routing/base_application.xml
         prefix: /admin
 
+    admin:
+        resource: base_application
+        prefix: /admin
+
 At this point you can access to the dashboard with the url: ``http://yoursite.local/admin/dashboard``.
 
 .. note::

+ 2 - 2
Resources/doc/reference/list_field_definition.rst

@@ -18,7 +18,7 @@ Example
 
         protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
 
-        protected $list_fields = array(
+        protected $listFields = array(
             'title' => array(),
             'enabled' => array('type' => 'boolean'),
             'tags' => array()
@@ -27,7 +27,7 @@ Example
         public function configureListFields() // optional
         {
 
-            $this->list_fields['summary']['template'] = 'NewsBundle:NewsAdmin:list_summary.twig';
+            $this->list_fields['summary']->setTemplate('NewsBundle:NewsAdmin:list_summary.twig');
         }
     }
 

+ 9 - 38
Resources/doc/reference/routing.rst

@@ -12,7 +12,7 @@ The ``Admin`` class contains two routing method:
 Routing Definition
 ------------------
 
-You must set a ``base_route`` property inside your ``Admin`` class, which
+You can set a ``baseRouteName`` property inside your ``Admin`` class, which
 represents the each route prefix.
 
 .. code-block:: php
@@ -22,45 +22,16 @@ represents the each route prefix.
 
         protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
 
-        protected $base_route = 'news_post_admin';
+        protected $baseRoute = 'news_post_admin';
     }
 
-This definition is mandatory.
 
-.. code-block:: xml
-
-    <?xml version="1.0" encoding="UTF-8" ?>
-
-    <routes xmlns="http://www.symfony-project.org/schema/routing"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://www.symfony-project.org/schema/routing http://www.symfony-project.org/schema/routing/routing-1.0.xsd">
-
-        <!-- NEWS CONTROLLER -->
-        <route id="news_post_admin_list" pattern="/post">
-            <default key="_controller">NewsBundle:PostAdmin:list</default>
-        </route>
-
-        <route id="news_post_admin_create" pattern="/post/create">
-            <default key="_controller">NewsBundle:PostAdmin:create</default>
-        </route>
-
-        <route id="news_post_admin_batch" pattern="/post/batch">
-            <default key="_controller">NewsBundle:PostAdmin:batch</default>
-        </route>
-
-        <route id="news_post_admin_update" pattern="/post/update">
-            <default key="_controller">NewsBundle:PostAdmin:update</default>
-        </route>
-
-        <route id="news_post_admin_edit" pattern="/post/:id/edit">
-            <default key="_controller">NewsBundle:PostAdmin:edit</default>
-        </route>
-
-        <route id="news_post_admin_delete" pattern="/post/:id/delete">
-            <default key="_controller">NewsBundle:PostAdmin:delete</default>
-        </route>
-    </routes>
+If no ``baseRouteName`` is defined then the Admin will pick on for you built on
+following format : 'admin_vendor_bundlename_entityname_action'. If the Admin
+fails to find the best baseRouteName then the an ``RuntimeException`` will
+be throw.
 
+The same goes for the ``baseRoutePattern``.
 
 Routing usage
 -------------
@@ -69,7 +40,7 @@ Inside a CRUD template, a route can be generated by using the ``Admin`` class.
 
 .. code-block:: html
 
-    <a href="{{ configuration.generateUrl('list') }}">List</a>
+    <a href="{{ admin.generateUrl('list') }}">List</a>
 
-    <a href="{{ configuration.generateUrl('list', params|merge('page': 1) }}">List</a>
+    <a href="{{ admin.generateUrl('list', params|merge('page': 1) }}">List</a>
 

+ 10 - 16
Resources/doc/tutorial/creating_your_first_admin_class/defining_admin_class.rst

@@ -26,9 +26,7 @@ By convention Admin files are set under a Admin folder.
 
         protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
 
-        protected $base_route = 'news_post_admin';
-
-        protected $base_controller_name = 'NewsBundle:PostAdmin';
+        protected $baseControllerName = 'Sonata\NewsBundle:PostAdmin';
 
     }
 
@@ -58,14 +56,14 @@ Now, let's specify the differents we want to use:
 
 ..
 
-    protected $list_fields = array(
+    protected $listFields = array(
         'title' => array('identifier' => true),
         'slug',
         'enabled',
         'comments_enabled',
     );
 
-    protected $form_fields = array(
+    protected $formFields = array(
         'enabled',
         'title',
         'abstract',
@@ -75,7 +73,7 @@ Now, let's specify the differents we want to use:
         'comments_default_status'
     );
 
-    protected $filter_fields = array(
+    protected $filterFields = array(
         'title',
         'enabled',
         'tags' => array('filter_field_options' => array('expanded' => true, 'multiple' => true))
@@ -100,20 +98,18 @@ TagAdmin
     {
         protected $class = 'Application\Sonata\NewsBundle\Entity\Tag';
 
-        protected $list_fields = array(
+        protected $listFields = array(
             'name' => array('identifier' => true),
             'slug',
             'enabled',
         );
 
-        protected $form_fields = array(
+        protected $formFields = array(
             'name',
             'enabled'
         );
 
-        protected $base_route = 'news_tag_admin';
-
-        protected $base_controller_name = 'NewsBundle:TagAdmin';
+        protected $baseControllerName = 'Sonata\NewsBundle:TagAdmin';
     }
 
 CommentAdmin
@@ -130,7 +126,7 @@ CommentAdmin
 
         protected $class = 'Application\Sonata\NewsBundle\Entity\Comment';
 
-        protected $list_fields = array(
+        protected $listFields = array(
             'name' => array('identifier' => true),
             'getStatusCode' => array('label' => 'status_code'),
             'post',
@@ -139,7 +135,7 @@ CommentAdmin
             'message',
         );
 
-        protected $form_fields = array(
+        protected $formFields = array(
             'name',
             'email',
             'url',
@@ -148,7 +144,5 @@ CommentAdmin
             'status' => array('type' => 'choice'),
         );
 
-        protected $base_route = 'news_comment_admin';
-
-        protected $base_controller_name = 'NewsBundle:CommentAdmin';
+        protected $baseControllerName = 'Sonata\NewsBundle:CommentAdmin';
     }

+ 1 - 126
Resources/doc/tutorial/creating_your_first_admin_class/defining_routing.rst

@@ -10,129 +10,4 @@ Each entity required 6 routes :
 - edit
 - delete
 
-For now, there is no implemented way to add admin routes, so we need to define them in a routing files.
-
-As we need to edit a Post, Comment and Tag, the final routing file looks like this :
-
-..
-
-    <?xml version="1.0" encoding="UTF-8" ?>
-
-    <routes xmlns="http://www.symfony-project.org/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.symfony-project.org/schema/routing http://www.symfony-project.org/schema/routing/routing-1.0.xsd">
-
-        <!-- POST CONTROLLER -->
-        <route id="news_post_admin_list" pattern="/post">
-
-            <default key="_controller">NewsBundle:PostAdmin:list</default>
-
-        </route>
-
-        <route id="news_post_admin_create" pattern="/post/create">
-
-            <default key="_controller">NewsBundle:PostAdmin:create</default>
-
-        </route>
-
-        <route id="news_post_admin_batch" pattern="/post/batch">
-
-            <default key="_controller">NewsBundle:PostAdmin:batch</default>
-
-        </route>
-
-        <route id="news_post_admin_update" pattern="/post/update">
-
-            <default key="_controller">NewsBundle:PostAdmin:update</default>
-
-        </route>
-
-        <route id="news_post_admin_edit" pattern="/post/:id/edit">
-
-            <default key="_controller">NewsBundle:PostAdmin:edit</default>
-
-        </route>
-
-        <route id="news_post_admin_delete" pattern="/post/:id/delete">
-
-            <default key="_controller">NewsBundle:PostAdmin:delete</default>
-
-        </route>
-
-
-        <!-- TAG CONTROLLER -->
-        <route id="news_tag_admin_list" pattern="/tag">
-
-            <default key="_controller">NewsBundle:TagAdmin:list</default>
-
-        </route>
-
-        <route id="news_tag_admin_create" pattern="/tag/create">
-
-            <default key="_controller">NewsBundle:TagAdmin:create</default>
-
-        </route>
-
-        <route id="news_tag_admin_batch" pattern="/tag/batch">
-
-            <default key="_controller">NewsBundle:TagAdmin:batch</default>
-
-        </route>
-
-        <route id="news_tag_admin_update" pattern="/tag/update">
-
-            <default key="_controller">NewsBundle:TagAdmin:update</default>
-
-        </route>
-
-        <route id="news_tag_admin_edit" pattern="/tag/:id/edit">
-
-            <default key="_controller">NewsBundle:TagAdmin:edit</default>
-
-        </route>
-
-        <route id="news_tag_admin_delete" pattern="/delete/:id/delete">
-
-            <default key="_controller">NewsBundle:TagAdmin:delete</default>
-
-        </route>
-
-        <!-- COMMENT CONTROLLER -->
-        <route id="news_comment_admin_list" pattern="/comment">
-
-            <default key="_controller">NewsBundle:CommentAdmin:list</default>
-
-        </route>
-
-        <route id="news_comment_admin_create" pattern="/comment/create">
-
-            <default key="_controller">NewsBundle:CommentAdmin:create</default>
-
-        </route>
-
-        <route id="news_comment_admin_batch" pattern="/comment/batch">
-
-            <default key="_controller">NewsBundle:CommentAdmin:batch</default>
-
-        </route>
-
-        <route id="news_comment_admin_update" pattern="/comment/update">
-
-            <default key="_controller">NewsBundle:CommentAdmin:update</default>
-
-        </route>
-
-        <route id="news_comment_admin_edit" pattern="/comment/:id/edit">
-
-            <default key="_controller">NewsBundle:CommentAdmin:edit</default>
-
-        </route>
-
-        <route id="news_comment_admin_delete" pattern="/comment/:id/delete">
-
-            <default key="_controller">NewsBundle:CommentAdmin:delete</default>
-
-        </route>
-
-    </routes>
-
-
-As the routing is now defined we can create the CRUD Controller for each Entity
+The route information are automatically generated for you.