Переглянути джерело

Updated console command docs and tweaked GenerateAdminCommand:
* expanded sonata:admin:generate docs
* switched order of list and explain in docs, since you need to list first before you know what to explain
* refactored GenerateAdminCommand::getAdminServiceId() so it only strips the end off Bundle names that end in "Bundle"
* edit for readability

Christian Morgan 11 роки тому
батько
коміт
83c7ebbc7c
2 змінених файлів з 39 додано та 36 видалено
  1. 5 3
      Command/GenerateAdminCommand.php
  2. 34 33
      Resources/doc/reference/console.rst

+ 5 - 3
Command/GenerateAdminCommand.php

@@ -296,12 +296,14 @@ class GenerateAdminCommand extends ContainerAwareCommand
      */
      */
     private function getAdminServiceId($bundleName, $adminClassBasename)
     private function getAdminServiceId($bundleName, $adminClassBasename)
     {
     {
-        $name = substr($adminClassBasename, -5) == 'Admin' ? substr($adminClassBasename, 0, -5) : $adminClassBasename;
+        $prefix = substr($bundleName, -6) == 'Bundle' ? substr($bundleName, 0, -6) : $bundleName;
+        $suffix = substr($adminClassBasename, -5) == 'Admin' ? substr($adminClassBasename, 0, -5) : $adminClassBasename;
+        $suffix = str_replace('\\', '.', $suffix);
 
 
         return Container::underscore(sprintf(
         return Container::underscore(sprintf(
             '%s.admin.%s',
             '%s.admin.%s',
-            substr($bundleName, 0, -6),
-            str_replace('\\', '.', $name)
+            $prefix,
+            $suffix
         ));
         ));
     }
     }
 
 

+ 34 - 33
Resources/doc/reference/console.rst

@@ -26,77 +26,78 @@ Usage example:
 sonata:admin:generate
 sonata:admin:generate
 --------------------
 --------------------
 
 
-The ``sonata:admin:generate`` command generates a new admin class based on the given model class,
-registers it as a service and potentially creates a new controller.
+The ``sonata:admin:generate`` command generates a new Admin class based on the given model 
+class, registers it as a service and potentially creates a new controller.
 As an argument you need to specify the fully qualified model class.
 As an argument you need to specify the fully qualified model class.
 All passed arguments and options are used as default values in interactive mode.
 All passed arguments and options are used as default values in interactive mode.
 You can disable the interactive mode with ``--no-interaction`` option.
 You can disable the interactive mode with ``--no-interaction`` option.
 
 
 Options are:
 Options are:
- * ``bundle`` : the bundle name (the default value is determined by the given model class)
- * ``admin`` : the admin class basename (the default value is a concatenation of model class basename and "Admin")
- * ``controller`` : the controller class basename (the default value is a concatenation of model class basename and "AdminController")
- * ``manager`` : the model manager type (the default value is the first registered model manager type, mostly "orm")
- * ``services`` : the services YAML file (the default value is "services.yml" or "admin.yml" if it already exist)
- * ``id`` : the admin service ID (the default value is combination of the bundle name and admin class basename like "app_foo.admin.user")
+ * ``bundle``: the bundle name (the default value is determined by the given model class, e.g. "YourNSFooBundle")
+ * ``admin``: the admin class basename (by default this adds "Admin" to the model class name, e.g. "BarAdmin")
+ * ``controller``: the controller class basename (by default this adds "AdminController" to the model class name, e.g. "BarAdminController")
+ * ``manager``: the model manager type (by default this is the first registered model manager type, e.g. "orm")
+ * ``services``: the services YAML file (the default value is "services.yml" or "admin.yml" if it already exist)
+ * ``id``: the admin service ID (the default value is combination of the bundle name and admin class basename like "your_ns_foo.admin.bar")
 
 
 Usage example:
 Usage example:
 
 
 .. code-block:: bash
 .. code-block:: bash
 
 
-    php app/console sonata:admin:generate App\Bundle\FooBundle\Entity\User
+    php app/console sonata:admin:generate YourNS\FooBundle\Entity\Bar
 
 
-sonata:admin:explain
---------------------
 
 
-The ``sonata:admin:explain`` command prints details about the admin of a model.
-As an argument you need to specify admin service id of the model you need
-explaining.
+sonata:admin:list
+-----------------
+
+To see which admin services are available use the ``sonata:admin:list`` command. 
+It prints all the admin service ids available in your application. This command 
+gets the ids from the ``sonata.admin.pool`` service where all the available admin 
+services are registered.
 
 
 Usage example:
 Usage example:
 
 
 .. code-block:: bash
 .. code-block:: bash
 
 
-    php app/console sonata:admin:explain sonata.news.admin.post
+    php app/console sonata:admin:list
 
 
-.. figure:: ../images/console_admin_explain.png
+
+.. figure:: ../images/console_admin_list.png
    :align: center
    :align: center
-   :alt: Explain command
+   :alt: List command
    :width: 700px
    :width: 700px
 
 
-   Explain command
+   List command
 
 
 
 
-sonata:admin:list
------------------
+sonata:admin:explain
+--------------------
 
 
-If you wish to see which admin services are available, you can use
-``sonata:admin:list`` command. It prints all the admin service ids available in
-your application. Command gets ids from ``sonata.admin.pool`` service where all
-the available admin services are present.
+The ``sonata:admin:explain`` command prints details about the admin of a model.
+As an argument you need to specify the admin service id of the Admin to explain.
 
 
 Usage example:
 Usage example:
 
 
 .. code-block:: bash
 .. code-block:: bash
 
 
-    php app/console sonata:admin:list
-
+    php app/console sonata:admin:explain sonata.news.admin.post
 
 
-.. figure:: ../images/console_admin_list.png
+.. figure:: ../images/console_admin_explain.png
    :align: center
    :align: center
-   :alt: List command
+   :alt: Explain command
    :width: 700px
    :width: 700px
 
 
-   List command
+   Explain command
+
 
 
 sonata:admin:setup-acl
 sonata:admin:setup-acl
 ----------------------
 ----------------------
 
 
-The ``sonata:admin:setup-acl`` command updates ACL definitions for all admin
-classes available in ``sonata.admin.pool``. For instance every time you create a
-new ``Admin`` class, you can create ACL by using the ``sonata:admin:setup-acl``
+The ``sonata:admin:setup-acl`` command updates ACL definitions for all Admin
+classes available in ``sonata.admin.pool``. For instance, every time you create a
+new ``Admin`` class, you can create its ACL by using the ``sonata:admin:setup-acl``
 command. The ACL database will be automatically updated with the latest masks
 command. The ACL database will be automatically updated with the latest masks
-and roles informations.
+and roles.
 
 
 Usage example:
 Usage example: