Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
97
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/AssetFactory.php
vendored
Normal file
97
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/AssetFactory.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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\Factory;
|
||||
|
||||
use Assetic\Factory\AssetFactory as BaseAssetFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
||||
* Loads asset formulae from the filesystem.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class AssetFactory extends BaseAssetFactory
|
||||
{
|
||||
private $kernel;
|
||||
private $container;
|
||||
private $parameterBag;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param KernelInterface $kernel The kernel is used to parse bundle notation
|
||||
* @param ContainerInterface $container The container is used to load the managers lazily, thus avoiding a circular dependency
|
||||
* @param ParameterBagInterface $parameterBag The container parameter bag
|
||||
* @param string $baseDir The base directory for relative inputs
|
||||
* @param Boolean $debug The current debug mode
|
||||
*/
|
||||
public function __construct(KernelInterface $kernel, ContainerInterface $container, ParameterBagInterface $parameterBag, $baseDir, $debug = false)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->container = $container;
|
||||
$this->parameterBag = $parameterBag;
|
||||
|
||||
parent::__construct($baseDir, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds support for bundle notation file and glob assets and parameter placeholders.
|
||||
*
|
||||
* FIXME: This is a naive implementation of globs in that it doesn't
|
||||
* attempt to support bundle inheritance within the glob pattern itself.
|
||||
*/
|
||||
protected function parseInput($input, array $options = array())
|
||||
{
|
||||
$input = $this->parameterBag->resolveValue($input);
|
||||
|
||||
// expand bundle notation
|
||||
if ('@' == $input[0] && false !== strpos($input, '/')) {
|
||||
// use the bundle path as this asset's root
|
||||
$bundle = substr($input, 1);
|
||||
if (false !== $pos = strpos($bundle, '/')) {
|
||||
$bundle = substr($bundle, 0, $pos);
|
||||
}
|
||||
$options['root'] = array($this->kernel->getBundle($bundle)->getPath());
|
||||
|
||||
// canonicalize the input
|
||||
if (false !== $pos = strpos($input, '*')) {
|
||||
// locateResource() does not support globs so we provide a naive implementation here
|
||||
list($before, $after) = explode('*', $input, 2);
|
||||
$input = $this->kernel->locateResource($before).'*'.$after;
|
||||
} else {
|
||||
$input = $this->kernel->locateResource($input);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::parseInput($input, $options);
|
||||
}
|
||||
|
||||
protected function createAssetReference($name)
|
||||
{
|
||||
if (!$this->getAssetManager()) {
|
||||
$this->setAssetManager($this->container->get('assetic.asset_manager'));
|
||||
}
|
||||
|
||||
return parent::createAssetReference($name);
|
||||
}
|
||||
|
||||
protected function getFilter($name)
|
||||
{
|
||||
if (!$this->getFilterManager()) {
|
||||
$this->setFilterManager($this->container->get('assetic.filter_manager'));
|
||||
}
|
||||
|
||||
return parent::getFilter($name);
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
<?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\Factory\Loader;
|
||||
|
||||
use Assetic\Factory\Loader\BasePhpFormulaLoader;
|
||||
|
||||
/**
|
||||
* Loads formulae from Symfony2 PHP templates.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class AsseticHelperFormulaLoader extends BasePhpFormulaLoader
|
||||
{
|
||||
protected function registerPrototypes()
|
||||
{
|
||||
return array(
|
||||
'$view[\'assetic\']->javascripts(*)' => array('output' => 'js/*.js'),
|
||||
'$view[\'assetic\']->stylesheets(*)' => array('output' => 'css/*.css'),
|
||||
'$view[\'assetic\']->image(*)' => array('output' => 'images/*', 'single' => true),
|
||||
'$view["assetic"]->javascripts(*)' => array('output' => 'js/*.js'),
|
||||
'$view["assetic"]->stylesheets(*)' => array('output' => 'css/*.css'),
|
||||
'$view["assetic"]->image(*)' => array('output' => 'images/*', 'single' => true),
|
||||
'$view->get(\'assetic\')->javascripts(*)' => array('output' => 'js/*.js'),
|
||||
'$view->get(\'assetic\')->stylesheets(*)' => array('output' => 'css/*.css'),
|
||||
'$view->get(\'assetic\')->image(*)' => array('output' => 'images/*', 'single' => true),
|
||||
'$view->get("assetic")->javascripts(*)' => array('output' => 'js/*.js'),
|
||||
'$view->get("assetic")->stylesheets(*)' => array('output' => 'css/*.css'),
|
||||
'$view->get("assetic")->image(*)' => array('output' => 'images/*', 'single' => true),
|
||||
);
|
||||
}
|
||||
|
||||
protected function registerSetupCode()
|
||||
{
|
||||
return <<<'EOF'
|
||||
class Helper
|
||||
{
|
||||
public function assets()
|
||||
{
|
||||
global $_call;
|
||||
$_call = func_get_args();
|
||||
}
|
||||
|
||||
public function javascripts()
|
||||
{
|
||||
global $_call;
|
||||
$_call = func_get_args();
|
||||
}
|
||||
|
||||
public function stylesheets()
|
||||
{
|
||||
global $_call;
|
||||
$_call = func_get_args();
|
||||
}
|
||||
|
||||
public function image()
|
||||
{
|
||||
global $_call;
|
||||
$_call = func_get_args();
|
||||
}
|
||||
}
|
||||
|
||||
class View extends ArrayObject
|
||||
{
|
||||
public function __construct(Helper $helper)
|
||||
{
|
||||
parent::__construct(array('assetic' => $helper));
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
return $this['assetic'];
|
||||
}
|
||||
}
|
||||
|
||||
$view = new View(new Helper());
|
||||
EOF;
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
<?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\Factory\Loader;
|
||||
|
||||
use Assetic\Factory\Loader\FormulaLoaderInterface;
|
||||
use Assetic\Factory\Resource\ResourceInterface;
|
||||
use Symfony\Bundle\AsseticBundle\Factory\Resource\ConfigurationResource;
|
||||
|
||||
/**
|
||||
* Loads configured formulae.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class ConfigurationLoader implements FormulaLoaderInterface
|
||||
{
|
||||
public function load(ResourceInterface $resource)
|
||||
{
|
||||
return $resource instanceof ConfigurationResource ? $resource->getContent() : array();
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\CoalescingDirectoryResource as BaseCoalescingDirectoryResource;
|
||||
use Assetic\Factory\Resource\ResourceInterface;
|
||||
|
||||
/**
|
||||
* Coalesces multiple directories together into one merged resource.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class CoalescingDirectoryResource extends BaseCoalescingDirectoryResource
|
||||
{
|
||||
protected function getRelativeName(ResourceInterface $file, ResourceInterface $directory)
|
||||
{
|
||||
$name = (string) $file;
|
||||
|
||||
return substr($name, strpos($name, ':'));
|
||||
}
|
||||
}
|
@@ -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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\ResourceInterface;
|
||||
|
||||
/**
|
||||
* A configured resource.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class ConfigurationResource implements ResourceInterface
|
||||
{
|
||||
private $formulae;
|
||||
|
||||
public function __construct(array $formulae)
|
||||
{
|
||||
$this->formulae = $formulae;
|
||||
}
|
||||
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->formulae;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return 'symfony';
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
<?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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\DirectoryResource as BaseDirectoryResource;
|
||||
use Symfony\Component\Templating\Loader\LoaderInterface;
|
||||
|
||||
/**
|
||||
* A directory resource that creates Symfony2 templating resources.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class DirectoryResource extends BaseDirectoryResource
|
||||
{
|
||||
protected $loader;
|
||||
protected $bundle;
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderInterface $loader The templating loader
|
||||
* @param string $bundle The current bundle name
|
||||
* @param string $path The directory path
|
||||
* @param string $pattern A regex pattern for file basenames
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, $bundle, $path, $pattern = null)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->bundle = $bundle;
|
||||
$this->path = rtrim($path, '/').'/';
|
||||
|
||||
parent::__construct($path, $pattern);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return is_dir($this->path)
|
||||
? new DirectoryResourceIterator($this->loader, $this->bundle, $this->path, $this->getInnerIterator())
|
||||
: new \EmptyIterator();
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?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\Factory\Resource;
|
||||
|
||||
use Symfony\Component\Templating\Loader\LoaderInterface;
|
||||
|
||||
class DirectoryResourceIterator extends \RecursiveIteratorIterator
|
||||
{
|
||||
protected $loader;
|
||||
protected $bundle;
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderInterface $loader The templating loader
|
||||
* @param string $bundle The current bundle name
|
||||
* @param string $path The directory
|
||||
* @param RecursiveIterator $iterator The inner iterator
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, $bundle, $path, \RecursiveIterator $iterator)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->bundle = $bundle;
|
||||
$this->path = $path;
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
$file = parent::current();
|
||||
|
||||
return new FileResource($this->loader, $this->bundle, $this->path, $file->getPathname());
|
||||
}
|
||||
}
|
88
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php
vendored
Normal file
88
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\ResourceInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Component\Templating\Loader\LoaderInterface;
|
||||
|
||||
/**
|
||||
* A file resource.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class FileResource implements ResourceInterface
|
||||
{
|
||||
protected $loader;
|
||||
protected $bundle;
|
||||
protected $baseDir;
|
||||
protected $path;
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderInterface $loader The templating loader
|
||||
* @param string $bundle The current bundle name
|
||||
* @param string $baseDir The directory
|
||||
* @param string $path The file path
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, $bundle, $baseDir, $path)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->bundle = $bundle;
|
||||
$this->baseDir = $baseDir;
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
return $this->loader->isFresh($this->getTemplate(), $timestamp);
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$templateReference = $this->getTemplate();
|
||||
$fileResource = $this->loader->load($templateReference);
|
||||
|
||||
if (!$fileResource) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to find template "%s".', $templateReference));
|
||||
}
|
||||
|
||||
return $fileResource->getContent();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->getTemplate();
|
||||
}
|
||||
|
||||
protected function getTemplate()
|
||||
{
|
||||
if (null === $this->template) {
|
||||
$this->template = self::createTemplateReference($this->bundle, substr($this->path, strlen($this->baseDir)));
|
||||
}
|
||||
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
static private function createTemplateReference($bundle, $file)
|
||||
{
|
||||
$parts = explode('/', strtr($file, '\\', '/'));
|
||||
$elements = explode('.', array_pop($parts));
|
||||
$engine = array_pop($elements);
|
||||
$format = array_pop($elements);
|
||||
$name = implode('.', $elements);
|
||||
|
||||
return new TemplateReference($bundle, implode('/', $parts), $name, $format, $engine);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?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\Factory\Worker;
|
||||
|
||||
use Assetic\Asset\AssetInterface;
|
||||
use Assetic\Factory\Worker\WorkerInterface;
|
||||
|
||||
/**
|
||||
* Prepends a fake front controller so the asset knows where it is-ish.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class UseControllerWorker implements WorkerInterface
|
||||
{
|
||||
public function process(AssetInterface $asset)
|
||||
{
|
||||
$targetUrl = $asset->getTargetPath();
|
||||
if ($targetUrl && '/' != $targetUrl[0] && 0 !== strpos($targetUrl, '_controller/')) {
|
||||
$asset->setTargetPath('_controller/'.$targetUrl);
|
||||
}
|
||||
|
||||
return $asset;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user