Browse Source

update documentation

Thomas 14 years ago
parent
commit
4e45c2bfb0

+ 31 - 7
Resources/doc/reference/architecture.rst

@@ -23,12 +23,36 @@ If a field is associated with another entity (and that entity also has an
 ``Admin`` class), then the related ``Admin`` class will be accessible from
 within the first ``Admin`` class.
 
-The admin class is ContainerAware, meaning that the entire dependency injection
-container is injected. Therefore, you have access to every service and can
-do things such as:
+The admin class is a service implementing the ``AdminInterface``, meaning that
+only required dependencies are injected:
+
+* ``ListBuilder``
+* ``FormBuildre``
+* ``DatagridBuilder``
+* ``Router``
+* ``Request``
+* ``EntityManager``
+* ``Translator``
+
+
+Therefore, you have access to every service you want by injecting them into the
+admin class, like:
+
+.. code-block:: xml
+
+    <service id="sonata.news.admin.post" class="%sonata.news.admin.post.class%">
+        <tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/>
+        <argument>%sonata.news.admin.post.entity%</argument>
+        <argument>%sonata.news.admin.post.controller%</argument>
+
+        <call method="setUserManager">
+            <argument type="service" id="fos_user.user_manager" />
+        </call>
+
+    </service>
+
+Here, the FOS' User Manager is injected into the Post service.
 
-* Access user permissions to define the list fields;
-* Access the ``Router`` to generate custom routes.
 
 Field Definition
 ----------------
@@ -78,8 +102,8 @@ property.
 Obtaining an ``Admin`` Service
 ------------------------------
 
-``Admin`` definition are accessible through the 'admin.pool' service.
-The ``Admin`` definitions are lazy loaded from the Pool to avoid overhead.
+``Admin`` definition are accessible through the 'sonata_admin.pool' service or directly from the DIC.
+The ``Admin`` definitions are lazy loaded from the DIC to avoid overhead.
 
 Filter and Datagrid
 -------------------

+ 10 - 34
Resources/doc/reference/installation.rst

@@ -22,7 +22,7 @@ Next, be sure to enable the bundles in your application kernel:
   $loader->registerNamespaces(array(
       // ...
       'Sonata'                         => __DIR__.'/../src',
-      'Knplabs'                         => __DIR__.'/../src',
+      'Knplabs'                        => __DIR__.'/../src',
       // ...
   ));
 
@@ -42,16 +42,6 @@ Next, be sure to enable the bundles in your application kernel:
 Configuration
 -------------
 
-To use the ``AdminBundle``, add the following to your application
-configuration file.
-
-.. code-block:: yaml
-
-    # app/config/config.yml
-    sonata_admin: ~
-
-    menu.twig:   ~
-
 The bundle also contains several routes. Import them by adding the following
 code to your application's routing file:
 
@@ -85,26 +75,12 @@ Once you have created an admin class, you must declare the class to use it. Like
 
 .. code-block:: yaml
 
-    # app/config/config.yml
-    sonata_admin:
-        entities:
-            post:
-                label:      Post
-                group:      blog
-                class:      Sonata\NewsBundle\Admin\PostAdmin
-                entity:     Application\Sonata\NewsBundle\Entity\Post
-                controller: SonataNewsBundle:PostAdmin
-
-            tag:
-                label:      Tag
-                group:      blog
-                class:      Sonata\NewsBundle\Admin\TagAdmin
-                entity:     Application\Sonata\NewsBundle\Entity\Tag
-                controller: SonataNewsBundle:TagAdmin
-
-            comment:
-                label:      Comment
-                group:      blog
-                class:      Sonata\NewsBundle\Admin\CommentAdmin
-                entity:     Application\Sonata\NewsBundle\Entity\Comment
-                controller: SonataNewsBundle:CommentAdmin
+    # app/config/config.xml
+
+    <service id="sonata.news.admin.post" class="Sonata\NewsBundle\Admin\PostAdmin">
+
+        <tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/>
+
+        <argument>Application\Sonata\NewsBundle\Entity\Post</argument>
+        <argument>SonataNewsBundle:PostAdmin</argument>
+    </service>

+ 7 - 5
Resources/doc/tutorial/creating_your_first_admin_class/defining_admin_class.rst

@@ -29,15 +29,17 @@ By convention Admin files are set under a Admin folder.
 
     }
 
-- register the AdminClass inside the admin.config from the config.yml file
+- register the PostAdmin class inside the DIC
 
 ..
 
-    post:
-        class:      Bundle\NewsBundle\Admin\PostAdmin
-        entity:     Application\Sonata\NewsBundle\Entity\Post
-        controller: SonataNewsBundle:PostAdmin
+    <service id="sonata.news.admin.post" class="Sonata\NewsBundle\Admin\PostAdmin">
 
+        <tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/>
+
+        <argument>Application\Sonata\NewsBundle\Entity\Post</argument>
+        <argument>SonataNewsBundle:PostAdmin</argument>
+    </service>
 
 
 These is the minimal configuration required to display the entity inside the dashboard and