Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hint how fosjsrouting works #785

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions book/extend-admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,20 @@ as well, then you should be able to see these actions when using the ``debug:rou
app.put_event PUT ANY ANY /admin/api/events/{id}.{_format}
app.delete_event DELETE ANY ANY /admin/api/events/{id}.{_format}

.. note::

To expose routes also to the admin frontend, you must use the `FOSJsRoutingBundle`_ and set the ``methods`` and the ``expose``
parameter for the actions.

For example: ``options: ['expose' => true], methods: ['POST']``. Further examples of exposed routes, can be found in the
`Sulu Workshops`_, specifically assignment 10.

Sulu automatically exposes actions with names that match the regex pattern ``(.+\.)?c?get_.*``.

If you want to verify the active rules for exposing routes, you can use the command ``bin/console debug:config fos_js_routing``.

To confirm that your route is correctly registered, use the command ``bin/console fos:js-routing:debug``.

These routes are spread over two different URLs, one without the ID (``/admin/api/events``) and one with the ID
(``/admin/api/events/{id}``). The first one is used to get a list of available events and to create new events, while
the latter is about already existing events.
Expand Down Expand Up @@ -889,3 +903,5 @@ the parent then the ``/config/forms/event_details.xml`` would look like this:
.. _Sulu workshop: https://github.com/sulu/sulu-workshop
.. _Sulu Demo repository: https://github.com/sulu/sulu-demo/pulls?q=is%3Aopen+is%3Apr+label%3AExample
.. _Sulu Javascript Docs: https://jsdocs.sulu.io/
.. _FOSJsRoutingBundle: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/master/Resources/doc/usage.rst
.. _Sulu Workshops: https://github.com/sulu/sulu-workshop/pulls
Loading