Prechádzať zdrojové kódy

Add some screenshots

Thomas Rabaix 12 rokov pred
rodič
commit
3d91ea85cd

BIN
Resources/doc/images/console_admin_explain.png


BIN
Resources/doc/images/console_admin_list.png


BIN
Resources/doc/images/dashboard.png


BIN
Resources/doc/images/post_create_tag.png


BIN
Resources/doc/images/post_create_tag_error.png


BIN
Resources/doc/images/post_edit.png


BIN
Resources/doc/images/post_edit_error.png


BIN
Resources/doc/images/post_list.png


BIN
Resources/doc/images/sonata_type_immutable_array.png


+ 31 - 0
Resources/doc/index.rst

@@ -35,3 +35,34 @@ Reference Guide
    reference/advance
    reference/console
    reference/preview_mode
+
+Overview
+--------
+
+.. figure:: ../images/dashboard.png
+   :align: center
+   :alt: The dashboard
+   :width: 400px
+
+   The dashboard
+
+.. figure:: ../images/post_list.png
+   :align: center
+   :alt: The model list
+   :width: 400px
+
+   The model list
+
+.. figure:: ../images/post_edit.png
+   :align: center
+   :alt: The model edition
+   :width: 400px
+
+   The model edition
+
+.. figure:: ../images/post_create_tag.png
+   :align: center
+   :alt: The modal model edition
+   :width: 400px
+
+   The modal model edition

+ 19 - 5
Resources/doc/reference/batch_actions.rst

@@ -6,9 +6,11 @@ Batch actions are actions triggered on a set of selected models (all of them or
 Defining new actions
 --------------------
 
-You can easily add some custom batch action in the list view. By default the ``delete`` action allows you to remove several entries at once.
+You can easily add some custom batch action in the list view. By default the ``delete`` action
+allows you to remove several entries at once.
 
-Override the ``getBatchActions`` from your ``Admin`` class to define custom batch actions. For example, we define here a new ``merge`` action.
+Override the ``getBatchActions`` from your ``Admin`` class to define custom batch actions.
+For example, we define here a new ``merge`` action.
 
 .. code-block:: php
 
@@ -37,7 +39,11 @@ Override the ``getBatchActions`` from your ``Admin`` class to define custom batc
 (Optional) Overriding the batch selection template
 --------------------------------------------------
 
-Obviously, a merge action requires two kind of selection : a set of source model to merge into one target model. By default, this bundle only enable the user to select some model, but there is only one selection kind. Thus you will need to override the ``list__batch.html.twig`` template to display both a checkbox (source selection) and a radio (target selection) for each model row. See Symfony bundle overriding mechanism for further explanation.
+Obviously, a merge action requires two kind of selection : a set of source model to merge
+into one target model. By default, this bundle only enable the user to select some model,
+but there is only one selection kind. Thus you will need to override the ``list__batch.html.twig``
+template to display both a checkbox (source selection) and a radio (target selection) for each
+model row. See Symfony bundle overriding mechanism for further explanation.
 
 .. code-block:: html+jinja
 
@@ -70,7 +76,11 @@ And add this:
 (Optional) Overriding the default relevancy check function
 ----------------------------------------------------------
 
-By default, batch actions are not executed if no model was selected, and the user is notified of this lack of selection. If your custom batch action need some more complex logic to determine if an action can be performed or not, just define the ``batchActionMyActionIsRelevant`` method in your ``CRUDController`` class. This check is performed before any confirmation, to make sure there is actually something to confirm. This method may return three different values :
+By default, batch actions are not executed if no model was selected, and the user is notified of
+this lack of selection. If your custom batch action need some more complex logic to determine if
+an action can be performed or not, just define the ``batchActionMyActionIsRelevant`` method in
+your ``CRUDController`` class. This check is performed before any confirmation, to make sure there
+is actually something to confirm. This method may return three different values :
 
  - ``true``: The batch action is relevant and can be applied.
  - a string: The batch action is not relevant given the current request parameters (for example the ``target`` is missing for a ``merge`` action). The returned string is the message that inform the user why the action is aborted.
@@ -115,7 +125,11 @@ By default, batch actions are not executed if no model was selected, and the use
 Define the core action logic
 ----------------------------
 
-The method ``batchActionMyAction`` will be executed to achieve the core logic. The selected models are passed to the method through a query argument retrieving them. If for some reason it makes sense to perform your batch action without the default selection method (for example you defined another way, at template level, to select model at a lower granularity), the passed query is ``null``.
+The method ``batchActionMyAction`` will be executed to achieve the core logic. The selected
+models are passed to the method through a query argument retrieving them. If for some reason
+it makes sense to perform your batch action without the default selection method (for example
+you defined another way, at template level, to select model at a lower granularity), the
+passed query is ``null``.
 
 .. code-block:: php
 

+ 14 - 0
Resources/doc/reference/console.rst

@@ -35,6 +35,13 @@ Usage example:
 
     php app/console sonata:admin:explain sonata.news.admin.post
 
+.. figure:: ../images/console_admin_explain.png
+   :align: center
+   :alt: Explain command
+   :width: 400px
+
+   Explain command
+
 
 sonata:admin:list
 -----------------
@@ -51,6 +58,13 @@ Usage example:
     php app/console sonata:admin:list
 
 
+.. figure:: ../images/console_admin_list.png
+   :align: center
+   :alt: List command
+   :width: 400px
+
+   List command
+
 sonata:admin:setup-acl
 ----------------------
 

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

@@ -20,6 +20,13 @@ application's config file:
             groups:
                 ... your config ...
 
+.. figure:: ../images/dashboard.png
+   :align: center
+   :alt: The dashboard
+   :width: 400px
+
+   The dashboard
+
 
 Examples
 --------
@@ -93,8 +100,8 @@ Add some items to a group
 
 
 .. image:: ../images/dashboard.png
-           :alt: Dashboard
-           :width: 200
+   :alt: Dashboard
+   :width: 200
 
 Display two blocks with different dashboard groups
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

+ 19 - 18
Resources/doc/reference/getting_started.rst

@@ -6,7 +6,7 @@ Here is a quick checklist of what is needed to quickly setup SonataAdminBundle
 and create your first admin interface for the models of your application:
 
 * Step 1: Define SonataAdminBundle routes
-* Step 2: Setup the persistence service (ORM, ODM, ...)
+* Step 2: Setup the persistency service (ORM, ODM, ...)
 * Step 3: Create admin class
 * Step 4: Create admin service
 * Step 5: Configuration
@@ -43,9 +43,9 @@ At this point you can already access the admin dashboard by visiting the url:
 Step 2: Setup the persistence service (ORM, ODM, ...)
 -----------------------------------------------------
 
-SonataAdminBundle does not impose persistance service (service for handling and
+SonataAdminBundle does not impose any persistency services (service for handling and
 controlling your models), however most likely your application will use some
-persistance service (like ORM or ODM for database and document stores) therefore
+persistency services (like ORM or ODM for database and document stores) therefore
 you can use the following bundles officially supported by Sonata Project's admin
 bundle:
 
@@ -56,7 +56,7 @@ bundle:
 Propel users are warmly welcome to contribute and create a new bundle for Propel
 ORM that will be integrated in SonataAdminBundle.
 
-Install a persistance servise you need and configure it according to their
+Install a persistency servise you need and configure it according to their
 related documentation.
 
 Step 3: Create Admin class
@@ -77,7 +77,6 @@ Here is a simple example from the SonataNewsBundle:
    use Sonata\AdminBundle\Admin\Admin;
    use Sonata\AdminBundle\Datagrid\ListMapper;
    use Sonata\AdminBundle\Datagrid\DatagridMapper;
-   use Sonata\AdminBundle\Validator\ErrorElement;
    use Sonata\AdminBundle\Form\FormMapper;
 
    class TagAdmin extends Admin
@@ -106,15 +105,6 @@ Here is a simple example from the SonataNewsBundle:
                ->add('enabled')
            ;
        }
-
-       public function validate(ErrorElement $errorElement, $object)
-       {
-           $errorElement
-               ->with('name')
-                   ->assertMaxLength(array('limit' => 32))
-               ->end()
-           ;
-       }
    }
 
 
