/** * {@inheritdoc} */ protected function view($data = null, $statusCode = null, array $headers = []) { $view = parent::view($data, $statusCode, $headers); $context = $view->getSerializationContext(); $context->setGroups(['api', 'Default']); $view->setSerializationContext($context); return $view; }
/** * Creates a new view and sets the serialization context */ protected function view($data = null, $statusCode = null, array $headers = array(), array $serializerGroups = array()) { $view = parent::view($data, $statusCode, $headers); $view->setSerializationContext(SerializationContext::create()); if (0 != count($serializerGroups)) { $view->getSerializationContext()->setGroups($serializerGroups); } return $view; }
/** * Format the view for our API, and return a parent View * * @param mixed $response Response * @param VTExceptionInterface|int|null|string $status * @param array $headers * @param boolean $processActivity do we have to set the lastActivity for the current APIToken ? * * @return FOS\RestBundle\View\View */ protected function view($response = null, $status = VTExceptionInterface::STATUS_OK, array $headers = array(), $processActivity = true) { if (is_array($response)) { } if (empty($response)) { $response = null; } $data = array('response' => $response, 'serverTimestamp' => (new \DateTime())->getTimestamp(), 'status' => $status); return parent::view($data, $this->getStatusCode($status), $headers, $processActivity); }
/** * Override view method in order to set serialization groups easily * * @param null $data * @param null $statusCode * @param array $headers * @param array $serializationContextGroups * * @return \FOS\RestBundle\View\View */ protected function view($data = null, $statusCode = null, array $headers = array(), array $serializationContextGroups = array('Default')) { return parent::view($data, $statusCode, $headers)->setSerializationContext(SerializationContext::create()->setGroups($serializationContextGroups)); }
/** * @param null $data * @param null $statusCode * @param array $headers * @return \FOS\RestBundle\View\View */ protected function view($data = null, $statusCode = null, array $headers = array()) { return parent::view($data, $statusCode, $headers); }
/** * {@inheritdoc} * * @param null $data * @param null $statusCode * @param array $headers */ protected function view($data = null, $statusCode = null, array $headers = array()) { if ($data instanceof Paginator) { // Get iterator out of Paginator class so that the entities are properly serialized by the serializer $data = $data->getIterator()->getArrayCopy(); } return parent::view($data, $statusCode, $headers); }