Download project

This commit is contained in:
Roman Pyrih
2024-11-20 09:09:44 +01:00
parent 547a138d6a
commit 5ff041757f
40737 changed files with 7766183 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<?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 Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* Class RouteCollectionNormalizer
*/
class RouteCollectionNormalizer implements NormalizerInterface
{
/**
* {@inheritDoc}
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($data, $format = null, array $context = array())
{
$collection = array();
foreach ($data->all() as $name => $route) {
$collection[$name] = array(
'path' => $route->getPath(),
'host' => $route->getHost(),
'defaults' => $route->getDefaults(),
'requirements' => $route->getRequirements(),
'options' => $route->getOptions(),
'schemes' => $route->getSchemes(),
'methods' => $route->getMethods(),
'condition' => method_exists($route, 'getCondition') ? $route->getCondition() : '',
);
}
return $collection;
}
/**
* {@inheritDoc}
*/
public function supportsNormalization($data, $format = null): bool
{
return $data instanceof RouteCollection;
}
}

View File

@@ -0,0 +1,46 @@
<?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}
* @return array|string|int|float|bool|\ArrayObject|null
*/
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): bool
{
return $data instanceof RoutesResponse;
}
}