You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For create all endpoints in Sylius API we are using the API Platform.
5
-
API Platform allows to configure endpoint by ``yaml`` and ``xml`` files or in ``annotations``.
6
-
In these guide we will show you how to customize Sylius API endpoint with ``xml``.
4
+
We are using the API Platform to create all endpoints in Sylius API.
5
+
API Platform allows configuring an endpoint by ``yaml`` and ``xml`` files or by annotations.
6
+
In this guide, you will learn how to customize Sylius API endpoints using ``xml`` configuration.
7
7
8
-
How to prepare project to customization?
8
+
How to prepare project for customization?
9
9
========================================
10
10
11
-
For any kind of customization firstly you need to configure location of your configs.
11
+
For any kind of customization firstly you need to configure directory with your configs.
12
12
13
13
.. code-block:: yaml
14
14
# config/packages/api_platform.yaml
@@ -22,41 +22,51 @@ For any kind of customization firstly you need to configure location of your con
22
22
swagger:
23
23
versions: [3]
24
24
25
-
And now if you want to customize any API resource you need copy entire configuration of this resource from ``%kernel.project_dir%/vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/`` to ``%kernel.project_dir%/config/api_platform``
25
+
And now if you want to customize any API resource you need to copy the entire configuration of this resource from ``%kernel.project_dir%/vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/`` to ``%kernel.project_dir%/config/api_platform``
26
26
27
-
How to add an additional endpoint to a resource?
28
-
================================================
27
+
How to add an additional endpoint?
28
+
==================================
29
29
30
-
Let's assume that you want to add new endpoint to ``order`` which will dispatch a command.
30
+
Let's assume that you want to add a new endpoint to the ``Order`` resource that will be dispatching a command.
31
31
You need to add proper configuration in ``config/api_platform/Order.xml``:
And that's all, now you have new endpoint with your custom logic.
44
+
And that's all, now you have a new endpoint with your custom logic.
45
45
46
46
.. tip::
47
47
48
48
Read more about API Platform endpoint configuration `here <https://api-platform.com/docs/core/operations/>`_
49
49
50
-
How to remove a resource endpoint?
51
-
==================================
50
+
How to remove an endpoint?
51
+
==========================
52
+
53
+
Let's assume that your shop is offering only digital products. Therefore, while checking out,
54
+
your customers do not need to choose a shipping method for their orders.
52
55
53
-
Let's assume that your shop offer only digital products so you don't need setting shipment method at all.
54
-
To remove endpoint you only need to delete unnecessary configuration from ``config/api_platform/Order.xml``
56
+
Thus you will need to modify the configuration file of the ``Order`` resource and remove the shipping method choosing endpoint from it.
57
+
To remove the endpoint you only need to delete the unnecessary configuration from your ``config/api_platform/Order.xml`` which is a copied configuration file, that overwrites the one from Sylius.
58
+
59
+
.. code-block:: xml
55
60
56
-
How to rename the resource endpoint's path?
61
+
<!-- delete this configuration -->
62
+
<itemOperationname="shop_select_shipping_method">
63
+
<!-- ... -->
64
+
</itemOperation>
65
+
66
+
How to rename an endpoint's path?
57
67
===========================================
58
68
59
-
If you want to change endpoint's path, only what you need to do is change ``path`` attribute in your config:
69
+
If you want to change an endpoint's path, you just need to change the ``path`` attribute in your config:
60
70
61
71
.. code-block:: xml
62
72
@@ -67,14 +77,20 @@ If you want to change endpoint's path, only what you need to do is change ``path
67
77
</itemOperation>
68
78
</itemOperations>
69
79
70
-
How to modify the endpoints prefixes? "shop" to "retail" rename.
0 commit comments