/** * @param Context $context * @param array|string $groups * @param string|integer $version */ protected function applyExclusionStrategies(Context $context, $groups = null, $version = null) { $context->enableMaxDepthChecks(); if ($groups !== null) { $context->setGroups($groups); } if ($version !== null) { $context->setVersion($version); } }
/** * Fill a jms context. * * @param ContextInterface $context * @param JMSContext $newContext * * @return JMSContext */ private function fillContext(ContextInterface $context, JMSContext $newContext) { foreach ($context->getAttributes() as $key => $value) { $newContext->attributes->set($key, $value); } if ($context instanceof VersionableContextInterface && null !== $context->getVersion()) { $newContext->setVersion($context->getVersion()); } if ($context instanceof GroupableContextInterface) { $groups = $context->getGroups(); if (!empty($groups)) { $newContext->setGroups($context->getGroups()); } } if ($context instanceof MaxDepthContextInterface && null !== $context->getMaxDepth()) { $newContext->enableMaxDepthChecks(); } if ($context instanceof SerializeNullContextInterface && null !== $context->getSerializeNull()) { $newContext->setSerializeNull($context->getSerializeNull()); } return $newContext; }
/** * @param Context $context * @param array $options * @return Context */ protected function configureContext(Context $context, array $options) { if (isset($options['groups'])) { $context->setGroups($options['groups']); } if (isset($options['version'])) { $context->setVersion($options['version']); } return $context; }