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,70 @@
<?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\DependencyInjection;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
/**
* Configuration class.
*
* @author William DURAND <william.durand1@gmail.com>
*/
class Configuration implements ConfigurationInterface
{
/**
* Generates the configuration tree builder.
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
{
$builder = new TreeBuilder('fos_js_routing');
if (\method_exists($builder, 'getRootNode')) {
$rootNode = $builder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$rootNode = $builder->root('fos_js_routing');
}
$rootNode
->children()
->scalarNode('serializer')->cannotBeEmpty()->end()
->arrayNode('routes_to_expose')
->beforeNormalization()
->ifTrue(function ($v) { return !is_array($v); })
->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()
->end()
->scalarNode('router')->defaultValue('router')->end()
->scalarNode('request_context_base_url')->defaultNull()->end()
->arrayNode('cache_control')
->children()
->booleanNode('public')->defaultFalse()->end()
->scalarNode('expires')->defaultNull()->end()
->scalarNode('maxage')->defaultNull()->end()
->scalarNode('smaxage')->defaultNull()->end()
->arrayNode('vary')
->beforeNormalization()
->ifTrue(function ($v) { return !is_array($v); })
->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()
->end()
->end()
->end()
->end();
return $builder;
}
}

View File

@@ -0,0 +1,69 @@
<?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\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* FOSJsRoutingExtension
* Load configuration.
*
* @author William DURAND <william.durand1@gmail.com>
*/
class FOSJsRoutingExtension extends Extension
{
/**
* Load configuration.
*/
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$loader->load('controllers.xml');
if (isset($config['serializer'])) {
$container->setAlias('fos_js_routing.serializer', new Alias($config['serializer'], false));
} else {
$loader->load('serializer.xml');
}
$container->setAlias(
'fos_js_routing.router',
new Alias($config['router'], false)
);
$container
->getDefinition('fos_js_routing.extractor')
->replaceArgument(1, $config['routes_to_expose']);
$container->setParameter(
'fos_js_routing.request_context_base_url',
$config['request_context_base_url'] ? $config['request_context_base_url'] : null
);
if (isset($config['cache_control'])) {
$config['cache_control']['enabled'] = true;
} else {
$config['cache_control'] = array('enabled' => false);
}
$container->setParameter('fos_js_routing.cache_control', $config['cache_control']);
}
}