Ejemplo n.º 1
0
 /**
  * @param Context $context
  * @param int     $direction {@see self} constants
  *
  * @return JMSContext
  */
 private function convertContext(Context $context, $direction)
 {
     if ($direction === self::SERIALIZATION) {
         $jmsContext = JMSSerializationContext::create();
     } else {
         $jmsContext = JMSDeserializationContext::create();
         if (null !== $context->getMaxDepth()) {
             for ($i = 0; $i < $context->getMaxDepth(); ++$i) {
                 $jmsContext->increaseDepth();
             }
         }
     }
     foreach ($context->getAttributes() as $key => $value) {
         $jmsContext->attributes->set($key, $value);
     }
     if (null !== $context->getVersion()) {
         $jmsContext->setVersion($context->getVersion());
     }
     $groups = $context->getGroups();
     if (!empty($groups)) {
         $jmsContext->setGroups($context->getGroups());
     }
     if (null !== $context->getMaxDepth()) {
         $jmsContext->enableMaxDepthChecks();
     }
     if (null !== $context->getSerializeNull()) {
         $jmsContext->setSerializeNull($context->getSerializeNull());
     }
     return $jmsContext;
 }
 /**
  * @param Context $context
  */
 private function convertContext(Context $context)
 {
     $newContext = array();
     foreach ($context->getAttributes() as $key => $value) {
         $newContext[$key] = $value;
     }
     $newContext['groups'] = $context->getGroups();
     $newContext['version'] = $context->getVersion();
     $newContext['maxDepth'] = $context->getMaxDepth();
     return $newContext;
 }