@@ -124,13 +114,15 @@ Step 4: Create admin service
 To notify your administration of your new admin class you need to create an
 admin service and link it into the framework by setting the sonata.admin tag.
 
+Create a new ``admin.xml`` file inside the ``MyBundle/Ressources/config/`` folder:
+
 .. code-block:: xml
 
    <container xmlns="http://symfony.com/schema/dic/services"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://symfony.com/schema/dic/services/services-1.0.xsd">
        <services>
-          <service id="sonata.admin.course" class="YourNS\AdminBundle\Admin\BlogAdmin">
+          <service id="sonata.admin.tag" class="YourNS\AdminBundle\Admin\BlogAdmin">
              <tag name="sonata.admin" manager_type="orm" group="Posts" label="Blog"/>
              <argument />
              <argument>YourNS\AdminBundle\Entity\Course</argument>
@@ -143,14 +135,18 @@ admin service and link it into the framework by setting the sonata.admin tag.
    </container>
 
 
-Note: If you don't already have a configuration file for the purpose, you can register this service in a ``services.xml`` file, save the file in ``app/config``, and then import it from ``config.yml``:
-
 .. code-block:: yaml
 
     # app/config/config.yml
     imports:
-        - { resource: services.xml }
+        - { resource: @MyBundle/Ressources/config/admin.xml }
+
+Or you can load the file inside with the Bundle's extension file:
 
+.. code-block:: php
+
+    $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+    $loader->load('admin.xml');
 
 Step 5: Configuration
 ---------------------
@@ -174,6 +170,7 @@ and change them according to your requirements:
             list:    SonataAdminBundle:CRUD:list.html.twig
             show:    SonataAdminBundle:CRUD:show.html.twig
             edit:    SonataAdminBundle:CRUD:edit.html.twig
+
         dashboard:
             blocks:
                 # display a dashboard block
@@ -182,6 +179,8 @@ and change them according to your requirements:
 Linking the admin class to the dashboard is done automatically because of the
 default option you defined above:
 
+.. code-block:: yaml
+
     dashboard
         blocks:
             # display a dashboard block
@@ -190,6 +189,8 @@ default option you defined above:
 
 However you can define only admin groups you want to show in the dashboard by:
 
+.. code-block:: yaml
+
     dashboard
         blocks:
             # display a dashboard block