moved duplicated files to a new Config component
This commit is contained in:
parent
a72145bf5f
commit
a8ec9b27f0
|
@ -14,12 +14,12 @@ namespace Symfony\Bundle\DoctrineBundle\DependencyInjection;
|
|||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Resource\FileResource;
|
||||
use Symfony\Bundle\DoctrineAbstractBundle\DependencyInjection\AbstractDoctrineExtension;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* DoctrineExtension is an extension for the Doctrine DBAL and ORM library.
|
||||
|
|
|
@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class XmlDoctrineExtensionTest extends AbstractDoctrineExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class YamlDoctrineExtensionTest extends AbstractDoctrineExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\DependencyInjection;
|
|||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Resource\FileResource;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
use Symfony\Bundle\DoctrineAbstractBundle\DependencyInjection\AbstractDoctrineExtension;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class XmlMongoDBExtensionTest extends AbstractMongoDBExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class YamlMongoDBExtensionTest extends AbstractMongoDBExtensionTest
|
||||
{
|
||||
|
|
|
@ -17,10 +17,10 @@ use Symfony\Component\DependencyInjection\Parameter;
|
|||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Configuration\Processor;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\Resource\FileResource;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* FrameworkExtension.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<parameter key="router.class">Symfony\Component\Routing\Router</parameter>
|
||||
<parameter key="router.cached.class">Symfony\Bundle\FrameworkBundle\Routing\CachedRouter</parameter>
|
||||
<parameter key="routing.loader.class">Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader</parameter>
|
||||
<parameter key="routing.file_locator.class">Symfony\Bundle\FrameworkBundle\Routing\FileLocator</parameter>
|
||||
<parameter key="routing.file_locator.class">Symfony\Component\HttpKernel\Config\FileLocator</parameter>
|
||||
<parameter key="routing.resolver.class">Symfony\Component\Routing\Loader\LoaderResolver</parameter>
|
||||
<parameter key="routing.loader.xml.class">Symfony\Component\Routing\Loader\XmlFileLoader</parameter>
|
||||
<parameter key="routing.loader.yml.class">Symfony\Component\Routing\Loader\YamlFileLoader</parameter>
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class XmlFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class YamlFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
namespace Symfony\Bundle\FrameworkBundle\Tests;
|
||||
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
|
|
|
@ -17,13 +17,13 @@ use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
|||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Parameter;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class PhpSecurityExtensionTest extends SecurityExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class XmlSecurityExtensionTest extends SecurityExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class YamlSecurityExtensionTest extends SecurityExtensionTest
|
||||
{
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;
|
|||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* SwiftMailerExtension is an extension for the SwiftMailer library.
|
||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* TwigExtension.
|
||||
|
|
|
@ -13,11 +13,11 @@ namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection;
|
|||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* WebProfilerExtension.
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace Symfony\Bundle\ZendBundle\DependencyInjection;
|
|||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* ZendExtension is an extension for the Zend Framework libraries.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* DelegatingLoader delegates loading to other loaders using a loader resolver.
|
|
@ -9,9 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* FileLoader is the abstract class used by all built-in loaders that are file based.
|
||||
|
@ -23,6 +21,9 @@ abstract class FileLoader extends Loader
|
|||
protected $locator;
|
||||
protected $currentDir;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(FileLocator $locator)
|
||||
{
|
||||
$this->locator = $locator;
|
||||
|
@ -34,21 +35,24 @@ abstract class FileLoader extends Loader
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds routes from a resource.
|
||||
* Adds definitions and parameters from a resource.
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return RouteCollection A RouteCollection instance
|
||||
* @param mixed $resource A Resource
|
||||
*/
|
||||
public function import($resource, $type = null)
|
||||
public function import($resource, $ignoreErrors = false)
|
||||
{
|
||||
$loader = $this->resolve($resource, $type);
|
||||
try {
|
||||
$loader = $this->resolve($resource);
|
||||
|
||||
if ($loader instanceof FileLoader && null !== $this->currentDir) {
|
||||
$resource = $this->locator->getAbsolutePath($resource, $this->currentDir);
|
||||
if ($loader instanceof FileLoader && null !== $this->currentDir) {
|
||||
$resource = $this->locator->getAbsolutePath($resource, $this->currentDir);
|
||||
}
|
||||
|
||||
$loader->load($resource);
|
||||
} catch (\Exception $e) {
|
||||
if (!$ignoreErrors) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return $loader->load($resource, $type);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* FileLocator uses an array of pre-defined paths to find files.
|
|
@ -9,9 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* Loader is the abstract class used by all built-in loaders.
|
||||
|
@ -20,19 +18,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
*/
|
||||
abstract class Loader implements LoaderInterface
|
||||
{
|
||||
protected $container;
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
*/
|
||||
public function __construct(ContainerBuilder $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loader resolver.
|
||||
*
|
|
@ -9,12 +9,10 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* LoaderInterface is the interface that all loader classes must implement.
|
||||
* LoaderInterface is the interface implemented by all loader classes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
|
@ -23,22 +21,18 @@ interface LoaderInterface
|
|||
/**
|
||||
* Loads a resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return RouteCollection A RouteCollection instance
|
||||
* @param mixed $resource The resource
|
||||
*/
|
||||
function load($resource, $type = null);
|
||||
function load($resource);
|
||||
|
||||
/**
|
||||
* Returns true if this class supports the given resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
* @param mixed $resource A resource
|
||||
*
|
||||
* @return Boolean True if this class supports the given resource, false otherwise
|
||||
* @return Boolean true if this class supports the given resource, false otherwise
|
||||
*/
|
||||
function supports($resource, $type = null);
|
||||
function supports($resource);
|
||||
|
||||
/**
|
||||
* Gets the loader resolver.
|
|
@ -9,14 +9,13 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* LoaderResolver selects a loader for a given resource.
|
||||
*
|
||||
* A resource can be anything that can be converted to a ContainerBuilder
|
||||
* instance (e.g. a full path to a config file or a Closure). Each
|
||||
* loader determines whether it can load a resource and how.
|
||||
* A resource can be anything (e.g. a full path to a config file or a Closure).
|
||||
* Each loader determines whether it can load a resource and how.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* LoaderResolverInterface selects a loader for a given resource.
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\Loader\Loader;
|
||||
|
||||
/**
|
||||
* ClosureLoader loads service definitions from a PHP closure.
|
||||
*
|
||||
|
@ -20,6 +23,18 @@ namespace Symfony\Component\DependencyInjection\Loader;
|
|||
*/
|
||||
class ClosureLoader extends Loader
|
||||
{
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
*/
|
||||
public function __construct(ContainerBuilder $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a Closure.
|
||||
*
|
||||
|
|
|
@ -12,16 +12,17 @@
|
|||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\Loader\FileLoader as BaseFileLoader;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* FileLoader is the abstract class used by all built-in loaders that are file based.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
abstract class FileLoader extends Loader
|
||||
abstract class FileLoader extends BaseFileLoader
|
||||
{
|
||||
protected $locator;
|
||||
protected $currentDir;
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -30,35 +31,8 @@ abstract class FileLoader extends Loader
|
|||
*/
|
||||
public function __construct(ContainerBuilder $container, FileLocator $locator)
|
||||
{
|
||||
$this->locator = $locator;
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
public function getLocator()
|
||||
{
|
||||
return $this->locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds definitions and parameters from a resource.
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
*/
|
||||
public function import($resource, $ignoreErrors = false)
|
||||
{
|
||||
try {
|
||||
$loader = $this->resolve($resource);
|
||||
|
||||
if ($loader instanceof FileLoader && null !== $this->currentDir) {
|
||||
$resource = $this->locator->getAbsolutePath($resource, $this->currentDir);
|
||||
}
|
||||
|
||||
$loader->load($resource);
|
||||
} catch (\Exception $e) {
|
||||
if (!$ignoreErrors) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
parent::__construct($locator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
/**
|
||||
* FileLocator uses an array of pre-defined paths to find files.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
class FileLocator
|
||||
{
|
||||
protected $paths;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|array $paths A path or an array of paths where to look for resources
|
||||
*/
|
||||
public function __construct($paths = array())
|
||||
{
|
||||
if (!is_array($paths)) {
|
||||
$paths = array($paths);
|
||||
}
|
||||
$this->paths = $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a full path for a given file.
|
||||
*
|
||||
* @param string $file A file path
|
||||
* @param string $currentPath The current path
|
||||
*
|
||||
* @return string The full path for the file
|
||||
*
|
||||
* @throws \InvalidArgumentException When file is not found
|
||||
*/
|
||||
public function locate($file, $currentPath = null)
|
||||
{
|
||||
$path = $this->getAbsolutePath($file, $currentPath);
|
||||
if (!file_exists($path)) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $file, implode(', ', $this->paths)));
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the absolute path for the file path if possible.
|
||||
*
|
||||
* @param string $file A file path
|
||||
* @param string $currentPath The current path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAbsolutePath($file, $currentPath = null)
|
||||
{
|
||||
if ($this->isAbsolutePath($file)) {
|
||||
return $file;
|
||||
} else if (null !== $currentPath && file_exists($currentPath.DIRECTORY_SEPARATOR.$file)) {
|
||||
return $currentPath.DIRECTORY_SEPARATOR.$file;
|
||||
} else {
|
||||
foreach ($this->paths as $path) {
|
||||
if (file_exists($path.DIRECTORY_SEPARATOR.$file)) {
|
||||
return $path.DIRECTORY_SEPARATOR.$file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the file path is an absolute path.
|
||||
*
|
||||
* @param string $file A file path
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isAbsolutePath($file)
|
||||
{
|
||||
if ($file[0] == '/' || $file[0] == '\\'
|
||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||
&& $file[1] == ':'
|
||||
&& ($file[2] == '\\' || $file[2] == '/')
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* LoaderInterface is the interface implemented by all loader classes.
|
||||
*
|
||||
* $loader = new XXXLoader();
|
||||
* $config = $loader->load('resource_name');
|
||||
*
|
||||
* $container = new ContainerBuilder();
|
||||
* $container->merge($config);
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
interface LoaderInterface
|
||||
{
|
||||
/**
|
||||
* Loads a resource.
|
||||
*
|
||||
* A resource can be anything that can be converted to a
|
||||
* ContainerBuilder instance.
|
||||
*
|
||||
* Some loaders support an array of resources as an argument to the
|
||||
* constructor.
|
||||
*
|
||||
* If multiple resources are loaded, the services and parameters are merged.
|
||||
*
|
||||
* Remember that services and parameters are simple key/pair stores.
|
||||
*
|
||||
* When overriding a value, the old one is totally replaced, even if it is
|
||||
* a "complex" value (an array for instance):
|
||||
*
|
||||
* <pre>
|
||||
* file1.xml
|
||||
* <parameter key="complex" type="collection">
|
||||
* <parameter>true</parameter>
|
||||
* <parameter>false</parameter>
|
||||
* </parameter>
|
||||
*
|
||||
* file2.xml
|
||||
* <parameter key="complex">foo</parameter>
|
||||
* </pre>
|
||||
*
|
||||
* If you load file1.xml and file2.xml in this order, the value of complex
|
||||
* will be "foo".
|
||||
*
|
||||
* @param mixed $resource The resource
|
||||
*/
|
||||
function load($resource);
|
||||
|
||||
/**
|
||||
* Returns true if this class supports the given resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
*
|
||||
* @return Boolean true if this class supports the given resource, false otherwise
|
||||
*/
|
||||
function supports($resource);
|
||||
|
||||
/**
|
||||
* Gets the loader resolver.
|
||||
*
|
||||
* @return LoaderResolver A LoaderResolver instance
|
||||
*/
|
||||
function getResolver();
|
||||
|
||||
/**
|
||||
* Sets the loader resolver.
|
||||
*
|
||||
* @param LoaderResolver $resolver A LoaderResolver instance
|
||||
*/
|
||||
function setResolver(LoaderResolver $resolver);
|
||||
}
|
|
@ -9,9 +9,9 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Routing;
|
||||
namespace Symfony\Component\HttpKernel\Config\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\FileLocator as BaseFileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator as BaseFileLocator;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator as BaseFileLocator;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
||||
* FileLocator uses the KernelInterface to locate resources in bundles.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
class FileLocator extends BaseFileLocator
|
||||
{
|
||||
protected $kernel;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param KernelInterface $kernel A KernelInterface instance
|
||||
* @param string|array $paths A path or an array of paths where to look for resources
|
||||
*/
|
||||
public function __construct(KernelInterface $kernel, array $paths = array())
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
|
||||
parent::__construct($paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function locate($file, $currentPath = null)
|
||||
{
|
||||
if ('@' === $file[0]) {
|
||||
return $this->kernel->locateResource($file);
|
||||
}
|
||||
|
||||
return parent::locate($file, $currentPath);
|
||||
}
|
||||
}
|
|
@ -15,9 +15,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
|
@ -26,7 +23,9 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\HttpKernel\Config\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
|
||||
/**
|
||||
* The Kernel is the heart of the Symfony system.
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
namespace Symfony\Component\HttpKernel;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
||||
/**
|
||||
* The Kernel is the heart of the Symfony system.
|
||||
|
|
|
@ -438,9 +438,9 @@ class HttpKernel implements HttpKernelInterface
|
|||
namespace Symfony\Component\HttpKernel
|
||||
{
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
{
|
||||
function registerRootDir();
|
||||
|
@ -469,7 +469,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
namespace Symfony\Component\HttpKernel
|
||||
{
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
{
|
||||
function registerRootDir();
|
||||
|
@ -33,7 +33,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
|
|
@ -13,10 +13,11 @@ namespace Symfony\Component\Routing\Loader;
|
|||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Symfony\Component\Routing\Annotation\Route as RouteAnnotation;
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
|
||||
/**
|
||||
* AnnotationClassLoader loads routing information from a PHP class and its methods.
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Routing\Loader;
|
|||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Resource\FileResource;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
/**
|
||||
* AnnotationFileLoader loads routing information from annotations set
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\Loader;
|
||||
|
||||
/**
|
||||
* ClosureLoader loads routes from a PHP closure.
|
||||
*
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* DelegatingLoader delegates route loading to other loaders using a loader resolver.
|
||||
*
|
||||
* This loader acts as an array of LoaderInterface objects - each having
|
||||
* a chance to load a given resource (handled by the resolver)
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
class DelegatingLoader extends Loader
|
||||
{
|
||||
/**
|
||||
* @var LoaderResolverInterface
|
||||
*/
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
||||
*/
|
||||
public function __construct(LoaderResolverInterface $resolver)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return RouteCollection A RouteCollection instance
|
||||
*
|
||||
* @throws \InvalidArgumentException When the resource cannot be loaded
|
||||
*/
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
$loader = $this->resolver->resolve($resource, $type);
|
||||
|
||||
if (false === $loader) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load the "%s" routing resource.', is_string($resource) ? $resource : (is_object($resource) ? get_class($resource) : 'RESOURCE')));
|
||||
}
|
||||
|
||||
return $loader->load($resource, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this class supports the given resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return Boolean True if this class supports the given resource, false otherwise
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
foreach ($this->resolver->getLoaders() as $loader) {
|
||||
if ($loader->supports($resource, $type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
/**
|
||||
* Loader is the abstract class used by all built-in loaders.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
abstract class Loader implements LoaderInterface
|
||||
{
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* Gets the loader resolver.
|
||||
*
|
||||
* @return LoaderResolver A LoaderResolver instance
|
||||
*/
|
||||
public function getResolver()
|
||||
{
|
||||
return $this->resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the loader resolver.
|
||||
*
|
||||
* @param LoaderResolver $resolver A LoaderResolver instance
|
||||
*/
|
||||
public function setResolver(LoaderResolver $resolver)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds routes from a resource.
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
*/
|
||||
public function import($resource, $type = null)
|
||||
{
|
||||
$this->resolve($resource, $type)->load($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a loader able to load an imported resource
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return LoaderInterface A LoaderInterface instance
|
||||
*
|
||||
* @throws \InvalidArgumentException if no loader is found
|
||||
*/
|
||||
public function resolve($resource, $type = null)
|
||||
{
|
||||
$loader = false;
|
||||
if ($this->supports($resource, $type)) {
|
||||
$loader = $this;
|
||||
} elseif (null !== $this->resolver) {
|
||||
$loader = $this->resolver->resolve($resource, $type);
|
||||
}
|
||||
|
||||
if (false === $loader) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load the "%s" routing resource.', is_string($resource) ? $resource : (is_object($resource) ? get_class($resource) : 'RESOURCE')));
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
/**
|
||||
* LoaderResolver selects a loader for a given resource.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
class LoaderResolver implements LoaderResolverInterface
|
||||
{
|
||||
protected $loaders;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $loaders An array of LoaderInterface instances to add
|
||||
*/
|
||||
public function __construct(array $loaders = array())
|
||||
{
|
||||
$this->loaders = array();
|
||||
foreach ($loaders as $loader) {
|
||||
$this->addLoader($loader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a loader able to load the resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return LoaderInterface|false A LoaderInterface instance supporting the resource if one exists, false otherwise
|
||||
*/
|
||||
public function resolve($resource, $type = null)
|
||||
{
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader->supports($resource, $type)) {
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a loader.
|
||||
*
|
||||
* @param LoaderInterface $loader A LoaderInterface instance
|
||||
*/
|
||||
public function addLoader(LoaderInterface $loader)
|
||||
{
|
||||
$this->loaders[] = $loader;
|
||||
$loader->setResolver($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the registered loaders.
|
||||
*
|
||||
* @return array An array of LoaderInterface instances
|
||||
*/
|
||||
public function getLoaders()
|
||||
{
|
||||
return $this->loaders;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
/**
|
||||
* LoaderResolverInterface selects a loader for a given resource.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*/
|
||||
interface LoaderResolverInterface
|
||||
{
|
||||
/**
|
||||
* Returns a loader able to load the resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return LoaderInterface|false A LoaderInterface instance supporting the resource if one exists, false otherwise
|
||||
*/
|
||||
function resolve($resource, $type = null);
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
namespace Symfony\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Resource\FileResource;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
|
||||
/**
|
||||
* PhpFileLoader loads routes from a PHP file.
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Routing\Loader;
|
|||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\Resource\FileResource;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
|
||||
/**
|
||||
* XmlFileLoader loads XML routing files.
|
||||
|
|
|
@ -15,6 +15,7 @@ use Symfony\Component\Routing\RouteCollection;
|
|||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\Resource\FileResource;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Config\Loader\FileLoader;
|
||||
|
||||
/**
|
||||
* YamlFileLoader loads Yaml routing files.
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
use Symfony\Component\Config\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\Loader\ClosureLoader;
|
||||
use Symfony\Component\Config\RouteCollection;
|
||||
use Symfony\Component\Config\Route;
|
||||
|
||||
class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$loader = new DelegatingLoader($resolver = new LoaderResolver());
|
||||
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::getResolver
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader');
|
||||
$loader->setResolver($resolver = new LoaderResolver());
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::supports
|
||||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
|
||||
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
|
||||
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::load
|
||||
*/
|
||||
public function testLoad()
|
||||
{
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$loader->expects($this->once())->method('load');
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$loader->load('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
|
||||
{
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(false));
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$loader->load('foo');
|
||||
}
|
||||
}
|
|
@ -9,15 +9,15 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
namespace Symfony\Tests\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class FileLocatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\FileLocator::GetAbsolutePath
|
||||
* @covers Symfony\Component\Routing\Loader\FileLocator::isAbsolutePath
|
||||
* @covers Symfony\Component\Config\Loader\FileLocator::GetAbsolutePath
|
||||
* @covers Symfony\Component\Config\Loader\FileLocator::isAbsolutePath
|
||||
*/
|
||||
public function testGetAbsolutePath()
|
||||
{
|
|
@ -9,47 +9,47 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\DependencyInjection\Loader;
|
||||
namespace Symfony\Tests\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
|
||||
class LoaderResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\LoaderResolver::__construct
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$loader = new ClosureLoader(new ContainerBuilder()),
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'),
|
||||
));
|
||||
|
||||
$this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\LoaderResolver::resolve
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::resolve
|
||||
*/
|
||||
public function testResolve()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$loader = new ClosureLoader(new ContainerBuilder()),
|
||||
));
|
||||
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
|
||||
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\LoaderResolver::getLoaders
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\LoaderResolver::addLoader
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::getLoaders
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::addLoader
|
||||
*/
|
||||
public function testLoaders()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$resolver->addLoader($loader = new ClosureLoader(new ContainerBuilder()));
|
||||
$resolver->addLoader($loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'));
|
||||
|
||||
$this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
|
||||
}
|
|
@ -9,17 +9,16 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
namespace Symfony\Tests\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\Loader;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\Loader;
|
||||
|
||||
class LoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\Loader::getResolver
|
||||
* @covers Symfony\Component\Routing\Loader\Loader::setResolver
|
||||
* @covers Symfony\Component\Config\Loader\Loader::getResolver
|
||||
* @covers Symfony\Component\Config\Loader\Loader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
|
@ -30,19 +29,24 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\Loader::resolve
|
||||
* @covers Symfony\Component\Config\Loader\Loader::resolve
|
||||
*/
|
||||
public function testResolve()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$ini = new XmlFileLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator')),
|
||||
));
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$resolver = new LoaderResolver(array($loader1));
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
|
||||
$this->assertSame($ini, $loader->resolve('foo.xml'), '->resolve() finds a loader');
|
||||
$this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader');
|
||||
$this->assertSame($loader1, $loader->resolve('foo.xml'), '->resolve() finds a loader');
|
||||
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
|
||||
$resolver = new LoaderResolver(array($loader1));
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
try {
|
||||
$loader->resolve(new \stdClass());
|
||||
$this->fail('->resolve() throws an \InvalidArgumentException if the resource cannot be loaded');
|
|
@ -12,7 +12,7 @@
|
|||
namespace Symfony\Tests\Component\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class CrossCheckTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
|
||||
class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\DelegatingLoader::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\DelegatingLoader::getResolver
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\DelegatingLoader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader');
|
||||
$loader->setResolver($resolver = new LoaderResolver());
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\DelegatingLoader::supports
|
||||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = new LoaderResolver(array(
|
||||
$ini = new IniFileLoader($container, new FileLocator(array())),
|
||||
));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$this->assertTrue($loader->supports('foo.ini'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\DelegatingLoader::load
|
||||
*/
|
||||
public function testLoad()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = new LoaderResolver(array(
|
||||
new ClosureLoader($container),
|
||||
));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$loader->load(function ($container)
|
||||
{
|
||||
$container->setParameter('foo', 'foo');
|
||||
});
|
||||
|
||||
$this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a resource using the loaders from the resolver');
|
||||
|
||||
try {
|
||||
$loader->load('foo.foo');
|
||||
$this->fail('->load() throws an \InvalidArgumentException if the resource cannot be loaded');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an \InvalidArgumentException if the resource cannot be loaded');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
|
||||
class FileLocatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\FileLocator::GetAbsolutePath
|
||||
*/
|
||||
public function testGetAbsolutePath()
|
||||
{
|
||||
$loader = new FileLocator(array(__DIR__.'/../Fixtures/containers'));
|
||||
$this->assertEquals('/foo.xml', $loader->getAbsolutePath('/foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
|
||||
$this->assertEquals('c:\\\\foo.xml', $loader->getAbsolutePath('c:\\\\foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
|
||||
$this->assertEquals('c:/foo.xml', $loader->getAbsolutePath('c:/foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
|
||||
$this->assertEquals('\\server\\foo.xml', $loader->getAbsolutePath('\\server\\foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
|
||||
|
||||
$this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'FileLocatorTest.php', $loader->getAbsolutePath('FileLocatorTest.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in the current path');
|
||||
|
||||
$this->assertEquals(__DIR__.'/../Fixtures/containers'.DIRECTORY_SEPARATOR.'container10.php', $loader->getAbsolutePath('container10.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor');
|
||||
|
||||
$this->assertEquals('foo.xml', $loader->getAbsolutePath('foo.xml', __DIR__), '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths');
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace Symfony\Tests\Component\DependencyInjection\Loader;
|
|||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class IniFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\DependencyInjection\Loader;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\Loader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
|
||||
class LoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\Loader::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$loader = new ProjectLoader1(new ContainerBuilder());
|
||||
$this->assertTrue(true, '__construct() takes a container builder as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\Loader::getResolver
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\Loader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new ProjectLoader1(new ContainerBuilder());
|
||||
$loader->setResolver($resolver);
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\Loader\Loader::resolve
|
||||
*/
|
||||
public function testResolve()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$resolver = new LoaderResolver(array(
|
||||
$ini = new IniFileLoader($container, new FileLocator(array())),
|
||||
));
|
||||
$loader = new ProjectLoader1($container);
|
||||
$loader->setResolver($resolver);
|
||||
|
||||
$this->assertSame($ini, $loader->resolve('foo.ini'), '->resolve() finds a loader');
|
||||
$this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader');
|
||||
|
||||
try {
|
||||
$loader->resolve(new \stdClass());
|
||||
$this->fail('->resolve() throws an \InvalidArgumentException if the resource cannot be loaded');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->resolve() throws an \InvalidArgumentException if the resource cannot be loaded');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectLoader1 extends Loader
|
||||
{
|
||||
public function load($resource)
|
||||
{
|
||||
}
|
||||
|
||||
public function supports($resource)
|
||||
{
|
||||
return is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION);
|
||||
}
|
||||
}
|
|
@ -16,8 +16,8 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Loader\Loader;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -20,8 +20,8 @@ use Symfony\Component\DependencyInjection\Loader\Loader;
|
|||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -18,8 +18,8 @@ use Symfony\Component\DependencyInjection\Loader\Loader;
|
|||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -14,9 +14,9 @@ namespace Symfony\Tests\Component\HttpKernel;
|
|||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
||||
class KernelTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\AnnotationClassLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Loader\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
|
||||
class AnnotationDirectoryLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
@ -27,7 +27,7 @@ class AnnotationFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$loader = new AnnotationFileLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator'), $annotationClassLoader);
|
||||
$loader = new AnnotationFileLoader($this->getMock('Symfony\Component\Config\Loader\FileLocator'), $annotationClassLoader);
|
||||
|
||||
$fixture = __DIR__.'/../Fixtures/annotated.php';
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\AnnotationGlobLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
@ -27,7 +27,7 @@ class AnnotationGlobLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$loader = new AnnotationGlobLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator'), $annotationClassLoader);
|
||||
$loader = new AnnotationGlobLoader($this->getMock('Symfony\Component\Config\Loader\FileLocator'), $annotationClassLoader);
|
||||
|
||||
$this->assertTrue($loader->supports('*'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\ClosureLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\DelegatingLoader;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Routing\Loader\ClosureLoader;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\DelegatingLoader::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\DelegatingLoader::getResolver
|
||||
* @covers Symfony\Component\Routing\Loader\DelegatingLoader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader');
|
||||
$loader->setResolver($resolver = new LoaderResolver());
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\DelegatingLoader::supports
|
||||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$ini = new XmlFileLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator')),
|
||||
));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\DelegatingLoader::load
|
||||
*/
|
||||
public function testLoad()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
new ClosureLoader(),
|
||||
));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$route = new Route('/');
|
||||
$routes = $loader->load(function () use ($route)
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$routes->add('foo', $route);
|
||||
|
||||
return $routes;
|
||||
});
|
||||
|
||||
$this->assertSame($route, $routes->get('foo'), '->load() loads a resource using the loaders from the resolver');
|
||||
|
||||
try {
|
||||
$loader->load('foo.foo');
|
||||
$this->fail('->load() throws an \InvalidArgumentException if the resource cannot be loaded');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an \InvalidArgumentException if the resource cannot be loaded');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\ClosureLoader;
|
||||
|
||||
class LoaderResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\LoaderResolver::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$loader = new ClosureLoader(),
|
||||
));
|
||||
|
||||
$this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\LoaderResolver::resolve
|
||||
*/
|
||||
public function testResolve()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$loader = new ClosureLoader(),
|
||||
));
|
||||
|
||||
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
|
||||
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Routing\Loader\LoaderResolver::getLoaders
|
||||
* @covers Symfony\Component\Routing\Loader\LoaderResolver::addLoader
|
||||
*/
|
||||
public function testLoaders()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$resolver->addLoader($loader = new ClosureLoader());
|
||||
|
||||
$this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\PhpFileLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
@ -23,7 +23,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new PhpFileLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator'));
|
||||
$loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\Loader\FileLocator'));
|
||||
|
||||
$this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
@ -23,7 +23,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new XmlFileLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator'));
|
||||
$loader = new XmlFileLoader($this->getMock('Symfony\Component\Config\Loader\FileLocator'));
|
||||
|
||||
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
namespace Symfony\Tests\Component\Routing\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Loader\FileLocator;
|
||||
|
||||
class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new YamlFileLoader($this->getMock('Symfony\Component\Routing\Loader\FileLocator'));
|
||||
$loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\Loader\FileLocator'));
|
||||
|
||||
$this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
|
Reference in New Issue