Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
144
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php
vendored
Normal file
144
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* Semantic asset configuration.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class AsseticExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Loads the configuration.
|
||||
*
|
||||
* @param array $configs An array of configuration settings
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
|
||||
$loader->load('assetic.xml');
|
||||
$loader->load('templating_twig.xml');
|
||||
$loader->load('templating_php.xml');
|
||||
|
||||
$processor = new Processor();
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $processor->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setParameter('assetic.debug', $config['debug']);
|
||||
$container->setParameter('assetic.use_controller', $config['use_controller']['enabled']);
|
||||
$container->setParameter('assetic.enable_profiler', $config['use_controller']['profiler']);
|
||||
$container->setParameter('assetic.read_from', $config['read_from']);
|
||||
$container->setParameter('assetic.write_to', $config['write_to']);
|
||||
$container->setParameter('assetic.variables', $config['variables']);
|
||||
|
||||
$container->setParameter('assetic.java.bin', $config['java']);
|
||||
$container->setParameter('assetic.node.bin', $config['node']);
|
||||
$container->setParameter('assetic.ruby.bin', $config['ruby']);
|
||||
$container->setParameter('assetic.sass.bin', $config['sass']);
|
||||
|
||||
// register formulae
|
||||
$formulae = array();
|
||||
foreach ($config['assets'] as $name => $formula) {
|
||||
$formulae[$name] = array($formula['inputs'], $formula['filters'], $formula['options']);
|
||||
}
|
||||
|
||||
if ($formulae) {
|
||||
$container->getDefinition('assetic.config_resource')->replaceArgument(0, $formulae);
|
||||
} else {
|
||||
$container->removeDefinition('assetic.config_loader');
|
||||
$container->removeDefinition('assetic.config_resource');
|
||||
}
|
||||
|
||||
// register filters
|
||||
foreach ($config['filters'] as $name => $filter) {
|
||||
if (isset($filter['resource'])) {
|
||||
$loader->load($container->getParameterBag()->resolveValue($filter['resource']));
|
||||
unset($filter['resource']);
|
||||
} else {
|
||||
$loader->load('filters/'.$name.'.xml');
|
||||
}
|
||||
|
||||
if (isset($filter['file'])) {
|
||||
$container->getDefinition('assetic.filter.'.$name)->setFile($filter['file']);
|
||||
unset($filter['file']);
|
||||
}
|
||||
|
||||
if (isset($filter['apply_to'])) {
|
||||
if (!is_array($filter['apply_to'])) {
|
||||
$filter['apply_to'] = array($filter['apply_to']);
|
||||
}
|
||||
|
||||
foreach ($filter['apply_to'] as $i => $pattern) {
|
||||
$worker = new DefinitionDecorator('assetic.worker.ensure_filter');
|
||||
$worker->replaceArgument(0, '/'.$pattern.'/');
|
||||
$worker->replaceArgument(1, new Reference('assetic.filter.'.$name));
|
||||
$worker->addTag('assetic.factory_worker');
|
||||
|
||||
$container->setDefinition('assetic.filter.'.$name.'.worker'.$i, $worker);
|
||||
}
|
||||
|
||||
unset($filter['apply_to']);
|
||||
}
|
||||
|
||||
foreach ($filter as $key => $value) {
|
||||
$container->setParameter('assetic.filter.'.$name.'.'.$key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// twig functions
|
||||
$container->setParameter('assetic.twig_extension.functions', $config['twig']['functions']);
|
||||
|
||||
// choose dynamic or static
|
||||
if ($useController = $container->getParameterBag()->resolveValue($container->getParameterBag()->get('assetic.use_controller'))) {
|
||||
$loader->load('controller.xml');
|
||||
$container->getDefinition('assetic.helper.dynamic')->addTag('templating.helper', array('alias' => 'assetic'));
|
||||
$container->removeDefinition('assetic.helper.static');
|
||||
} else {
|
||||
$container->getDefinition('assetic.helper.static')->addTag('templating.helper', array('alias' => 'assetic'));
|
||||
$container->removeDefinition('assetic.helper.dynamic');
|
||||
}
|
||||
|
||||
$container->setParameter('assetic.bundles', $config['bundles']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base path for the XSD files.
|
||||
*
|
||||
* @return string The XSD base path
|
||||
*/
|
||||
public function getXsdValidationBasePath()
|
||||
{
|
||||
return __DIR__ . '/../Resources/config/schema';
|
||||
}
|
||||
|
||||
public function getNamespace()
|
||||
{
|
||||
return 'http://symfony.com/schema/dic/assetic';
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
|
||||
return new Configuration(array_keys($bundles));
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Adds services tagged as workers to the asset factory.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class AssetFactoryPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('assetic.asset_factory')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$factory = $container->getDefinition('assetic.asset_factory');
|
||||
foreach ($container->findTaggedServiceIds('assetic.factory_worker') as $id => $attr) {
|
||||
$factory->addMethodCall('addWorker', array(new Reference($id)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Adds services tagged as assets to the asset manager.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class AssetManagerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('assetic.asset_manager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$am = $container->getDefinition('assetic.asset_manager');
|
||||
|
||||
// add assets
|
||||
foreach ($container->findTaggedServiceIds('assetic.asset') as $id => $attributes) {
|
||||
foreach ($attributes as $attr) {
|
||||
if (isset($attr['alias'])) {
|
||||
$am->addMethodCall('set', array($attr['alias'], new Reference($id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add loaders
|
||||
$loaders = array();
|
||||
foreach ($container->findTaggedServiceIds('assetic.formula_loader') as $id => $attributes) {
|
||||
foreach ($attributes as $attr) {
|
||||
if (isset($attr['alias'])) {
|
||||
$loaders[$attr['alias']] = new Reference($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
$am->replaceArgument(1, $loaders);
|
||||
|
||||
// add resources
|
||||
foreach ($container->findTaggedServiceIds('assetic.formula_resource') as $id => $attributes) {
|
||||
foreach ($attributes as $attr) {
|
||||
if (isset($attr['loader'])) {
|
||||
$am->addMethodCall('addResource', array(new Reference($id), $attr['loader']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Tags either the closure JAR or API filter for the filter manager.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class CheckClosureFilterPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if ($container->hasDefinition('assetic.filter.closure.jar')
|
||||
&& $container->hasParameter('assetic.filter.closure.jar')
|
||||
&& $container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.closure.jar'))) {
|
||||
$container->removeDefinition('assetic.filter.closure.api');
|
||||
$container->setAlias('assetic.filter.closure', 'assetic.filter.closure.jar');
|
||||
} elseif ($container->hasDefinition('assetic.filter.closure.api')) {
|
||||
$container->removeDefinition('assetic.filter.closure.jar');
|
||||
$container->setAlias('assetic.filter.closure', 'assetic.filter.closure.api');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Checks that the location of the CssEmbed JAR has been configured.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class CheckCssEmbedFilterPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if ($container->hasDefinition('assetic.filter.cssembed') &&
|
||||
!$container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.cssembed.jar'))) {
|
||||
throw new \RuntimeException('The "assetic.filters.cssembed" configuration requires a "jar" value.');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Checks that the location of the YUI JAR has been configured.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class CheckYuiFilterPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if ($container->hasDefinition('assetic.filter.yui_css') &&
|
||||
!$container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.yui_css.jar'))) {
|
||||
throw new \RuntimeException('The "assetic.filters.yui_css" configuration requires a "jar" value.');
|
||||
}
|
||||
|
||||
if ($container->hasDefinition('assetic.filter.yui_js') &&
|
||||
!$container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.yui_js.jar'))) {
|
||||
throw new \RuntimeException('The "assetic.filters.yui_js" configuration requires a "jar" value.');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Adds services tagged as filters to the filter manager.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class FilterManagerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('assetic.filter_manager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mapping = array();
|
||||
foreach ($container->findTaggedServiceIds('assetic.filter') as $id => $attributes) {
|
||||
foreach ($attributes as $attr) {
|
||||
if (isset($attr['alias'])) {
|
||||
$mapping[$attr['alias']] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$container
|
||||
->getDefinition('assetic.filter_manager')
|
||||
->replaceArgument(1, $mapping);
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* This pass adds Assetic routes when use_controller is true.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class RouterResourcePass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->getParameter('assetic.use_controller') || !$container->getParameter('router.resource')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = $container->getParameter('kernel.cache_dir').'/assetic/routing.yml';
|
||||
|
||||
if (!is_dir($dir = dirname($file))) {
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
|
||||
file_put_contents($file, Yaml::dump(array(
|
||||
'_assetic' => array('resource' => '.', 'type' => 'assetic'),
|
||||
'_app' => array('resource' => $container->getParameter('router.resource')),
|
||||
)));
|
||||
|
||||
$container->setParameter('router.resource', $file);
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Finishes configuration of the Sprockets filter.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class SprocketsFilterPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('assetic.filter.sprockets')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filter = $container->getDefinition('assetic.filter.sprockets');
|
||||
foreach ($container->getParameter('assetic.filter.sprockets.include_dirs') as $dir) {
|
||||
$filter->addMethodCall('addIncludeDir', array($dir));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Bundle\AsseticBundle\DependencyInjection\DirectoryResourceDefinition;
|
||||
|
||||
/**
|
||||
* This pass adds directory resources to scan for assetic assets.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class TemplateResourcesPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('assetic.asset_manager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$engines = $container->getParameter('templating.engines');
|
||||
|
||||
// bundle and kernel resources
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
$asseticBundles = $container->getParameterBag()->resolveValue($container->getParameter('assetic.bundles'));
|
||||
foreach ($asseticBundles as $bundleName) {
|
||||
$rc = new \ReflectionClass($bundles[$bundleName]);
|
||||
foreach ($engines as $engine) {
|
||||
$this->setBundleDirectoryResources($container, $engine, dirname($rc->getFileName()), $bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($engines as $engine) {
|
||||
$this->setAppDirectoryResources($container, $engine);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setBundleDirectoryResources(ContainerBuilder $container, $engine, $bundleDirName, $bundleName)
|
||||
{
|
||||
$container->setDefinition(
|
||||
'assetic.'.$engine.'_directory_resource.'.$bundleName,
|
||||
new DirectoryResourceDefinition($bundleName, $engine, array(
|
||||
$container->getParameter('kernel.root_dir').'/Resources/'.$bundleName.'/views',
|
||||
$bundleDirName.'/Resources/views',
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
protected function setAppDirectoryResources(ContainerBuilder $container, $engine)
|
||||
{
|
||||
$container->setDefinition(
|
||||
'assetic.'.$engine.'_directory_resource.kernel',
|
||||
new DirectoryResourceDefinition('', $engine, array($container->getParameter('kernel.root_dir').'/Resources/views'))
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* This pass removes services associated with unused templating engines.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class TemplatingPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('assetic.asset_manager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$engines = $container->getParameterBag()->resolveValue($container->getParameter('templating.engines'));
|
||||
|
||||
if (!in_array('twig', $engines)) {
|
||||
foreach ($container->findTaggedServiceIds('assetic.templating.twig') as $id => $attr) {
|
||||
$container->removeDefinition($id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('php', $engines)) {
|
||||
foreach ($container->findTaggedServiceIds('assetic.templating.php') as $id => $attr) {
|
||||
$container->removeDefinition($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
199
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php
vendored
Normal file
199
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This class contains the configuration information for the bundle
|
||||
*
|
||||
* This information is solely responsible for how the different configuration
|
||||
* sections are normalized, and merged.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
private $bundles;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $bundles An array of bundle names
|
||||
*/
|
||||
public function __construct(array $bundles)
|
||||
{
|
||||
$this->bundles = $bundles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the configuration tree builder.
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
$finder = new ExecutableFinder();
|
||||
|
||||
$builder->root('assetic')
|
||||
->children()
|
||||
->booleanNode('debug')->defaultValue('%kernel.debug%')->end()
|
||||
->arrayNode('use_controller')
|
||||
->addDefaultsIfNotSet()
|
||||
->treatTrueLike(array('enabled' => true))
|
||||
->treatFalseLike(array('enabled' => false))
|
||||
->children()
|
||||
->booleanNode('enabled')->defaultValue('%kernel.debug%')->end()
|
||||
->booleanNode('profiler')->defaultFalse()->end()
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('read_from')->defaultValue('%kernel.root_dir%/../web')->end()
|
||||
->scalarNode('write_to')->defaultValue('%assetic.read_from%')->end()
|
||||
->scalarNode('java')->defaultValue(function() use($finder) { return $finder->find('java', '/usr/bin/java'); })->end()
|
||||
->scalarNode('node')->defaultValue(function() use($finder) { return $finder->find('node', '/usr/bin/node'); })->end()
|
||||
->scalarNode('ruby')->defaultValue(function() use($finder) { return $finder->find('ruby', '/usr/bin/ruby'); })->end()
|
||||
->scalarNode('sass')->defaultValue(function() use($finder) { return $finder->find('sass', '/usr/bin/sass'); })->end()
|
||||
->end()
|
||||
|
||||
// variables
|
||||
->fixXmlConfig('variable')
|
||||
->children()
|
||||
->arrayNode('variables')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('array')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
||||
// bundles
|
||||
->fixXmlConfig('bundle')
|
||||
->children()
|
||||
->arrayNode('bundles')
|
||||
->defaultValue($this->bundles)
|
||||
->prototype('scalar')
|
||||
->validate()
|
||||
->ifNotInArray($this->bundles)
|
||||
->thenInvalid('%s is not a valid bundle.')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
||||
// assets
|
||||
->fixXmlConfig('asset')
|
||||
->children()
|
||||
->arrayNode('assets')
|
||||
->requiresAtLeastOneElement()
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('array')
|
||||
->beforeNormalization()
|
||||
// a scalar is a simple formula of one input file
|
||||
->ifTrue(function($v) { return !is_array($v); })
|
||||
->then(function($v) { return array('inputs' => array($v)); })
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->always()
|
||||
->then(function($v)
|
||||
{
|
||||
// cast scalars as array
|
||||
foreach (array('input', 'inputs', 'filter', 'filters') as $key) {
|
||||
if (isset($v[$key]) && !is_array($v[$key])) {
|
||||
$v[$key] = array($v[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// organize arbitrary options
|
||||
foreach ($v as $key => $value) {
|
||||
if (!in_array($key, array('input', 'inputs', 'filter', 'filters', 'option', 'options'))) {
|
||||
$v['options'][$key] = $value;
|
||||
unset($v[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
|
||||
// the formula
|
||||
->fixXmlConfig('input')
|
||||
->fixXmlConfig('filter')
|
||||
->children()
|
||||
->arrayNode('inputs')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->arrayNode('filters')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->arrayNode('options')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('variable')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
||||
// filters
|
||||
->fixXmlConfig('filter')
|
||||
->children()
|
||||
->arrayNode('filters')
|
||||
->requiresAtLeastOneElement()
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('variable')
|
||||
->treatNullLike(array())
|
||||
->validate()
|
||||
->ifTrue(function($v) { return !is_array($v); })
|
||||
->thenInvalid('The assetic.filters config %s must be either null or an array.')
|
||||
->end()
|
||||
->end()
|
||||
->validate()
|
||||
->always(function($v) use ($finder) {
|
||||
if (isset($v['compass']) && !isset($v['compass']['bin'])) {
|
||||
$v['compass']['bin'] = $finder->find('compass', '/usr/bin/compass');
|
||||
}
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
||||
// twig
|
||||
->children()
|
||||
->arrayNode('twig')
|
||||
->addDefaultsIfNotSet()
|
||||
->fixXmlConfig('function')
|
||||
->children()
|
||||
->arrayNode('functions')
|
||||
->defaultValue(array())
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('variable')
|
||||
->treatNullLike(array())
|
||||
->validate()
|
||||
->ifTrue(function($v) { return !is_array($v); })
|
||||
->thenInvalid('The assetic.twig.functions config %s must be either null or an array.')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\AsseticBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Encapsulates logic for creating a directory resource.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class DirectoryResourceDefinition extends Definition
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $bundle A bundle name or empty string
|
||||
* @param string $engine The templating engine
|
||||
* @param array $dirs An array of directories to merge
|
||||
*/
|
||||
public function __construct($bundle, $engine, array $dirs)
|
||||
{
|
||||
if (!count($dirs)) {
|
||||
throw new \InvalidArgumentException('You must provide at least one directory.');
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this
|
||||
->addTag('assetic.templating.'.$engine)
|
||||
->addTag('assetic.formula_resource', array('loader' => $engine));
|
||||
;
|
||||
|
||||
if (1 == count($dirs)) {
|
||||
// no need to coalesce
|
||||
self::configureDefinition($this, $bundle, $engine, reset($dirs));
|
||||
return;
|
||||
}
|
||||
|
||||
// gather the wrapped resource definitions
|
||||
$resources = array();
|
||||
foreach ($dirs as $dir) {
|
||||
$resources[] = $resource = new Definition();
|
||||
self::configureDefinition($resource, $bundle, $engine, $dir);
|
||||
}
|
||||
|
||||
$this
|
||||
->setClass('%assetic.coalescing_directory_resource.class%')
|
||||
->addArgument($resources)
|
||||
->setPublic(false)
|
||||
;
|
||||
}
|
||||
|
||||
static private function configureDefinition(Definition $definition, $bundle, $engine, $dir)
|
||||
{
|
||||
$definition
|
||||
->setClass('%assetic.directory_resource.class%')
|
||||
->addArgument(new Reference('templating.loader'))
|
||||
->addArgument($bundle)
|
||||
->addArgument($dir)
|
||||
->addArgument('/\.[^.]+\.'.$engine.'$/')
|
||||
->setPublic(false)
|
||||
;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user