schmittjoh/serializer — pull request #177 by shiroyuki (2013-11-06 19:53:38+00:00)
Title: Added the support for class inheritance and skipping handlers

(Originally submitted as #175)

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)
{
/* ... */
}
}
```