ezsystems/ezpublish-kernel — pull request #431 by bdunogier (2013-06-22 12:01:31+00:00)
Title: EZP-21120: Refactor REST output to Sf services

Sub-task: http://jira.ez.no/browse/EZP-21120

This PR refactors output related objects to services. It adds the following service tags:

# New service tags

## `ezpublish_rest.output.visitor`

Maps a Request property to an output format (json or xml). It currently only supports matching the Accept HTTP header.

- tag name: ezpublish_rest.output.visitor
- attributes:
- regexp. Either an array of regexp or the name of a container parameter containing such an array

### Example
```yml
parameters:
ezpublish_rest.output.visitor.class: eZ\Publish\Core\REST\Common\Output\Visitor
ezpublish_rest.output.visitor.json.mapping:
- '(^application/vnd\.ez\.api\.[A-Za-z]+\+json$)'
- '(^application/json$)'

services:
ezpublish_rest.output.visitor.json:
class: %ezpublish_rest.output.visitor.class%
arguments:
- @ezpublish_rest.output.generator.json
- @ezpublish_rest.output.value_object_visitor.dispatcher
tags:
- { name: ezpublish_rest.output.visitor, regexps: %ezpublish_rest.output.visitor.json.mapping% }
```

## `ezpublish_rest.output.value_object_visitor`

Maps a ValueObject class name to a Visitor. This visitor will be used to convert objects returned by the REST controllers to a generic format that can be outputed by an ezpublish_rest.output.visitor service.

- tag name: ezpublish_rest.output.value_object_visitor
- attributes:
- type: The FQN of a ValueObject class (without a leading backslash)

These services are defined in `value_object_visitors.yml`.

### Example

```yml
{code:title=value_object_visitors.yml}
parameters:
ezpublish_rest.output.value_object_visitor.ContentList.class: eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\ContentList

services:
ezpublish_rest.output.value_object_visitor.ContentList:
parent: ezpublish_rest.output.value_object_visitor.base
class: %ezpublish_rest.output.value_object_visitor.ContentList.class%
tags:
- { name: ezpublish_rest.output.value_object_visitor, type: eZ\Publish\Core\REST\Server\Values\ContentList }
```

### TODO
- [ ] remove the % signs around the `ezpublish_rest.output.visitor` tag `regexps` attribute