2017-01-05 3 views
0

в "friendsofsymfony/rest-bundle": "~1.4", мы setSerializationContext из "jms/serializer-bundle": "^1.1.0", в этом контексте мы устанавливаем gropu и включить ГлубинаSymfony RestBundle с JMSSerialization setSerializationContext

 return View::create() 
     ->setStatusCode(200) 
     ->setData($certificatesResponse) 
     ->setSerializationContext(
      SerializationContext::create() 
       ->enableMaxDepthChecks() 
       ->setGroups(array('certificates_by_parameters')) 
     ); 

в начале "friendsofsymfony/rest-bundle": "~1.4", мы имеем эту функцию для просмотра класса от RestBundle

/** 
* Sets the serialization context. 
* 
* @param SerializationContext $serializationContext 
* 
* @return View 
*/ 
public function setSerializationContext(SerializationContext $serializationContext) 
{ 
    $this->serializationContext = $serializationContext; 

    return $this; 
} 

В "friendsofsymfony/rest-bundle": "^2.0", Я не нахожу эту функцию, как установить сериализованный контекст в версии 2.0?

+0

Вы должны для 'setSerializationContext' здесь https://github.com/FriendsOfSymfony/FOSRestBundle/ блоб/ведущий/UPGRADING-2.0.md – smarber

ответ

2

Вы должны посмотреть здесь https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/UPGRADING-2.0.md.

==>

View::setSerializationContext and View::getSerializationContext have been removed. Use View::setContext and View::getContext together with the new Context class instead.

Before:

use JMS\Serializer\SerializationContext; 

$view = new View(); 

$context = new SerializationContext(); 
$view->setSerializationContext($context); 

$context = $view->getSerializationContext(); 

After:

use FOS\RestBundle\Context\Context; 

$view = new View(); 

$context = new Context(); 
$view->setContext($context); 

$context = $view->getContext(); 
Смежные вопросы