Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user