Skip to content

Commit 1e1ed7b

Browse files
committed
Use Acme/HelloBundle in example, update docs
1 parent ed9ddfc commit 1e1ed7b

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

Resources/doc/5-automatic-route-generation_single-restful-controller.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -283,47 +283,50 @@ use FOS\RestBundle\Controller\Annotations\Route;
283283
}
284284
```
285285

286-
### Change pluralization in generated routes
286+
### Changing pluralization in generated routes
287287

288-
For everyone who wants to change pluralization in generated routes, you can do this by replacing "fos_rest.service.inflector" service with your implementation of "fos_rest.inflector.doctrine" service by creating new class that implements "FOS\RestBundle\Util\Inflector\InflectorInterface", than define service of this class with name e.g. "my_fos_rest.inflector.doctrine" and simply set parameter in config.yml.
288+
If you want to change pluralization in generated routes, you can do this by replacing
289+
"fos_rest.service.inflector" service with your own implementation of "fos_rest.inflector".
290+
Create a new class that implements "FOS\RestBundle\Util\Inflector\InflectorInterface" and define a service of this
291+
class with name e.g. "my_fos_rest.inflector" and set the parameter in config.yml.
289292

290-
The example below will remove pluralization by implementing the interface and returning the "$word" instead of executing method ```Inflector::pluralize($word);```
293+
The example below will remove pluralization by implementing the interface and returning the "$word"
294+
instead of executing method ```Inflector::pluralize($word);```
291295

292-
Define your service in config.yml
293-
```
294-
services:
295-
yournamespace.yourbundle.util.inflector.doctrine:
296-
class: YourNamespace\YourBundle\Util\Inflector
297-
```
298-
299-
Tell fos_rest to use your own service as inflector, also in config.yml
300-
```
301-
fos_rest:
302-
service:
303-
inflector: yournamespace.yourbundle.util.inflector.doctrine
304-
```
305-
306-
Example class implementing InflectorInterface
296+
**Example class implementing InflectorInterface**
307297
```php
308298
<?php
309-
namespace YourNamespace\YourBundle\Util\Inflector;
299+
namespace Acme\HelloBundle\Util\Inflector;
310300

311-
use Doctrine\Common\Inflector\Inflector;
312301
use FOS\RestBundle\Util\Inflector\InflectorInterface;
313302

314303
/**
315-
* Inflector object using the Doctrine/Inflector
304+
* Inflector class
316305
*
317306
*/
318-
class DoctrineInflector implements InflectorInterface
307+
class NoopInflector implements InflectorInterface
319308
{
320309
public function pluralize($word)
321310
{
322-
// Don't pluralize <-- By default this is: Inflector::pluralize($word);
311+
// Don't pluralize
323312
return $word;
324313
}
325314
}
326315
```
327316

317+
**Define your service in config.yml**
318+
```
319+
services:
320+
acme.hellobundle.util.inflector:
321+
class: Acme\HelloBundle\Util\NoopInflector
322+
```
323+
324+
**Tell fos_rest to use your own service as inflector, also in config.yml**
325+
```
326+
fos_rest:
327+
service:
328+
inflector: acme.hellobundle.util.inflector
329+
```
330+
328331
## That was it!
329332
[Return to the index](index.md) or continue reading about [Automatic route generation: multiple RESTful controllers](6-automatic-route-generation_multiple-restful-controllers.md).

0 commit comments

Comments
 (0)