Skip to content

Commit

Permalink
docs: Minor touches to the arguments converter section
Browse files Browse the repository at this point in the history
  • Loading branch information
MontealegreLuis committed Sep 2, 2017
1 parent 6ff91f3 commit 6b8c039
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions docs/argument-converters.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ signature style by default:
method(/* $route_param_1, $route_param_2, ... $route_param_n */ $request, $app)
```

The route params are optional, they depend on your route, but the request and the
The route parameters are optional, they depend on your route, but the request and the
application arguments will be passed by default.

You can modify this behaviour by passing an *arguments converter function* to the
`Resolver::resolve` method.

## Contents

* [Modifying arguments](#modifying-arguments)
* [Custom arguments](#custom-arguments)

## Modifying arguments

You can pass an anonymous function to the `Resolver` in order to modify the
arguments passed to your controller. Suppose for instance that your method
Suppose for instance that your method
`Modules\ProductCatalog\Controllers\ProductController::showProductForm` does not need
the request argument. You could remove it by registering your route the following way:

```php
# Modules\ProductCatalog\ProductCatalogControllers
# Modules\ProductCatalog\CatalogControllerProvider

public function register(Slim $app, ControllerResolver $resolver)
{
Expand All @@ -43,9 +50,9 @@ following `showProductForm($productId, Slim $app)`.

Any converter function must return an `array` with the arguments that will be passed to
your controller. In the example above we removed an unnecessary argument, but we can
replace the arguments completely.
customize the arguments completely.

## Replacing arguments
## Custom arguments

Suppose you have a controller in your catalog to search products. This controller
uses the product category and a group of keywords separated by spaces to perform the
Expand Down

0 comments on commit 6b8c039

Please sign in to comment.