/
RoutesResponseNormalizer.php
45 lines (40 loc) · 1.16 KB
/
RoutesResponseNormalizer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of the FOSJsRoutingBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\JsRoutingBundle\Serializer\Normalizer;
use FOS\JsRoutingBundle\Response\RoutesResponse;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* Class RoutesResponseNormalizer
*/
class RoutesResponseNormalizer implements NormalizerInterface
{
/**
* {@inheritdoc}
*/
public function normalize($data, $format = null, array $context = array())
{
return array(
'base_url' => $data->getBaseUrl(),
'routes' => $data->getRoutes(),
'prefix' => $data->getPrefix(),
'host' => $data->getHost(),
'port' => $data->getPort(),
'scheme' => $data->getScheme(),
'locale' => $data->getLocale(),
);
}
/**
* {@inheritDoc}
*/
public function supportsNormalization($data, $format = null)
{
return $data instanceof RoutesResponse;
}
}