/** * @param ContextInterface $context * @param array $options * * @return ContextInterface */ protected function configureDeserializationContext(ContextInterface $context, array $options) { foreach ($options as $key => $value) { if ($key == 'groups' && $context instanceof GroupableContextInterface) { $context->addGroups($options['groups']); } elseif ($key == 'version' && $context instanceof VersionableContextInterface) { $context->setVersion($options['version']); } elseif ($key == 'maxDepth' && $context instanceof MaxDepthContextInterface) { $context->setMaxDepth($options['maxDepth']); } elseif ($key == 'serializeNull' && $context instanceof SerializeNullContextInterface) { $context->setSerializeNull($options['serializeNull']); } else { $context->setAttribute($key, $value); } } return $context; }