schmittjoh/serializer — pull request #253 by adam-g-pullen (2014-03-23 18:16:45+00:00)
Title: Implemented PathBasedExclusion

This allows the user to annotate their base root class to exclude
complex paths.

For example given the following graph
```php
User
-> Company
-> Users
-> Groups
-> Permissions
-> Groups
-> Groups
-> Permissions
-> Groups
-> Groups
-> Permissions
... and so on
```

The current state of the serializer does an excellent job of prevent recursion. However I am not interested in pulling all the data from the graph.

With this change you can tell the serializer to ignore object paths
```php
use JMS\Serializer\Annotation as JMS;
/**
* FinalConcept\TimeTracker\EntitiesBundle\Entity
*
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="FinalConcept\TimeTracker\EntitiesBundle\Repository\UserRepository")
* @JMS\PathBasedExclusion({"company.users", "company.teams", "company.groups", "groups.users", "groups.permissions.groups", "teams.company", "teams.users"})
*/
class User implements UserInterface, \Serializable
{
//..
}.
```
which will give you a nice neat graph like so
```php
User
-> Company
-> Groups
-> Permissions
```

PathBasedExclusion is designed to work on the root object of the graph. Any PathBasedExclusion annotations found on objects lower down in the graph will be ignored.

Therefore if you want to continue ignoring properties from lower objects you need to add them to the root object