schmittjoh/serializer — pull request #175 by shiroyuki (2013-11-04 17:05:48+00:00)
Title: Support for SkipStepException and handling class inheritance

(This PR is based on #174.)

This PR is to add the support to allow the handler to tell the graph navigator to skip itself and proceed with the normal procedure. For instance,

``` php
use PhpOption\None;

class MyHandler implements SubscribingHandlerInterface
{
public function serializeProxy(JsonSerializationVisitor $visitor, $entity, array $type, Context $context)
{
if ($visitor->getRoot() === null) {
throw new SkipStepException('Skip This');
}

return array(/* ... */);
}
}
```

Also, this PR *supports the class inheritance* such that we can specify a parent class in `getSubscribingMethods`. For instance,

``` php
class MyHandler implements SubscribingHandlerInterface
{
public static function getSubscribingMethods()
{
return array(
array(
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
'format' => 'json',
'type' => 'EntityParentClassOrInterface',
'method' => 'serializeProxy',
),
);
}

public function serializeProxy(JsonSerializationVisitor $visitor, $entity, array $type, Context $context)
{
/* ... */
}
}
```