|
@@ -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
|