Grammar updates to docs customization section

This commit is contained in:
Daniel Hennion 2016-10-26 01:20:04 -04:00
parent 9ab5cc4997
commit e2c8abcdef
3 changed files with 23 additions and 22 deletions

View file

@ -1,22 +1,23 @@
Customizing Controllers
=======================
All **Sylius** resources are using the
All **Sylius** resources use the
`Sylius/Bundle/ResourceBundle/Controller/ResourceController <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/ResourceBundle/Controller/ResourceController.php>`_
as default, but some of them have been already extended in Bundles.
If you want to override some controller action, check which controller you should be extending.
by default, but some of them have already been extended in Bundles.
If you want to override a controller action, check which controller you should be extending.
.. note::
There are two types of controllers we can define in Sylius.
**Resource Controllers** - are basing only on one Entity, so they return only the resources they have in their name. For instance a ``ProductController`` should return only products.
There are two types of controllers we can define in Sylius:
**Resource Controllers** - are based only on one Entity, so they return only the resources they have in their name. For instance a ``ProductController`` should return only products.
**Standard Controllers** - non-resource; these may use many entities at once, they are useful on more general pages. We are extending these controllers only if the actions we want cannot be done through yaml configuration - like sending emails.
Why would you customize a Controller?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To add your custom actions you need to override controllers. You may bee needing to:
To add your custom actions you need to override controllers. You may need to:
* add a generic action that will render a list of recommended products with a product on its show page,
* add a generic action that will render a list of recommended products with a product on its show page.
* render a partial template that cannot be done via yaml resource action.
How to customize a Resource Controller?
@ -38,10 +39,10 @@ For the ``ProductController`` run:
$ php app/console debug:container sylius.controller.product
As a result you will get the ``Sylius\Bundle\CoreBundle\Controller\ProductController`` - this is the class that you need to be extending.
As a result you will get the ``Sylius\Bundle\CoreBundle\Controller\ProductController`` - this is the class that you need to extend.
Now you have to create the controller that will have a generic action that is basically the ``showAction`` from the ``ResourceController`` extended by
getting a list of recommended product from your external api.
getting a list of recommended products from your external api.
.. code-block:: php
@ -105,7 +106,7 @@ getting a list of recommended product from your external api.
classes:
controller: AppBundle\Controller\ProductController
How to customize a Standard Controller?
How to customize a Standard Controller:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's assume that you would like to send some kind of emails (which are not resources) after something has been purchased in your shop - to do this you should modify an ``afterPurchaseAction`` on the ``OrderController``.
@ -114,7 +115,7 @@ Let's assume that you would like to send some kind of emails (which are not reso
Run ``$ php app/console debug:container sylius.controller.frontend.order``.
Your class needs to be extending this base class.
Your class needs to extend this base class.
.. code-block:: php

View file

@ -19,7 +19,7 @@ How to customize templates?
.. note::
How do you know which template you should be overriding?
Go to the page that you are going to modify, at the bottom in the Symfony toolbar click on the route ,
Go to the page that you are going to modify, at the bottom in the Symfony toolbar click on the route,
which will redirect you to the profiler. In the Request Attributes section
under ``_sylius [ template => ...]`` you can check the path to the current template.
@ -63,7 +63,7 @@ Copy the contents of the original template to make your work easier. And then mo
</div>
{% endblock %}
Done! If you do not see any changes on the ``/shop/login`` url, clear your cache. ``$ php app/console cache:clear``.
Done! If you do not see any changes on the ``/shop/login`` url, clear your cache: ``$ php app/console cache:clear``.
* **Admin** templates: Customization of the Country form view.
@ -88,4 +88,4 @@ Copy the contents of the original template to make your work easier. And then mo
{{ form_row(form.provinces, {'label': false}) }}
</div>
Done! If you do not see any changes on the ``/admin/countries/new`` url, clear your cache. ``$ php app/console cache:clear``.
Done! If you do not see any changes on the ``/admin/countries/new`` url, clear your cache: ``$ php app/console cache:clear``.

View file

@ -15,21 +15,21 @@ For example:
* change "Last name" into "Surname"
* change "Add to cart" into "Buy"
and many other places where you can customize the text content of pages.
There are many other places where you can customize the text content of pages.
How to customize a translation?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to customize a translation in your project:
1. If you don't have create the ``AppBundle\Resources\translations\messages.en.yml`` for english translations.
1. If you don't have it yet, create ``AppBundle\Resources\translations\messages.en.yml`` for English translations.
.. note::
You can create different files for different locales (languages). For example ``messages.pl.yml`` should hold only polish translations,
as they will be visible when the current locale is ``PL``. Check :doc:`Locales </book/locales>` docs for more information.
You can create different files for different locales (languages). For example ``messages.pl.yml`` should hold only Polish translations,
as they will be visible when the current locale is ``PL``. Check the :doc:`Locales </book/locales>` docs for more information.
3. In this file configure the desired key and give it a translation.
3. In this file, configure the desired key and give it a translation.
If you would like to change the translation of "Email" into "Username" on the login form you have to
override its translation key which is ``sylius.form.customer.email``.
@ -43,9 +43,9 @@ override its translation key which is ``sylius.form.customer.email``.
.. tip::
**How to check what is the proper translation key for your message?**
When you are on the page where you are trying to customize a translation click the Translations icon in the Symfony Profiler.
In this section you can see all messages with their keys on that page.
**How to check what the proper translation key is for your message:**
When you are on the page where you are trying to customize a translation, click the Translations icon in the Symfony Profiler.
In this section you can see all messages with their associated keys on that page.
.. image:: ../_images/translations.png
:align: center