-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for SkipStepException and handling class inheritance #175
Conversation
…ecide what to put on the serialized object
Conflicts: src/JMS/Serializer/GraphNavigator.php
…rent handlers if the known handler is not found for the particulartype
Once a handler throws a SkipStepException, this handler will be ignored and the GraphNavigation will try to reach an another one. Ex: if the user implements a JSON Handler to some special operation, and want to disable in somepoint, just need to throw a SkipStepException and the GraphNavigator will reach the default JSON handler use \PhpOption\None; class IcJsonHandler implements SubscribingHandlerInterface { public static function getSubscribingMethods() { return array( array( 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, 'format' => 'json', 'type' => 'My\Interface', 'method' => 'serializeProxy', ), ); } public function serializeProxy(JsonSerializationVisitor $visitor, $entity, array $type, Context $context) { $skipHandler = $context->attributes->get('my_special_skip_attribute'); if ($visitor->getRoot() === null || ($skipHandler instanceof None === false) { throw new SkipStepException('Skip This'); } return array(/*MySpecial Operation*/); } }
Could you rebase this feature on master and exclude the commits related to the circular reference event? You can do this via |
Rebasing is impossible. This is what I have:
I'm going to resubmit the PR in 20 minutes. |
(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,
Also, this PR supports the class inheritance such that we can specify a parent class in
getSubscribingMethods
. For instance,