Skip to content

Commit

Permalink
Merge pull request Sylius#9456 from pamil/1.2-custom-repo-docs
Browse files Browse the repository at this point in the history
Add documentation for using custom repository service in ResourceBundle
  • Loading branch information
pamil committed Jun 6, 2018
2 parents 35180a9 + 098cd57 commit fa6e60c
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -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
-----------------------

Expand Down

0 comments on commit fa6e60c

Please sign in to comment.