Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function serialize($data, $format, SerializationContext $context = null)
 {
     if ($format === 'json') {
         foreach ($this->exclusionStrategies as $exclusionStrategy) {
             $context->addExclusionStrategy($exclusionStrategy);
         }
     }
     return parent::serialize($data, $format, $context);
 }
 /**
  * @param $fields
  * @return SerializationContext
  */
 protected function getContextWithFields($fields)
 {
     $context = new SerializationContext();
     $context->setGroups(['Default', 'Detail']);
     $context->addExclusionStrategy(new FieldsListExclusionStrategy($fields));
     return $context;
 }