From 098cd57811fb2803aa1b15629a7afbdb1ec91751 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 6 Jun 2018 09:45:59 +0200 Subject: [PATCH] Add documentation for using custom repository service in ResourceBundle --- .../SyliusResourceBundle/show_resource.rst | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/components_and_bundles/bundles/SyliusResourceBundle/show_resource.rst b/docs/components_and_bundles/bundles/SyliusResourceBundle/show_resource.rst index addc150ce26..115ecf18e5a 100644 --- a/docs/components_and_bundles/bundles/SyliusResourceBundle/show_resource.rst +++ b/docs/components_and_bundles/bundles/SyliusResourceBundle/show_resource.rst @@ -87,6 +87,28 @@ Creating yet another action to change the method called could be a solution but Internally, it simply uses the ``$repository->findOneNewestByAuthor($author)`` method, where ``author`` is taken from the current request. +Using Custom Repository Service +------------------------------- + +If you would like to use your own service to get the resource, then try the following configuration: + +.. code-block:: yaml + + # app/config/routing.yml + + app_book_show: + path: /books/{author} + methods: [GET] + defaults: + _controller: app.controller.book:showAction + _sylius: + repository: + method: ["expr:service('app.repository.custom_book_repository')", "findOneNewestByAuthor"] + arguments: [$author] + + +With this configuration, method ``findOneNewestByAuthor`` from service with ID ``app.repository.custom_book_repository`` will be called to get the resource. + Configuration Reference -----------------------