diff --git a/core/composer.json b/core/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..64928b1191f9a7ba1db0f015670268522131c06a --- /dev/null +++ b/core/composer.json @@ -0,0 +1,13 @@ +{ + "require": { + "symfony/class-loader": "2.1.*", + "symfony/dependency-injection": "2.1.*", + "symfony/event-dispatcher": "2.1.*", + "symfony/http-foundation": "2.1.*", + "symfony/http-kernel": "2.1.*", + "symfony/routing": "2.1.*", + "symfony/yaml": "2.1.*", + "twig/twig": "1.8.*" + }, + "minimum-stability": "beta" +} diff --git a/core/composer.lock b/core/composer.lock new file mode 100644 index 0000000000000000000000000000000000000000..c861d34a9042fabaaf94bfa48421db76dd80b9a8 --- /dev/null +++ b/core/composer.lock @@ -0,0 +1,45 @@ +{ + "hash": "ec77094fc475b57afb7a27f63983ead1", + "packages": [ + { + "package": "symfony/class-loader", + "version": "v2.1.0-BETA1" + }, + { + "package": "symfony/dependency-injection", + "version": "v2.1.0-BETA1" + }, + { + "package": "symfony/event-dispatcher", + "version": "v2.1.0-BETA1" + }, + { + "package": "symfony/http-foundation", + "version": "v2.1.0-BETA1" + }, + { + "package": "symfony/http-kernel", + "version": "v2.1.0-BETA1" + }, + { + "package": "symfony/routing", + "version": "v2.1.0-BETA1" + }, + { + "package": "symfony/yaml", + "version": "v2.1.0-BETA1" + }, + { + "package": "twig/twig", + "version": "v1.8.3" + } + ], + "packages-dev": null, + "aliases": [ + + ], + "minimum-stability": "beta", + "stability-flags": [ + + ] +} diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index fa1335b8f6d0bfe0ae0403f156b7ffd2136c9800..f3aeab47fa7b4715827381a423ad35909618bf72 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2994,13 +2994,13 @@ function drupal_classloader() { if (!isset($loader)) { // Include the Symfony ClassLoader for loading PSR-0-compatible classes. - require_once DRUPAL_ROOT . '/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php'; + require_once DRUPAL_ROOT . '/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php'; // @todo Use a cleaner way than variable_get() to switch autoloaders. switch (variable_get('autoloader_mode', 'default')) { case 'apc': if (function_exists('apc_store')) { - require_once DRUPAL_ROOT . '/core/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; + require_once DRUPAL_ROOT . '/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; $loader = new ApcUniversalClassLoader('drupal.' . $GLOBALS['drupal_hash_salt']); break; } @@ -3015,13 +3015,19 @@ function drupal_classloader() { // Register explicit PSR-0 vendor namespaces. $loader->registerNamespaces(array( - // All Symfony-borrowed code lives in /core/vendor/Symfony. - 'Symfony' => DRUPAL_ROOT . '/core/vendor', + // All Symfony-borrowed code lives in /core/vendor/symfony. + 'Symfony\Component\ClassLoader' => DRUPAL_ROOT . '/core/vendor/symfony/class-loader', + 'Symfony\Component\DependencyInjection' => DRUPAL_ROOT . '/core/vendor/symfony/dependency-injection', + 'Symfony\Component\EventDispatcher' => DRUPAL_ROOT . '/core/vendor/symfony/event-dispatcher', + 'Symfony\Component\HttpFoundation' => DRUPAL_ROOT . '/core/vendor/symfony/http-foundation', + 'Symfony\Component\HttpKernel' => DRUPAL_ROOT . '/core/vendor/symfony/http-kernel', + 'Symfony\Component\Routing' => DRUPAL_ROOT . '/core/vendor/symfony/routing', + 'Symfony\Component\Yaml' => DRUPAL_ROOT . '/core/vendor/symfony/yaml', )); // Register PEAR-style vendor namespaces. $loader->registerPrefixes(array( - // All Twig-borrowed code lives in /core/vendor/Twig. - 'Twig' => DRUPAL_ROOT . '/core/vendor', + // All Twig-borrowed code lives in /core/vendor/twig. + 'Twig' => DRUPAL_ROOT . '/core/vendor/twig/twig/lib', )); // Register the Drupal namespace for classes in core as a fallback. // This allows to register additional namespaces within the Drupal namespace diff --git a/core/vendor/.gitignore b/core/vendor/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..eacfa776e87e70aa02cecb42812b1943923833e9 --- /dev/null +++ b/core/vendor/.gitignore @@ -0,0 +1,3 @@ +# SimpleTest breaks with the following files, so avoid adding them. +symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/php5.4/traits.php diff --git a/core/vendor/Symfony/Component/ClassLoader/ApcClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/ApcClassLoader.php deleted file mode 100644 index 3508db6d8affa0250b0357a2ae65c2620b5ca79a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/ApcClassLoader.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3. - * - * It expects an object implementing a findFile method to find the file. This - * allow using it as a wrapper around the other loaders of the component (the - * ClassLoader and the UniversalClassLoader for instance) but also around any - * other autoloader following this convention (the Composer one for instance) - * - * $loader = new ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * $cachedLoader = new ApcClassLoader('my_prefix', $loader); - * - * // activate the cached autoloader - * $cachedLoader->register(); - * - * // eventually deactivate the non-cached loader if it was registered previously - * // to be sure to use the cached one. - * $loader->unregister(); - * - * @author Fabien Potencier - * @author Kris Wallsmith - * - * @api - */ -class ApcClassLoader -{ - private $prefix; - private $classFinder; - - /** - * Constructor. - * - * @param string $prefix A prefix to create a namespace in APC - * @param object $classFinder - * - * @api - */ - public function __construct($prefix, $classFinder) - { - if (!extension_loaded('apc')) { - throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.'); - } - - if (!method_exists($classFinder, 'findFile')) { - throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); - } - - $this->prefix = $prefix; - $this->classFinder = $classFinder; - } - - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return Boolean|null True, if loaded - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - - return true; - } - } - - /** - * Finds a file by class name while caching lookups to APC. - * - * @param string $class A class name to resolve to file - * - * @return string|null - */ - public function findFile($class) - { - if (false === $file = apc_fetch($this->prefix.$class)) { - apc_store($this->prefix.$class, $file = $this->classFinder->findFile($class)); - } - - return $file; - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php deleted file mode 100644 index 1295d0ae44937659148ec4c427200b4cf28db4a2..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ApcUniversalClassLoader implements a "universal" autoloader cached in APC for PHP 5.3. - * - * It is able to load classes that use either: - * - * * The technical interoperability standards for PHP 5.3 namespaces and - * class names (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md); - * - * * The PEAR naming convention for classes (http://pear.php.net/). - * - * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be - * looked for in a list of locations to ease the vendoring of a sub-set of - * classes for large projects. - * - * Example usage: - * - * require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - * require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; - * - * use Symfony\Component\ClassLoader\ApcUniversalClassLoader; - * - * $loader = new ApcUniversalClassLoader('apc.prefix.'); - * - * // register classes with namespaces - * $loader->registerNamespaces(array( - * 'Symfony\Component' => __DIR__.'/component', - * 'Symfony' => __DIR__.'/framework', - * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'), - * )); - * - * // register a library using the PEAR naming convention - * $loader->registerPrefixes(array( - * 'Swift_' => __DIR__.'/Swift', - * )); - * - * // activate the autoloader - * $loader->register(); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * @author Fabien Potencier - * @author Kris Wallsmith - * - * @api - */ -class ApcUniversalClassLoader extends UniversalClassLoader -{ - private $prefix; - - /** - * Constructor. - * - * @param string $prefix A prefix to create a namespace in APC - * - * @api - */ - public function __construct($prefix) - { - if (!extension_loaded('apc')) { - throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.'); - } - - $this->prefix = $prefix; - } - - /** - * Finds a file by class name while caching lookups to APC. - * - * @param string $class A class name to resolve to file - */ - public function findFile($class) - { - if (false === $file = apc_fetch($this->prefix.$class)) { - apc_store($this->prefix.$class, $file = parent::findFile($class)); - } - - return $file; - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/core/vendor/Symfony/Component/ClassLoader/ClassCollectionLoader.php deleted file mode 100644 index 894900b0c1592a04c1121ec3f301b06463635452..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ClassCollectionLoader. - * - * @author Fabien Potencier - */ -class ClassCollectionLoader -{ - static private $loaded; - - /** - * Loads a list of classes and caches them in one big file. - * - * @param array $classes An array of classes to load - * @param string $cacheDir A cache directory - * @param string $name The cache name prefix - * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not - * @param Boolean $adaptive Whether to remove already declared classes or not - * @param string $extension File extension of the resulting file - * - * @throws \InvalidArgumentException When class can't be loaded - */ - static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php') - { - // each $name can only be loaded once per PHP process - if (isset(self::$loaded[$name])) { - return; - } - - self::$loaded[$name] = true; - - if ($adaptive) { - // don't include already declared classes - $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); - - // the cache is different depending on which classes are already declared - $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5); - } - - $cache = $cacheDir.'/'.$name.$extension; - - // auto-reload - $reload = false; - if ($autoReload) { - $metadata = $cacheDir.'/'.$name.$extension.'.meta'; - if (!is_file($metadata) || !is_file($cache)) { - $reload = true; - } else { - $time = filemtime($cache); - $meta = unserialize(file_get_contents($metadata)); - - if ($meta[1] != $classes) { - $reload = true; - } else { - foreach ($meta[0] as $resource) { - if (!is_file($resource) || filemtime($resource) > $time) { - $reload = true; - - break; - } - } - } - } - } - - if (!$reload && is_file($cache)) { - require_once $cache; - - return; - } - - $files = array(); - $content = ''; - foreach ($classes as $class) { - if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) { - throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class)); - } - - $r = new \ReflectionClass($class); - $files[] = $r->getFileName(); - - $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName())); - - // add namespace declaration for global code - if (!$r->inNamespace()) { - $c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n"; - } else { - $c = self::fixNamespaceDeclarations(' - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ClassLoader implements an PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md - * - * $loader = new ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * @author Fabien Potencier - * @author Jordi Boggiano - */ -class ClassLoader -{ - private $prefixes = array(); - private $fallbackDirs = array(); - private $useIncludePath = false; - - public function getPrefixes() - { - return $this->prefixes; - } - - public function getFallbackDirs() - { - return $this->fallbackDirs; - } - - public function addPrefixes(array $prefixes) - { - foreach ($prefixes as $prefix => $path) { - $this->addPrefix($prefix, $path); - } - } - - /** - * Registers a set of classes - * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes - */ - public function addPrefix($prefix, $paths) - { - if (!$prefix) { - foreach ((array) $paths as $path) { - $this->fallbackDirs[] = $path; - } - - return; - } - if (isset($this->prefixes[$prefix])) { - $this->prefixes[$prefix] = array_merge( - $this->prefixes[$prefix], - (array) $paths - ); - } else { - $this->prefixes[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include for class files. - * - * @param Boolean $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return Boolean - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return Boolean|null True, if loaded - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|null The path, if found - */ - public function findFile($class) - { - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR; - $className = substr($class, $pos + 1); - } else { - // PEAR-like class name - $classPath = null; - $className = $class; - } - - $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - - foreach ($this->prefixes as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; - } - } - } - } - - foreach ($this->fallbackDirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; - } - } - - if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) { - return $file; - } - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/ClassMapGenerator.php b/core/vendor/Symfony/Component/ClassLoader/ClassMapGenerator.php deleted file mode 100644 index c0e9fc6d50f6a477a9dcc16eee66ca03b719ed28..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ /dev/null @@ -1,133 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ClassMapGenerator - * - * @author Gyula Sallai - */ -class ClassMapGenerator -{ - /** - * Generate a class map file - * - * @param array|string $dirs Directories or a single path to search in - * @param string $file The name of the class map file - */ - static public function dump($dirs, $file) - { - $dirs = (array) $dirs; - $maps = array(); - - foreach ($dirs as $dir) { - $maps = array_merge($maps, static::createMap($dir)); - } - - file_put_contents($file, sprintf('isFile()) { - continue; - } - - $path = $file->getRealPath(); - - if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') { - continue; - } - - $classes = self::findClasses($path); - - foreach ($classes as $class) { - $map[$class] = $path; - } - - } - - return $map; - } - - /** - * Extract the classes in the given file - * - * @param string $path The file to check - * - * @return array The found classes - */ - static private function findClasses($path) - { - $contents = file_get_contents($path); - $tokens = token_get_all($contents); - $T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT; - - $classes = array(); - - $namespace = ''; - for ($i = 0, $max = count($tokens); $i < $max; $i++) { - $token = $tokens[$i]; - - if (is_string($token)) { - continue; - } - - $class = ''; - - switch ($token[0]) { - case T_NAMESPACE: - $namespace = ''; - // If there is a namespace, extract it - while (($t = $tokens[++$i]) && is_array($t)) { - if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) { - $namespace .= $t[1]; - } - } - $namespace .= '\\'; - break; - case T_CLASS: - case T_INTERFACE: - case $T_TRAIT: - // Find the classname - while (($t = $tokens[++$i]) && is_array($t)) { - if (T_STRING === $t[0]) { - $class .= $t[1]; - } elseif ($class !== '' && T_WHITESPACE == $t[0]) { - break; - } - } - - $classes[] = ltrim($namespace . $class, '\\'); - break; - default: - break; - } - } - - return $classes; - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/DebugClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/DebugClassLoader.php deleted file mode 100644 index b6f7968bcace010860e239cce7198c5835bcd3c0..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/DebugClassLoader.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * Autoloader checking if the class is really defined in the file found. - * - * The DebugClassLoader will wrap all registered autoloaders providing a - * findFile method and will throw an exception if a file is found but does - * not declare the class. - * - * @author Fabien Potencier - * @author Christophe Coevoet - * - * @api - */ -class DebugClassLoader -{ - private $classFinder; - - /** - * Constructor. - * - * @param object $classFinder - * - * @api - */ - public function __construct($classFinder) - { - $this->classFinder = $classFinder; - } - - /** - * Replaces all autoloaders implementing a findFile method by a DebugClassLoader wrapper. - */ - static public function enable() - { - if (!is_array($functions = spl_autoload_functions())) { - return; - } - - foreach ($functions as $function) { - spl_autoload_unregister($function); - } - - foreach ($functions as $function) { - if (is_array($function) && method_exists($function[0], 'findFile')) { - $function = array(new static($function[0]), 'loadClass'); - } - - spl_autoload_register($function); - } - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return Boolean|null True, if loaded - */ - public function loadClass($class) - { - if ($file = $this->classFinder->findFile($class)) { - require $file; - - if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { - throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); - } - - return true; - } - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/README.md b/core/vendor/Symfony/Component/ClassLoader/README.md deleted file mode 100644 index 5a83c5f3c1fd9f1099587628f9ba468a109c81e5..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/README.md +++ /dev/null @@ -1,73 +0,0 @@ -ClassLoader Component -===================== - -ClassLoader loads your project classes automatically if they follow some -standard PHP conventions. - -The Universal ClassLoader is able to autoload classes that implement the PSR-0 -standard or the PEAR naming convention. - -First, register the autoloader: - - require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - - use Symfony\Component\ClassLoader\UniversalClassLoader; - - $loader = new UniversalClassLoader(); - $loader->register(); - -Then, register some namespaces with the `registerNamespace()` method: - - $loader->registerNamespace('Symfony', __DIR__.'/src'); - $loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src'); - -The `registerNamespace()` method takes a namespace prefix and a path where to -look for the classes as arguments. - -You can also register a sub-namespaces: - - $loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib'); - -The order of registration is significant and the first registered namespace -takes precedence over later registered one. - -You can also register more than one path for a given namespace: - - $loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src')); - -Alternatively, you can use the `registerNamespaces()` method to register more -than one namespace at once: - - $loader->registerNamespaces(array( - 'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'), - 'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib', - 'Doctrine' => __DIR__.'/vendor/doctrine/lib', - 'Monolog' => __DIR__.'/vendor/monolog/src', - )); - -For better performance, you can use the APC based version of the universal -class loader: - - require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; - - use Symfony\Component\ClassLoader\ApcUniversalClassLoader; - - $loader = new ApcUniversalClassLoader('apc.prefix.'); - -Furthermore, the component provides tools to aggregate classes into a single -file, which is especially useful to improve performance on servers that do not -provide byte caches. - -Resources ---------- - -You can run the unit tests with the following command: - - phpunit -c src/Symfony/Component/ClassLoader/ - -If you also want to run the unit tests that depend on other Symfony -Components, declare the following environment variables before running -PHPUnit: - - export SYMFONY_FINDER=../path/to/Finder diff --git a/core/vendor/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/core/vendor/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php deleted file mode 100644 index cd1c439c411ed15caeda4dedaeacf7c9bbea6eed..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader\Tests; - -use Symfony\Component\ClassLoader\ClassCollectionLoader; - -class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase -{ - public function testFixNamespaceDeclarations() - { - $source = <<assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source)); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testUnableToLoadClassException() - { - ClassCollectionLoader::load(array('SomeNotExistingClass'), '', 'foo', false); - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/Tests/bootstrap.php b/core/vendor/Symfony/Component/ClassLoader/Tests/bootstrap.php deleted file mode 100644 index 3364e147a14674005254da120fd49badffa065a3..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/Tests/bootstrap.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -spl_autoload_register(function ($class) { - foreach (array( - 'SYMFONY_FINDER' => 'Finder', - ) as $env => $name) { - if (isset($_SERVER[$env]) && 0 === strpos(ltrim($class, '/'), 'Symfony\Component\\'.$name)) { - if (file_exists($file = $_SERVER[$env].'/'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\\'.$name)).'.php')) { - require_once $file; - } - } - } - - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\ClassLoader')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\ClassLoader')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php deleted file mode 100644 index 60f245ad1bde10593f194c004d690983cd235918..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php +++ /dev/null @@ -1,319 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * UniversalClassLoader implements a "universal" autoloader for PHP 5.3. - * - * It is able to load classes that use either: - * - * * The technical interoperability standards for PHP 5.3 namespaces and - * class names (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md); - * - * * The PEAR naming convention for classes (http://pear.php.net/). - * - * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be - * looked for in a list of locations to ease the vendoring of a sub-set of - * classes for large projects. - * - * Example usage: - * - * $loader = new UniversalClassLoader(); - * - * // register classes with namespaces - * $loader->registerNamespaces(array( - * 'Symfony\Component' => __DIR__.'/component', - * 'Symfony' => __DIR__.'/framework', - * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'), - * )); - * - * // register a library using the PEAR naming convention - * $loader->registerPrefixes(array( - * 'Swift_' => __DIR__.'/Swift', - * )); - * - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->useIncludePath(true); - * - * // activate the autoloader - * $loader->register(); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * @author Fabien Potencier - * - * @api - */ -class UniversalClassLoader -{ - private $namespaces = array(); - private $prefixes = array(); - private $namespaceFallbacks = array(); - private $prefixFallbacks = array(); - private $useIncludePath = false; - - /** - * Turns on searching the include for class files. Allows easy loading - * of installed PEAR packages - * - * @param Boolean $useIncludePath - */ - public function useIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return Boolean - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Gets the configured namespaces. - * - * @return array A hash with namespaces as keys and directories as values - */ - public function getNamespaces() - { - return $this->namespaces; - } - - /** - * Gets the configured class prefixes. - * - * @return array A hash with class prefixes as keys and directories as values - */ - public function getPrefixes() - { - return $this->prefixes; - } - - /** - * Gets the directory(ies) to use as a fallback for namespaces. - * - * @return array An array of directories - */ - public function getNamespaceFallbacks() - { - return $this->namespaceFallbacks; - } - - /** - * Gets the directory(ies) to use as a fallback for class prefixes. - * - * @return array An array of directories - */ - public function getPrefixFallbacks() - { - return $this->prefixFallbacks; - } - - /** - * Registers the directory to use as a fallback for namespaces. - * - * @param array $dirs An array of directories - * - * @api - */ - public function registerNamespaceFallbacks(array $dirs) - { - $this->namespaceFallbacks = $dirs; - } - - /** - * Registers a directory to use as a fallback for namespaces. - * - * @param string $dir A directory - */ - public function registerNamespaceFallback($dir) - { - $this->namespaceFallbacks[] = $dir; - } - - /** - * Registers directories to use as a fallback for class prefixes. - * - * @param array $dirs An array of directories - * - * @api - */ - public function registerPrefixFallbacks(array $dirs) - { - $this->prefixFallbacks = $dirs; - } - - /** - * Registers a directory to use as a fallback for class prefixes. - * - * @param string $dir A directory - */ - public function registerPrefixFallback($dir) - { - $this->prefixFallbacks[] = $dir; - } - - /** - * Registers an array of namespaces - * - * @param array $namespaces An array of namespaces (namespaces as keys and locations as values) - * - * @api - */ - public function registerNamespaces(array $namespaces) - { - foreach ($namespaces as $namespace => $locations) { - $this->namespaces[$namespace] = (array) $locations; - } - } - - /** - * Registers a namespace. - * - * @param string $namespace The namespace - * @param array|string $paths The location(s) of the namespace - * - * @api - */ - public function registerNamespace($namespace, $paths) - { - $this->namespaces[$namespace] = (array) $paths; - } - - /** - * Registers an array of classes using the PEAR naming convention. - * - * @param array $classes An array of classes (prefixes as keys and locations as values) - * - * @api - */ - public function registerPrefixes(array $classes) - { - foreach ($classes as $prefix => $locations) { - $this->prefixes[$prefix] = (array) $locations; - } - } - - /** - * Registers a set of classes using the PEAR naming convention. - * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes - * - * @api - */ - public function registerPrefix($prefix, $paths) - { - $this->prefixes[$prefix] = (array) $paths; - } - - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - * - * @api - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|null The path, if found - */ - public function findFile($class) - { - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $namespace = substr($class, 0, $pos); - $className = substr($class, $pos + 1); - $normalizedClass = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; - foreach ($this->namespaces as $ns => $dirs) { - if (0 !== strpos($namespace, $ns)) { - continue; - } - - foreach ($dirs as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - } - - foreach ($this->namespaceFallbacks as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - - } else { - // PEAR-like class name - $normalizedClass = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; - foreach ($this->prefixes as $prefix => $dirs) { - if (0 !== strpos($class, $prefix)) { - continue; - } - - foreach ($dirs as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - } - - foreach ($this->prefixFallbacks as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - } - - if ($this->useIncludePath && $file = stream_resolve_include_path($normalizedClass)) { - return $file; - } - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/XcacheClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/XcacheClassLoader.php deleted file mode 100644 index 2eaaba202fa88f34d8280e7a9b6509a3129a2e30..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/XcacheClassLoader.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * XcacheClassLoader implements a wrapping autoloader cached in Xcache for PHP 5.3. - * - * It expects an object implementing a findFile method to find the file. This - * allows using it as a wrapper around the other loaders of the component (the - * ClassLoader and the UniversalClassLoader for instance) but also around any - * other autoloader following this convention (the Composer one for instance) - * - * $loader = new ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * $cachedLoader = new XcacheClassLoader('my_prefix', $loader); - * - * // activate the cached autoloader - * $cachedLoader->register(); - * - * // eventually deactivate the non-cached loader if it was registered previously - * // to be sure to use the cached one. - * $loader->unregister(); - * - * @author Fabien Potencier - * @author Kris Wallsmith - * @author Kim Hemsø Rasmussen - * - * @api - */ -class XcacheClassLoader -{ - private $prefix; - private $classFinder; - - /** - * Constructor. - * - * @param string $prefix A prefix to create a namespace in Xcache - * @param object $classFinder - * - * @api - */ - public function __construct($prefix, $classFinder) - { - if (!extension_loaded('Xcache')) { - throw new \RuntimeException('Unable to use XcacheClassLoader as Xcache is not enabled.'); - } - - if (!method_exists($classFinder, 'findFile')) { - throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); - } - - $this->prefix = $prefix; - $this->classFinder = $classFinder; - } - - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return Boolean|null True, if loaded - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - return true; - } - } - - /** - * Finds a file by class name while caching lookups to Xcache. - * - * @param string $class A class name to resolve to file - * - * @return string|null - */ - public function findFile($class) - { - if (xcache_isset($this->prefix.$class)) { - $file = xcache_get($this->prefix.$class); - } else { - xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class)); - } - - return $file; - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/composer.json b/core/vendor/Symfony/Component/ClassLoader/composer.json deleted file mode 100644 index 2608f041a2e9516b1dfec5917daa2b5b98f575ac..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "symfony/class-loader", - "type": "library", - "description": "Symfony ClassLoader Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\ClassLoader": "" } - }, - "target-dir": "Symfony/Component/ClassLoader", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/phpunit.xml.dist b/core/vendor/Symfony/Component/ClassLoader/phpunit.xml.dist deleted file mode 100644 index bc7a21e8d462095540ebac6b8cf65bd7cdcb0abd..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/ClassLoader/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - - - - diff --git a/core/vendor/Symfony/Component/DependencyInjection/Alias.php b/core/vendor/Symfony/Component/DependencyInjection/Alias.php deleted file mode 100644 index 9a377eda6ad0c33ab9ec6d38f3d3ca08dbffe0a9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Alias.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * @api - */ -class Alias -{ - private $id; - private $public; - - /** - * Constructor. - * - * @param string $id Alias identifier - * @param Boolean $public If this alias is public - * - * @api - */ - public function __construct($id, $public = true) - { - $this->id = strtolower($id); - $this->public = $public; - } - - /** - * Checks if this DI Alias should be public or not. - * - * @return Boolean - * - * @api - */ - public function isPublic() - { - return $this->public; - } - - /** - * Sets if this Alias is public. - * - * @param Boolean $boolean If this Alias should be public - * - * @api - */ - public function setPublic($boolean) - { - $this->public = (Boolean) $boolean; - } - - /** - * Returns the Id of this alias. - * - * @return string The alias id - * - * @api - */ - public function __toString() - { - return $this->id; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/core/vendor/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php deleted file mode 100644 index b565f3f83e342ab4ef8aa07367988279463dfbda..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Run this pass before passes that need to know more about the relation of - * your services. - * - * This class will populate the ServiceReferenceGraph with information. You can - * retrieve the graph in other passes from the compiler. - * - * @author Johannes M. Schmitt - */ -class AnalyzeServiceReferencesPass implements RepeatablePassInterface -{ - private $graph; - private $container; - private $currentId; - private $currentDefinition; - private $repeatedPass; - private $onlyConstructorArguments; - - /** - * Constructor. - * - * @param Boolean $onlyConstructorArguments Sets this Service Reference pass to ignore method calls - */ - public function __construct($onlyConstructorArguments = false) - { - $this->onlyConstructorArguments = (Boolean) $onlyConstructorArguments; - } - - /** - * {@inheritDoc} - */ - public function setRepeatedPass(RepeatedPass $repeatedPass) - { - $this->repeatedPass = $repeatedPass; - } - - /** - * Processes a ContainerBuilder object to populate the service reference graph. - * - * @param ContainerBuilder $container - */ - public function process(ContainerBuilder $container) - { - $this->container = $container; - $this->graph = $container->getCompiler()->getServiceReferenceGraph(); - $this->graph->clear(); - - foreach ($container->getDefinitions() as $id => $definition) { - if ($definition->isSynthetic() || $definition->isAbstract()) { - continue; - } - - $this->currentId = $id; - $this->currentDefinition = $definition; - $this->processArguments($definition->getArguments()); - - if (!$this->onlyConstructorArguments) { - $this->processArguments($definition->getMethodCalls()); - $this->processArguments($definition->getProperties()); - } - } - - foreach ($container->getAliases() as $id => $alias) { - $this->graph->connect($id, $alias, (string) $alias, $this->getDefinition((string) $alias), null); - } - } - - /** - * Processes service definitions for arguments to find relationships for the service graph. - * - * @param array $arguments An array of Reference or Definition objects relating to service definitions - */ - private function processArguments(array $arguments) - { - foreach ($arguments as $argument) { - if (is_array($argument)) { - $this->processArguments($argument); - } elseif ($argument instanceof Reference) { - $this->graph->connect( - $this->currentId, - $this->currentDefinition, - $this->getDefinitionId((string) $argument), - $this->getDefinition((string) $argument), - $argument - ); - } elseif ($argument instanceof Definition) { - $this->processArguments($argument->getArguments()); - $this->processArguments($argument->getMethodCalls()); - $this->processArguments($argument->getProperties()); - } - } - } - - /** - * Returns a service definition given the full name or an alias. - * - * @param string $id A full id or alias for a service definition. - * - * @return Definition The definition related to the supplied id - */ - private function getDefinition($id) - { - $id = $this->getDefinitionId($id); - - return null === $id ? null : $this->container->getDefinition($id); - } - - private function getDefinitionId($id) - { - while ($this->container->hasAlias($id)) { - $id = (string) $this->container->getAlias($id); - } - - if (!$this->container->hasDefinition($id)) { - return null; - } - - return $id; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/core/vendor/Symfony/Component/DependencyInjection/Compiler/PassConfig.php deleted file mode 100644 index eb2266bf5840b5845e568d03cc93674e4038af05..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ /dev/null @@ -1,259 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; - -/** - * Compiler Pass Configuration - * - * This class has a default configuration embedded. - * - * @author Johannes M. Schmitt - * - * @api - */ -class PassConfig -{ - const TYPE_AFTER_REMOVING = 'afterRemoving'; - const TYPE_BEFORE_OPTIMIZATION = 'beforeOptimization'; - const TYPE_BEFORE_REMOVING = 'beforeRemoving'; - const TYPE_OPTIMIZE = 'optimization'; - const TYPE_REMOVE = 'removing'; - - private $mergePass; - private $afterRemovingPasses; - private $beforeOptimizationPasses; - private $beforeRemovingPasses; - private $optimizationPasses; - private $removingPasses; - - /** - * Constructor. - */ - public function __construct() - { - $this->mergePass = new MergeExtensionConfigurationPass(); - - $this->afterRemovingPasses = array(); - $this->beforeOptimizationPasses = array(); - $this->beforeRemovingPasses = array(); - - $this->optimizationPasses = array( - new ResolveDefinitionTemplatesPass(), - new ResolveParameterPlaceHoldersPass(), - new CheckDefinitionValidityPass(), - new ResolveReferencesToAliasesPass(), - new ResolveInvalidReferencesPass(), - new AnalyzeServiceReferencesPass(true), - new CheckCircularReferencesPass(), - new CheckReferenceValidityPass(), - ); - - $this->removingPasses = array( - new RemovePrivateAliasesPass(), - new RemoveAbstractDefinitionsPass(), - new ReplaceAliasByActualDefinitionPass(), - new RepeatedPass(array( - new AnalyzeServiceReferencesPass(), - new InlineServiceDefinitionsPass(), - new AnalyzeServiceReferencesPass(), - new RemoveUnusedDefinitionsPass(), - )), - new CheckExceptionOnInvalidReferenceBehaviorPass(), - ); - } - - /** - * Returns all passes in order to be processed. - * - * @return array An array of all passes to process - * - * @api - */ - public function getPasses() - { - return array_merge( - array($this->mergePass), - $this->beforeOptimizationPasses, - $this->optimizationPasses, - $this->beforeRemovingPasses, - $this->removingPasses, - $this->afterRemovingPasses - ); - } - - /** - * Adds a pass. - * - * @param CompilerPassInterface $pass A Compiler pass - * @param string $type The pass type - * - * @throws InvalidArgumentException when a pass type doesn't exist - * - * @api - */ - public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION) - { - $property = $type.'Passes'; - if (!isset($this->$property)) { - throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type)); - } - - $passes = &$this->$property; - $passes[] = $pass; - } - - /** - * Gets all passes for the AfterRemoving pass. - * - * @return array An array of passes - * - * @api - */ - public function getAfterRemovingPasses() - { - return $this->afterRemovingPasses; - } - - /** - * Gets all passes for the BeforeOptimization pass. - * - * @return array An array of passes - * - * @api - */ - public function getBeforeOptimizationPasses() - { - return $this->beforeOptimizationPasses; - } - - /** - * Gets all passes for the BeforeRemoving pass. - * - * @return array An array of passes - * - * @api - */ - public function getBeforeRemovingPasses() - { - return $this->beforeRemovingPasses; - } - - /** - * Gets all passes for the Optimization pass. - * - * @return array An array of passes - * - * @api - */ - public function getOptimizationPasses() - { - return $this->optimizationPasses; - } - - /** - * Gets all passes for the Removing pass. - * - * @return array An array of passes - * - * @api - */ - public function getRemovingPasses() - { - return $this->removingPasses; - } - - /** - * Gets all passes for the Merge pass. - * - * @return array An array of passes - * - * @api - */ - public function getMergePass() - { - return $this->mergePass; - } - - /** - * Sets the Merge Pass. - * - * @param CompilerPassInterface $pass The merge pass - * - * @api - */ - public function setMergePass(CompilerPassInterface $pass) - { - $this->mergePass = $pass; - } - - /** - * Sets the AfterRemoving passes. - * - * @param array $passes An array of passes - * - * @api - */ - public function setAfterRemovingPasses(array $passes) - { - $this->afterRemovingPasses = $passes; - } - - /** - * Sets the BeforeOptimization passes. - * - * @param array $passes An array of passes - * - * @api - */ - public function setBeforeOptimizationPasses(array $passes) - { - $this->beforeOptimizationPasses = $passes; - } - - /** - * Sets the BeforeRemoving passes. - * - * @param array $passes An array of passes - * - * @api - */ - public function setBeforeRemovingPasses(array $passes) - { - $this->beforeRemovingPasses = $passes; - } - - /** - * Sets the Optimization passes. - * - * @param array $passes An array of passes - * - * @api - */ - public function setOptimizationPasses(array $passes) - { - $this->optimizationPasses = $passes; - } - - /** - * Sets the Removing passes. - * - * @param array $passes An array of passes - * - * @api - */ - public function setRemovingPasses(array $passes) - { - $this->removingPasses = $passes; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php b/core/vendor/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php deleted file mode 100644 index dc83807eb13d42a74faf270992be1e2dd83e0fee..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -/** - * Replaces aliases with actual service definitions, effectively removing these - * aliases. - * - * @author Johannes M. Schmitt - */ -class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface -{ - private $compiler; - private $formatter; - private $sourceId; - - /** - * Process the Container to replace aliases with service definitions. - * - * @param ContainerBuilder $container - */ - public function process(ContainerBuilder $container) - { - $this->compiler = $container->getCompiler(); - $this->formatter = $this->compiler->getLoggingFormatter(); - - foreach ($container->getAliases() as $id => $alias) { - $aliasId = (string) $alias; - - $definition = $container->getDefinition($aliasId); - - if ($definition->isPublic()) { - continue; - } - - $definition->setPublic(true); - $container->setDefinition($id, $definition); - $container->removeDefinition($aliasId); - - $this->updateReferences($container, $aliasId, $id); - - // we have to restart the process due to concurrent modification of - // the container - $this->process($container); - - break; - } - } - - /** - * Updates references to remove aliases. - * - * @param ContainerBuilder $container The container - * @param string $currentId The alias identifier being replaced - * @param string $newId The id of the service the alias points to - */ - private function updateReferences($container, $currentId, $newId) - { - foreach ($container->getAliases() as $id => $alias) { - if ($currentId === (string) $alias) { - $container->setAlias($id, $newId); - } - } - - foreach ($container->getDefinitions() as $id => $definition) { - $this->sourceId = $id; - - $definition->setArguments( - $this->updateArgumentReferences($definition->getArguments(), $currentId, $newId) - ); - - $definition->setMethodCalls( - $this->updateArgumentReferences($definition->getMethodCalls(), $currentId, $newId) - ); - - $definition->setProperties( - $this->updateArgumentReferences($definition->getProperties(), $currentId, $newId) - ); - } - } - - /** - * Updates argument references. - * - * @param array $arguments An array of Arguments - * @param string $currentId The alias identifier - * @param string $newId The identifier the alias points to - */ - private function updateArgumentReferences(array $arguments, $currentId, $newId) - { - foreach ($arguments as $k => $argument) { - if (is_array($argument)) { - $arguments[$k] = $this->updateArgumentReferences($argument, $currentId, $newId); - } elseif ($argument instanceof Reference) { - if ($currentId === (string) $argument) { - $arguments[$k] = new Reference($newId, $argument->getInvalidBehavior()); - $this->compiler->addLogMessage($this->formatter->formatUpdateReference($this, $this->sourceId, $currentId, $newId)); - } - } - } - - return $arguments; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php b/core/vendor/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php deleted file mode 100644 index 6d3c78a81449be2854fc81d120fc15c470dbe94a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -/** - * Emulates the invalid behavior if the reference is not found within the - * container. - * - * @author Johannes M. Schmitt - */ -class ResolveInvalidReferencesPass implements CompilerPassInterface -{ - private $container; - - /** - * Process the ContainerBuilder to resolve invalid references. - * - * @param ContainerBuilder $container - */ - public function process(ContainerBuilder $container) - { - $this->container = $container; - foreach ($container->getDefinitions() as $definition) { - if ($definition->isSynthetic() || $definition->isAbstract()) { - continue; - } - - $definition->setArguments( - $this->processArguments($definition->getArguments()) - ); - - $calls = array(); - foreach ($definition->getMethodCalls() as $call) { - try { - $calls[] = array($call[0], $this->processArguments($call[1], true)); - } catch (RuntimeException $ignore) { - // this call is simply removed - } - } - $definition->setMethodCalls($calls); - - $properties = array(); - foreach ($definition->getProperties() as $name => $value) { - try { - $value = $this->processArguments(array($value), true); - $properties[$name] = reset($value); - } catch (RuntimeException $ignore) { - // ignore property - } - } - $definition->setProperties($properties); - } - } - - /** - * Processes arguments to determine invalid references. - * - * @param array $arguments An array of Reference objects - * @param Boolean $inMethodCall - */ - private function processArguments(array $arguments, $inMethodCall = false) - { - foreach ($arguments as $k => $argument) { - if (is_array($argument)) { - $arguments[$k] = $this->processArguments($argument, $inMethodCall); - } elseif ($argument instanceof Reference) { - $id = (string) $argument; - - $invalidBehavior = $argument->getInvalidBehavior(); - $exists = $this->container->has($id); - - // resolve invalid behavior - if ($exists && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - $arguments[$k] = new Reference($id); - } elseif (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { - $arguments[$k] = null; - } elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { - if ($inMethodCall) { - throw new RuntimeException('Method shouldn\'t be called.'); - } - - $arguments[$k] = null; - } - } - } - - return $arguments; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php b/core/vendor/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php deleted file mode 100644 index 60a9295f0c3535c0418b6abde2c162c89fe8943a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -/** - * Represents an edge in your service graph. - * - * Value is typically a reference. - * - * @author Johannes M. Schmitt - */ -class ServiceReferenceGraphEdge -{ - private $sourceNode; - private $destNode; - private $value; - - /** - * Constructor. - * - * @param ServiceReferenceGraphNode $sourceNode - * @param ServiceReferenceGraphNode $destNode - * @param string $value - */ - public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceReferenceGraphNode $destNode, $value = null) - { - $this->sourceNode = $sourceNode; - $this->destNode = $destNode; - $this->value = $value; - } - - /** - * Returns the value of the edge - * - * @return ServiceReferenceGraphNode - */ - public function getValue() - { - return $this->value; - } - - /** - * Returns the source node - * - * @return ServiceReferenceGraphNode - */ - public function getSourceNode() - { - return $this->sourceNode; - } - - /** - * Returns the destination node - * - * @return ServiceReferenceGraphNode - */ - public function getDestNode() - { - return $this->destNode; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php b/core/vendor/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php deleted file mode 100644 index da8dc704181eba598e310a5c74481ac3408cd7f1..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Alias; - -/** - * Represents a node in your service graph. - * - * Value is typically a definition, or an alias. - * - * @author Johannes M. Schmitt - */ -class ServiceReferenceGraphNode -{ - private $id; - private $inEdges; - private $outEdges; - private $value; - - /** - * Constructor. - * - * @param string $id The node identifier - * @param mixed $value The node value - */ - public function __construct($id, $value) - { - $this->id = $id; - $this->value = $value; - $this->inEdges = array(); - $this->outEdges = array(); - } - - /** - * Adds an in edge to this node. - * - * @param ServiceReferenceGraphEdge $edge - */ - public function addInEdge(ServiceReferenceGraphEdge $edge) - { - $this->inEdges[] = $edge; - } - - /** - * Adds an out edge to this node. - * - * @param ServiceReferenceGraphEdge $edge - */ - public function addOutEdge(ServiceReferenceGraphEdge $edge) - { - $this->outEdges[] = $edge; - } - - /** - * Checks if the value of this node is an Alias. - * - * @return Boolean True if the value is an Alias instance - */ - public function isAlias() - { - return $this->value instanceof Alias; - } - - /** - * Checks if the value of this node is a Definition. - * - * @return Boolean True if the value is a Definition instance - */ - public function isDefinition() - { - return $this->value instanceof Definition; - } - - /** - * Returns the identifier. - * - * @return string - */ - public function getId() - { - return $this->id; - } - - /** - * Returns the in edges. - * - * @return array The in ServiceReferenceGraphEdge array - */ - public function getInEdges() - { - return $this->inEdges; - } - - /** - * Returns the out edges. - * - * @return array The out ServiceReferenceGraphEdge array - */ - public function getOutEdges() - { - return $this->outEdges; - } - - /** - * Returns the value of this Node - * - * @return mixed The value - */ - public function getValue() - { - return $this->value; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Container.php b/core/vendor/Symfony/Component/DependencyInjection/Container.php deleted file mode 100644 index cf29685c605f5df40f0ff26e85b8db13f988718e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Container.php +++ /dev/null @@ -1,467 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; -use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; - -/** - * Container is a dependency injection container. - * - * It gives access to object instances (services). - * - * Services and parameters are simple key/pair stores. - * - * Parameter and service keys are case insensitive. - * - * A service id can contain lowercased letters, digits, underscores, and dots. - * Underscores are used to separate words, and dots to group services - * under namespaces: - * - *
    - *
  • request
  • - *
  • mysql_session_storage
  • - *
  • symfony.mysql_session_storage
  • - *
- * - * A service can also be defined by creating a method named - * getXXXService(), where XXX is the camelized version of the id: - * - *
    - *
  • request -> getRequestService()
  • - *
  • mysql_session_storage -> getMysqlSessionStorageService()
  • - *
  • symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()
  • - *
- * - * The container can have three possible behaviors when a service does not exist: - * - * * EXCEPTION_ON_INVALID_REFERENCE: Throws an exception (the default) - * * NULL_ON_INVALID_REFERENCE: Returns null - * * IGNORE_ON_INVALID_REFERENCE: Ignores the wrapping command asking for the reference - * (for instance, ignore a setter if the service does not exist) - * - * @author Fabien Potencier - * @author Johannes M. Schmitt - * - * @api - */ -class Container implements IntrospectableContainerInterface -{ - protected $parameterBag; - protected $services; - protected $scopes; - protected $scopeChildren; - protected $scopedServices; - protected $scopeStacks; - protected $loading = array(); - - /** - * Constructor. - * - * @param ParameterBagInterface $parameterBag A ParameterBagInterface instance - * - * @api - */ - public function __construct(ParameterBagInterface $parameterBag = null) - { - $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag; - - $this->services = array(); - $this->scopes = array(); - $this->scopeChildren = array(); - $this->scopedServices = array(); - $this->scopeStacks = array(); - - $this->set('service_container', $this); - } - - /** - * Compiles the container. - * - * This method does two things: - * - * * Parameter values are resolved; - * * The parameter bag is frozen. - * - * @api - */ - public function compile() - { - $this->parameterBag->resolve(); - - $this->parameterBag = new FrozenParameterBag($this->parameterBag->all()); - } - - /** - * Returns true if the container parameter bag are frozen. - * - * @return Boolean true if the container parameter bag are frozen, false otherwise - * - * @api - */ - public function isFrozen() - { - return $this->parameterBag instanceof FrozenParameterBag; - } - - /** - * Gets the service container parameter bag. - * - * @return ParameterBagInterface A ParameterBagInterface instance - * - * @api - */ - public function getParameterBag() - { - return $this->parameterBag; - } - - /** - * Gets a parameter. - * - * @param string $name The parameter name - * - * @return mixed The parameter value - * - * @throws InvalidArgumentException if the parameter is not defined - * - * @api - */ - public function getParameter($name) - { - return $this->parameterBag->get($name); - } - - /** - * Checks if a parameter exists. - * - * @param string $name The parameter name - * - * @return Boolean The presence of parameter in container - * - * @api - */ - public function hasParameter($name) - { - return $this->parameterBag->has($name); - } - - /** - * Sets a parameter. - * - * @param string $name The parameter name - * @param mixed $value The parameter value - * - * @api - */ - public function setParameter($name, $value) - { - $this->parameterBag->set($name, $value); - } - - /** - * Sets a service. - * - * @param string $id The service identifier - * @param object $service The service instance - * @param string $scope The scope of the service - * - * @api - */ - public function set($id, $service, $scope = self::SCOPE_CONTAINER) - { - if (self::SCOPE_PROTOTYPE === $scope) { - throw new InvalidArgumentException('You cannot set services of scope "prototype".'); - } - - $id = strtolower($id); - - if (self::SCOPE_CONTAINER !== $scope) { - if (!isset($this->scopedServices[$scope])) { - throw new RuntimeException('You cannot set services of inactive scopes.'); - } - - $this->scopedServices[$scope][$id] = $service; - } - - $this->services[$id] = $service; - } - - /** - * Returns true if the given service is defined. - * - * @param string $id The service identifier - * - * @return Boolean true if the service is defined, false otherwise - * - * @api - */ - public function has($id) - { - $id = strtolower($id); - - return isset($this->services[$id]) || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service'); - } - - /** - * Gets a service. - * - * If a service is both defined through a set() method and - * with a set*Service() method, the former has always precedence. - * - * @param string $id The service identifier - * @param integer $invalidBehavior The behavior when the service does not exist - * - * @return object The associated service - * - * @throws InvalidArgumentException if the service is not defined - * - * @see Reference - * - * @api - */ - public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) - { - $id = strtolower($id); - - if (isset($this->services[$id])) { - return $this->services[$id]; - } - - if (isset($this->loading[$id])) { - throw new ServiceCircularReferenceException($id, array_keys($this->loading)); - } - - if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { - $this->loading[$id] = true; - - try { - $service = $this->$method(); - } catch (\Exception $e) { - unset($this->loading[$id]); - throw $e; - } - - unset($this->loading[$id]); - - return $service; - } - - if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { - throw new ServiceNotFoundException($id); - } - } - - /** - * Returns true if the given service has actually been initialized - * - * @param string $id The service identifier - * - * @return Boolean true if service has already been initialized, false otherwise - */ - public function initialized($id) - { - return isset($this->services[strtolower($id)]); - } - - /** - * Gets all service ids. - * - * @return array An array of all defined service ids - */ - public function getServiceIds() - { - $ids = array(); - $r = new \ReflectionClass($this); - foreach ($r->getMethods() as $method) { - if (preg_match('/^get(.+)Service$/', $method->getName(), $match)) { - $ids[] = self::underscore($match[1]); - } - } - - return array_unique(array_merge($ids, array_keys($this->services))); - } - - /** - * This is called when you enter a scope - * - * @param string $name - * - * @api - */ - public function enterScope($name) - { - if (!isset($this->scopes[$name])) { - throw new InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name)); - } - - if (self::SCOPE_CONTAINER !== $this->scopes[$name] && !isset($this->scopedServices[$this->scopes[$name]])) { - throw new RuntimeException(sprintf('The parent scope "%s" must be active when entering this scope.', $this->scopes[$name])); - } - - // check if a scope of this name is already active, if so we need to - // remove all services of this scope, and those of any of its child - // scopes from the global services map - if (isset($this->scopedServices[$name])) { - $services = array($this->services, $name => $this->scopedServices[$name]); - unset($this->scopedServices[$name]); - - foreach ($this->scopeChildren[$name] as $child) { - $services[$child] = $this->scopedServices[$child]; - unset($this->scopedServices[$child]); - } - - // update global map - $this->services = call_user_func_array('array_diff_key', $services); - array_shift($services); - - // add stack entry for this scope so we can restore the removed services later - if (!isset($this->scopeStacks[$name])) { - $this->scopeStacks[$name] = new \SplStack(); - } - $this->scopeStacks[$name]->push($services); - } - - $this->scopedServices[$name] = array(); - } - - /** - * This is called to leave the current scope, and move back to the parent - * scope. - * - * @param string $name The name of the scope to leave - * - * @throws InvalidArgumentException if the scope is not active - * - * @api - */ - public function leaveScope($name) - { - if (!isset($this->scopedServices[$name])) { - throw new InvalidArgumentException(sprintf('The scope "%s" is not active.', $name)); - } - - // remove all services of this scope, or any of its child scopes from - // the global service map - $services = array($this->services, $this->scopedServices[$name]); - unset($this->scopedServices[$name]); - foreach ($this->scopeChildren[$name] as $child) { - if (!isset($this->scopedServices[$child])) { - continue; - } - - $services[] = $this->scopedServices[$child]; - unset($this->scopedServices[$child]); - } - $this->services = call_user_func_array('array_diff_key', $services); - - // check if we need to restore services of a previous scope of this type - if (isset($this->scopeStacks[$name]) && count($this->scopeStacks[$name]) > 0) { - $services = $this->scopeStacks[$name]->pop(); - $this->scopedServices += $services; - - array_unshift($services, $this->services); - $this->services = call_user_func_array('array_merge', $services); - } - } - - /** - * Adds a scope to the container. - * - * @param ScopeInterface $scope - * - * @api - */ - public function addScope(ScopeInterface $scope) - { - $name = $scope->getName(); - $parentScope = $scope->getParentName(); - - if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) { - throw new InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name)); - } - if (isset($this->scopes[$name])) { - throw new InvalidArgumentException(sprintf('A scope with name "%s" already exists.', $name)); - } - if (self::SCOPE_CONTAINER !== $parentScope && !isset($this->scopes[$parentScope])) { - throw new InvalidArgumentException(sprintf('The parent scope "%s" does not exist, or is invalid.', $parentScope)); - } - - $this->scopes[$name] = $parentScope; - $this->scopeChildren[$name] = array(); - - // normalize the child relations - while ($parentScope !== self::SCOPE_CONTAINER) { - $this->scopeChildren[$parentScope][] = $name; - $parentScope = $this->scopes[$parentScope]; - } - } - - /** - * Returns whether this container has a certain scope - * - * @param string $name The name of the scope - * - * @return Boolean - * - * @api - */ - public function hasScope($name) - { - return isset($this->scopes[$name]); - } - - /** - * Returns whether this scope is currently active - * - * This does not actually check if the passed scope actually exists. - * - * @param string $name - * - * @return Boolean - * - * @api - */ - public function isScopeActive($name) - { - return isset($this->scopedServices[$name]); - } - - /** - * Camelizes a string. - * - * @param string $id A string to camelize - * - * @return string The camelized string - */ - static public function camelize($id) - { - return preg_replace_callback('/(^|_|\.)+(.)/', function ($match) { return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); }, $id); - } - - /** - * A string to underscore. - * - * @param string $id The string to underscore - * - * @return string The underscored string - */ - static public function underscore($id) - { - return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.'))); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/ContainerAware.php b/core/vendor/Symfony/Component/DependencyInjection/ContainerAware.php deleted file mode 100644 index 1ae1db44af96f37b7b5032b790b440819da781b7..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/ContainerAware.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * A simple implementation of ContainerAwareInterface. - * - * @author Fabien Potencier - * - * @api - */ -class ContainerAware implements ContainerAwareInterface -{ - /** - * @var ContainerInterface - * - * @api - */ - protected $container; - - /** - * Sets the Container associated with this Controller. - * - * @param ContainerInterface $container A ContainerInterface instance - * - * @api - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/ContainerBuilder.php b/core/vendor/Symfony/Component/DependencyInjection/ContainerBuilder.php deleted file mode 100644 index 1d77ebc001ec03ec2ffa0c7dd451ad8140e6538d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ /dev/null @@ -1,867 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -use Symfony\Component\DependencyInjection\Compiler\Compiler; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\Exception\BadMethodCallException; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Exception\LogicException; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Resource\ResourceInterface; - -/** - * ContainerBuilder is a DI container that provides an API to easily describe services. - * - * @author Fabien Potencier - * - * @api - */ -class ContainerBuilder extends Container implements TaggedContainerInterface -{ - private $extensions = array(); - private $extensionsByNs = array(); - private $definitions = array(); - private $aliases = array(); - private $resources = array(); - private $extensionConfigs = array(); - private $compiler; - - /** - * Registers an extension. - * - * @param ExtensionInterface $extension An extension instance - * - * @api - */ - public function registerExtension(ExtensionInterface $extension) - { - $this->extensions[$extension->getAlias()] = $extension; - - if (false !== $extension->getNamespace()) { - $this->extensionsByNs[$extension->getNamespace()] = $extension; - } - } - - /** - * Returns an extension by alias or namespace. - * - * @param string $name An alias or a namespace - * - * @return ExtensionInterface An extension instance - * - * @api - */ - public function getExtension($name) - { - if (isset($this->extensions[$name])) { - return $this->extensions[$name]; - } - - if (isset($this->extensionsByNs[$name])) { - return $this->extensionsByNs[$name]; - } - - throw new LogicException(sprintf('Container extension "%s" is not registered', $name)); - } - - /** - * Returns all registered extensions. - * - * @return array An array of ExtensionInterface - * - * @api - */ - public function getExtensions() - { - return $this->extensions; - } - - /** - * Checks if we have an extension. - * - * @param string $name The name of the extension - * - * @return Boolean If the extension exists - * - * @api - */ - public function hasExtension($name) - { - return isset($this->extensions[$name]) || isset($this->extensionsByNs[$name]); - } - - /** - * Returns an array of resources loaded to build this configuration. - * - * @return ResourceInterface[] An array of resources - * - * @api - */ - public function getResources() - { - return array_unique($this->resources); - } - - /** - * Adds a resource for this configuration. - * - * @param ResourceInterface $resource A resource instance - * - * @return ContainerBuilder The current instance - * - * @api - */ - public function addResource(ResourceInterface $resource) - { - $this->resources[] = $resource; - - return $this; - } - - public function setResources(array $resources) - { - $this->resources = $resources; - - return $this; - } - - /** - * Adds the object class hierarchy as resources. - * - * @param object $object An object instance - * - * @api - */ - public function addObjectResource($object) - { - $parent = new \ReflectionObject($object); - do { - $this->addResource(new FileResource($parent->getFileName())); - } while ($parent = $parent->getParentClass()); - } - - /** - * Loads the configuration for an extension. - * - * @param string $extension The extension alias or namespace - * @param array $values An array of values that customizes the extension - * - * @return ContainerBuilder The current instance - * @throws BadMethodCallException When this ContainerBuilder is frozen - * - * @api - */ - public function loadFromExtension($extension, array $values = array()) - { - if ($this->isFrozen()) { - throw new BadMethodCallException('Cannot load from an extension on a frozen container.'); - } - - $namespace = $this->getExtension($extension)->getAlias(); - - $this->extensionConfigs[$namespace][] = $values; - - return $this; - } - - /** - * Adds a compiler pass. - * - * @param CompilerPassInterface $pass A compiler pass - * @param string $type The type of compiler pass - * - * @api - */ - public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) - { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - $this->compiler->addPass($pass, $type); - - $this->addObjectResource($pass); - } - - /** - * Returns the compiler pass config which can then be modified. - * - * @return PassConfig The compiler pass config - * - * @api - */ - public function getCompilerPassConfig() - { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - return $this->compiler->getPassConfig(); - } - - /** - * Returns the compiler. - * - * @return Compiler The compiler - * - * @api - */ - public function getCompiler() - { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - return $this->compiler; - } - - /** - * Returns all Scopes. - * - * @return array An array of scopes - * - * @api - */ - public function getScopes() - { - return $this->scopes; - } - - /** - * Returns all Scope children. - * - * @return array An array of scope children. - * - * @api - */ - public function getScopeChildren() - { - return $this->scopeChildren; - } - - /** - * Sets a service. - * - * @param string $id The service identifier - * @param object $service The service instance - * @param string $scope The scope - * - * @throws BadMethodCallException When this ContainerBuilder is frozen - * - * @api - */ - public function set($id, $service, $scope = self::SCOPE_CONTAINER) - { - if ($this->isFrozen()) { - throw new BadMethodCallException('Setting service on a frozen container is not allowed'); - } - - $id = strtolower($id); - - unset($this->definitions[$id], $this->aliases[$id]); - - parent::set($id, $service, $scope); - } - - /** - * Removes a service definition. - * - * @param string $id The service identifier - * - * @api - */ - public function removeDefinition($id) - { - unset($this->definitions[strtolower($id)]); - } - - /** - * Returns true if the given service is defined. - * - * @param string $id The service identifier - * - * @return Boolean true if the service is defined, false otherwise - * - * @api - */ - public function has($id) - { - $id = strtolower($id); - - return isset($this->definitions[$id]) || isset($this->aliases[$id]) || parent::has($id); - } - - /** - * Gets a service. - * - * @param string $id The service identifier - * @param integer $invalidBehavior The behavior when the service does not exist - * - * @return object The associated service - * - * @throws InvalidArgumentException if the service is not defined - * @throws LogicException if the service has a circular reference to itself - * - * @see Reference - * - * @api - */ - public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) - { - $id = strtolower($id); - - try { - return parent::get($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); - } catch (InvalidArgumentException $e) { - if (isset($this->loading[$id])) { - throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); - } - - if (!$this->hasDefinition($id) && isset($this->aliases[$id])) { - return $this->get($this->aliases[$id]); - } - - try { - $definition = $this->getDefinition($id); - } catch (InvalidArgumentException $e) { - if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; - } - - throw $e; - } - - $this->loading[$id] = true; - - $service = $this->createService($definition, $id); - - unset($this->loading[$id]); - - return $service; - } - } - - /** - * Merges a ContainerBuilder with the current ContainerBuilder configuration. - * - * Service definitions overrides the current defined ones. - * - * But for parameters, they are overridden by the current ones. It allows - * the parameters passed to the container constructor to have precedence - * over the loaded ones. - * - * $container = new ContainerBuilder(array('foo' => 'bar')); - * $loader = new LoaderXXX($container); - * $loader->load('resource_name'); - * $container->register('foo', new stdClass()); - * - * In the above example, even if the loaded resource defines a foo - * parameter, the value will still be 'bar' as defined in the ContainerBuilder - * constructor. - * - * @param ContainerBuilder $container The ContainerBuilder instance to merge. - * - * - * @throws BadMethodCallException When this ContainerBuilder is frozen - * - * @api - */ - public function merge(ContainerBuilder $container) - { - if ($this->isFrozen()) { - throw new BadMethodCallException('Cannot merge on a frozen container.'); - } - - $this->addDefinitions($container->getDefinitions()); - $this->addAliases($container->getAliases()); - $this->getParameterBag()->add($container->getParameterBag()->all()); - - foreach ($container->getResources() as $resource) { - $this->addResource($resource); - } - - foreach ($this->extensions as $name => $extension) { - if (!isset($this->extensionConfigs[$name])) { - $this->extensionConfigs[$name] = array(); - } - - $this->extensionConfigs[$name] = array_merge($this->extensionConfigs[$name], $container->getExtensionConfig($name)); - } - } - - /** - * Returns the configuration array for the given extension. - * - * @param string $name The name of the extension - * - * @return array An array of configuration - * - * @api - */ - public function getExtensionConfig($name) - { - if (!isset($this->extensionConfigs[$name])) { - $this->extensionConfigs[$name] = array(); - } - - return $this->extensionConfigs[$name]; - } - - /** - * Compiles the container. - * - * This method passes the container to compiler - * passes whose job is to manipulate and optimize - * the container. - * - * The main compiler passes roughly do four things: - * - * * The extension configurations are merged; - * * Parameter values are resolved; - * * The parameter bag is frozen; - * * Extension loading is disabled. - * - * @api - */ - public function compile() - { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - foreach ($this->compiler->getPassConfig()->getPasses() as $pass) { - $this->addObjectResource($pass); - } - - $this->compiler->compile($this); - - $this->extensionConfigs = array(); - - parent::compile(); - } - - /** - * Gets all service ids. - * - * @return array An array of all defined service ids - */ - public function getServiceIds() - { - return array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliases), parent::getServiceIds())); - } - - /** - * Adds the service aliases. - * - * @param array $aliases An array of aliases - * - * @api - */ - public function addAliases(array $aliases) - { - foreach ($aliases as $alias => $id) { - $this->setAlias($alias, $id); - } - } - - /** - * Sets the service aliases. - * - * @param array $aliases An array of service definitions - * - * @api - */ - public function setAliases(array $aliases) - { - $this->aliases = array(); - $this->addAliases($aliases); - } - - /** - * Sets an alias for an existing service. - * - * @param string $alias The alias to create - * @param mixed $id The service to alias - * - * @api - */ - public function setAlias($alias, $id) - { - $alias = strtolower($alias); - - if (is_string($id)) { - $id = new Alias($id); - } elseif (!$id instanceof Alias) { - throw new InvalidArgumentException('$id must be a string, or an Alias object.'); - } - - if ($alias === strtolower($id)) { - throw new InvalidArgumentException('An alias can not reference itself, got a circular reference on "'.$alias.'".'); - } - - unset($this->definitions[$alias]); - - $this->aliases[$alias] = $id; - } - - /** - * Removes an alias. - * - * @param string $alias The alias to remove - * - * @api - */ - public function removeAlias($alias) - { - unset($this->aliases[strtolower($alias)]); - } - - /** - * Returns true if an alias exists under the given identifier. - * - * @param string $id The service identifier - * - * @return Boolean true if the alias exists, false otherwise - * - * @api - */ - public function hasAlias($id) - { - return isset($this->aliases[strtolower($id)]); - } - - /** - * Gets all defined aliases. - * - * @return array An array of aliases - * - * @api - */ - public function getAliases() - { - return $this->aliases; - } - - /** - * Gets an alias. - * - * @param string $id The service identifier - * - * @return string The aliased service identifier - * - * @throws InvalidArgumentException if the alias does not exist - * - * @api - */ - public function getAlias($id) - { - $id = strtolower($id); - - if (!$this->hasAlias($id)) { - throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id)); - } - - return $this->aliases[$id]; - } - - /** - * Registers a service definition. - * - * This methods allows for simple registration of service definition - * with a fluid interface. - * - * @param string $id The service identifier - * @param string $class The service class - * - * @return Definition A Definition instance - * - * @api - */ - public function register($id, $class = null) - { - return $this->setDefinition(strtolower($id), new Definition($class)); - } - - /** - * Adds the service definitions. - * - * @param Definition[] $definitions An array of service definitions - * - * @api - */ - public function addDefinitions(array $definitions) - { - foreach ($definitions as $id => $definition) { - $this->setDefinition($id, $definition); - } - } - - /** - * Sets the service definitions. - * - * @param array $definitions An array of service definitions - * - * @api - */ - public function setDefinitions(array $definitions) - { - $this->definitions = array(); - $this->addDefinitions($definitions); - } - - /** - * Gets all service definitions. - * - * @return array An array of Definition instances - * - * @api - */ - public function getDefinitions() - { - return $this->definitions; - } - - /** - * Sets a service definition. - * - * @param string $id The service identifier - * @param Definition $definition A Definition instance - * - * @throws BadMethodCallException When this ContainerBuilder is frozen - * - * @api - */ - public function setDefinition($id, Definition $definition) - { - if ($this->isFrozen()) { - throw new BadMethodCallException('Adding definition to a frozen container is not allowed'); - } - - $id = strtolower($id); - - unset($this->aliases[$id]); - - return $this->definitions[$id] = $definition; - } - - /** - * Returns true if a service definition exists under the given identifier. - * - * @param string $id The service identifier - * - * @return Boolean true if the service definition exists, false otherwise - * - * @api - */ - public function hasDefinition($id) - { - return array_key_exists(strtolower($id), $this->definitions); - } - - /** - * Gets a service definition. - * - * @param string $id The service identifier - * - * @return Definition A Definition instance - * - * @throws InvalidArgumentException if the service definition does not exist - * - * @api - */ - public function getDefinition($id) - { - $id = strtolower($id); - - if (!$this->hasDefinition($id)) { - throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id)); - } - - return $this->definitions[$id]; - } - - /** - * Gets a service definition by id or alias. - * - * The method "unaliases" recursively to return a Definition instance. - * - * @param string $id The service identifier or alias - * - * @return Definition A Definition instance - * - * @throws InvalidArgumentException if the service definition does not exist - * - * @api - */ - public function findDefinition($id) - { - while ($this->hasAlias($id)) { - $id = (string) $this->getAlias($id); - } - - return $this->getDefinition($id); - } - - /** - * Creates a service for a service definition. - * - * @param Definition $definition A service definition instance - * @param string $id The service identifier - * - * @return object The service described by the service definition - * - * @throws RuntimeException When factory specification is incomplete or scope is inactive - * @throws InvalidArgumentException When configure callable is not callable - */ - private function createService(Definition $definition, $id) - { - if (null !== $definition->getFile()) { - require_once $this->getParameterBag()->resolveValue($definition->getFile()); - } - - $arguments = $this->resolveServices($this->getParameterBag()->resolveValue($definition->getArguments())); - - if (null !== $definition->getFactoryMethod()) { - if (null !== $definition->getFactoryClass()) { - $factory = $this->getParameterBag()->resolveValue($definition->getFactoryClass()); - } elseif (null !== $definition->getFactoryService()) { - $factory = $this->get($this->getParameterBag()->resolveValue($definition->getFactoryService())); - } else { - throw new RuntimeException('Cannot create service from factory method without a factory service or factory class.'); - } - - $service = call_user_func_array(array($factory, $definition->getFactoryMethod()), $arguments); - } else { - $r = new \ReflectionClass($this->getParameterBag()->resolveValue($definition->getClass())); - - $service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments); - } - - if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { - if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) { - throw new RuntimeException('You tried to create a service of an inactive scope.'); - } - - $this->services[$lowerId = strtolower($id)] = $service; - - if (self::SCOPE_CONTAINER !== $scope) { - $this->scopedServices[$scope][$lowerId] = $service; - } - } - - foreach ($definition->getMethodCalls() as $call) { - $services = self::getServiceConditionals($call[1]); - - $ok = true; - foreach ($services as $s) { - if (!$this->has($s)) { - $ok = false; - break; - } - } - - if ($ok) { - call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1]))); - } - } - - $properties = $this->resolveServices($this->getParameterBag()->resolveValue($definition->getProperties())); - foreach ($properties as $name => $value) { - $service->$name = $value; - } - - if ($callable = $definition->getConfigurator()) { - if (is_array($callable) && is_object($callable[0]) && $callable[0] instanceof Reference) { - $callable[0] = $this->get((string) $callable[0]); - } elseif (is_array($callable)) { - $callable[0] = $this->getParameterBag()->resolveValue($callable[0]); - } - - if (!is_callable($callable)) { - throw new InvalidArgumentException(sprintf('The configure callable for class "%s" is not a callable.', get_class($service))); - } - - call_user_func($callable, $service); - } - - return $service; - } - - /** - * Replaces service references by the real service instance. - * - * @param mixed $value A value - * - * @return mixed The same value with all service references replaced by the real service instances - */ - public function resolveServices($value) - { - if (is_array($value)) { - foreach ($value as &$v) { - $v = $this->resolveServices($v); - } - } elseif (is_object($value) && $value instanceof Reference) { - $value = $this->get((string) $value, $value->getInvalidBehavior()); - } elseif (is_object($value) && $value instanceof Definition) { - $value = $this->createService($value, null); - } - - return $value; - } - - /** - * Returns service ids for a given tag. - * - * @param string $name The tag name - * - * @return array An array of tags - * - * @api - */ - public function findTaggedServiceIds($name) - { - $tags = array(); - foreach ($this->getDefinitions() as $id => $definition) { - if ($definition->getTag($name)) { - $tags[$id] = $definition->getTag($name); - } - } - - return $tags; - } - - /** - * Returns the Service Conditionals. - * - * @param mixed $value An array of conditionals to return. - * - * @return array An array of Service conditionals - */ - static public function getServiceConditionals($value) - { - $services = array(); - - if (is_array($value)) { - foreach ($value as $v) { - $services = array_unique(array_merge($services, self::getServiceConditionals($v))); - } - } elseif (is_object($value) && $value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { - $services[] = (string) $value; - } - - return $services; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/ContainerInterface.php b/core/vendor/Symfony/Component/DependencyInjection/ContainerInterface.php deleted file mode 100644 index 93cbf3a650d516e608271840e92b197ea094187c..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/ContainerInterface.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; - -/** - * ContainerInterface is the interface implemented by service container classes. - * - * @author Fabien Potencier - * @author Johannes M. Schmitt - * - * @api - */ -interface ContainerInterface -{ - const EXCEPTION_ON_INVALID_REFERENCE = 1; - const NULL_ON_INVALID_REFERENCE = 2; - const IGNORE_ON_INVALID_REFERENCE = 3; - const SCOPE_CONTAINER = 'container'; - const SCOPE_PROTOTYPE = 'prototype'; - - /** - * Sets a service. - * - * @param string $id The service identifier - * @param object $service The service instance - * @param string $scope The scope of the service - * - * @api - */ - function set($id, $service, $scope = self::SCOPE_CONTAINER); - - /** - * Gets a service. - * - * @param string $id The service identifier - * @param int $invalidBehavior The behavior when the service does not exist - * - * @return object The associated service - * - * @throws InvalidArgumentException if the service is not defined - * - * @see Reference - * - * @api - */ - function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); - - /** - * Returns true if the given service is defined. - * - * @param string $id The service identifier - * - * @return Boolean true if the service is defined, false otherwise - * - * @api - */ - function has($id); - - /** - * Gets a parameter. - * - * @param string $name The parameter name - * - * @return mixed The parameter value - * - * @throws InvalidArgumentException if the parameter is not defined - * - * @api - */ - function getParameter($name); - - /** - * Checks if a parameter exists. - * - * @param string $name The parameter name - * - * @return Boolean The presence of parameter in container - * - * @api - */ - function hasParameter($name); - - /** - * Sets a parameter. - * - * @param string $name The parameter name - * @param mixed $value The parameter value - * - * @api - */ - function setParameter($name, $value); - - /** - * Enters the given scope - * - * @param string $name - * - * @api - */ - function enterScope($name); - - /** - * Leaves the current scope, and re-enters the parent scope - * - * @param string $name - * - * @api - */ - function leaveScope($name); - - /** - * Adds a scope to the container - * - * @param ScopeInterface $scope - * - * @api - */ - function addScope(ScopeInterface $scope); - - /** - * Whether this container has the given scope - * - * @param string $name - * - * @return Boolean - * - * @api - */ - function hasScope($name); - - /** - * Determines whether the given scope is currently active. - * - * It does however not check if the scope actually exists. - * - * @param string $name - * - * @return Boolean - * - * @api - */ - function isScopeActive($name); -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Definition.php b/core/vendor/Symfony/Component/DependencyInjection/Definition.php deleted file mode 100644 index 1c974a6bb01478e152d9ccbb3d12483508afb0a2..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Definition.php +++ /dev/null @@ -1,655 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException; - -/** - * Definition represents a service definition. - * - * @author Fabien Potencier - * - * @api - */ -class Definition -{ - private $class; - private $file; - private $factoryClass; - private $factoryMethod; - private $factoryService; - private $scope; - private $properties; - private $calls; - private $configurator; - private $tags; - private $public; - private $synthetic; - private $abstract; - - protected $arguments; - - /** - * Constructor. - * - * @param string $class The service class - * @param array $arguments An array of arguments to pass to the service constructor - * - * @api - */ - public function __construct($class = null, array $arguments = array()) - { - $this->class = $class; - $this->arguments = $arguments; - $this->calls = array(); - $this->scope = ContainerInterface::SCOPE_CONTAINER; - $this->tags = array(); - $this->public = true; - $this->synthetic = false; - $this->abstract = false; - $this->properties = array(); - } - - /** - * Sets the name of the class that acts as a factory using the factory method, - * which will be invoked statically. - * - * @param string $factoryClass The factory class name - * - * @return Definition The current instance - * - * @api - */ - public function setFactoryClass($factoryClass) - { - $this->factoryClass = $factoryClass; - - return $this; - } - - /** - * Gets the factory class. - * - * @return string The factory class name - * - * @api - */ - public function getFactoryClass() - { - return $this->factoryClass; - } - - /** - * Sets the factory method able to create an instance of this class. - * - * @param string $factoryMethod The factory method name - * - * @return Definition The current instance - * - * @api - */ - public function setFactoryMethod($factoryMethod) - { - $this->factoryMethod = $factoryMethod; - - return $this; - } - - /** - * Gets the factory method. - * - * @return string The factory method name - * - * @api - */ - public function getFactoryMethod() - { - return $this->factoryMethod; - } - - /** - * Sets the name of the service that acts as a factory using the factory method. - * - * @param string $factoryService The factory service id - * - * @return Definition The current instance - * - * @api - */ - public function setFactoryService($factoryService) - { - $this->factoryService = $factoryService; - - return $this; - } - - /** - * Gets the factory service id. - * - * @return string The factory service id - * - * @api - */ - public function getFactoryService() - { - return $this->factoryService; - } - - /** - * Sets the service class. - * - * @param string $class The service class - * - * @return Definition The current instance - * - * @api - */ - public function setClass($class) - { - $this->class = $class; - - return $this; - } - - /** - * Gets the service class. - * - * @return string The service class - * - * @api - */ - public function getClass() - { - return $this->class; - } - - /** - * Sets the arguments to pass to the service constructor/factory method. - * - * @param array $arguments An array of arguments - * - * @return Definition The current instance - * - * @api - */ - public function setArguments(array $arguments) - { - $this->arguments = $arguments; - - return $this; - } - - /** - * @api - */ - public function setProperties(array $properties) - { - $this->properties = $properties; - - return $this; - } - - /** - * @api - */ - public function getProperties() - { - return $this->properties; - } - - /** - * @api - */ - public function setProperty($name, $value) - { - $this->properties[$name] = $value; - - return $this; - } - - /** - * Adds an argument to pass to the service constructor/factory method. - * - * @param mixed $argument An argument - * - * @return Definition The current instance - * - * @api - */ - public function addArgument($argument) - { - $this->arguments[] = $argument; - - return $this; - } - - /** - * Sets a specific argument - * - * @param integer $index - * @param mixed $argument - * - * @return Definition The current instance - * - * @api - */ - public function replaceArgument($index, $argument) - { - if ($index < 0 || $index > count($this->arguments) - 1) { - throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1)); - } - - $this->arguments[$index] = $argument; - - return $this; - } - - /** - * Gets the arguments to pass to the service constructor/factory method. - * - * @return array The array of arguments - * - * @api - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * Gets an argument to pass to the service constructor/factory method. - * - * @param integer $index - * - * @return mixed The argument value - * - * @api - */ - public function getArgument($index) - { - if ($index < 0 || $index > count($this->arguments) - 1) { - throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1)); - } - - return $this->arguments[$index]; - } - - /** - * Sets the methods to call after service initialization. - * - * @param array $calls An array of method calls - * - * @return Definition The current instance - * - * @api - */ - public function setMethodCalls(array $calls = array()) - { - $this->calls = array(); - foreach ($calls as $call) { - $this->addMethodCall($call[0], $call[1]); - } - - return $this; - } - - /** - * Adds a method to call after service initialization. - * - * @param string $method The method name to call - * @param array $arguments An array of arguments to pass to the method call - * - * @return Definition The current instance - * - * @throws InvalidArgumentException on empty $method param - * - * @api - */ - public function addMethodCall($method, array $arguments = array()) - { - if (empty($method)) { - throw new InvalidArgumentException(sprintf('Method name cannot be empty.')); - } - $this->calls[] = array($method, $arguments); - - return $this; - } - - /** - * Removes a method to call after service initialization. - * - * @param string $method The method name to remove - * - * @return Definition The current instance - * - * @api - */ - public function removeMethodCall($method) - { - foreach ($this->calls as $i => $call) { - if ($call[0] === $method) { - unset($this->calls[$i]); - break; - } - } - - return $this; - } - - /** - * Check if the current definition has a given method to call after service initialization. - * - * @param string $method The method name to search for - * - * @return Boolean - * - * @api - */ - public function hasMethodCall($method) - { - foreach ($this->calls as $call) { - if ($call[0] === $method) { - return true; - } - } - - return false; - } - - /** - * Gets the methods to call after service initialization. - * - * @return array An array of method calls - * - * @api - */ - public function getMethodCalls() - { - return $this->calls; - } - - /** - * Sets tags for this definition - * - * @param array $tags - * - * @return Definition the current instance - * - * @api - */ - public function setTags(array $tags) - { - $this->tags = $tags; - - return $this; - } - - /** - * Returns all tags. - * - * @return array An array of tags - * - * @api - */ - public function getTags() - { - return $this->tags; - } - - /** - * Gets a tag by name. - * - * @param string $name The tag name - * - * @return array An array of attributes - * - * @api - */ - public function getTag($name) - { - return isset($this->tags[$name]) ? $this->tags[$name] : array(); - } - - /** - * Adds a tag for this definition. - * - * @param string $name The tag name - * @param array $attributes An array of attributes - * - * @return Definition The current instance - * - * @api - */ - public function addTag($name, array $attributes = array()) - { - $this->tags[$name][] = $attributes; - - return $this; - } - - /** - * Whether this definition has a tag with the given name - * - * @param string $name - * - * @return Boolean - * - * @api - */ - public function hasTag($name) - { - return isset($this->tags[$name]); - } - - /** - * Clears all tags for a given name. - * - * @param string $name The tag name - * - * @return Definition - */ - public function clearTag($name) - { - if (isset($this->tags[$name])) { - unset($this->tags[$name]); - } - - return $this; - } - - /** - * Clears the tags for this definition. - * - * @return Definition The current instance - * - * @api - */ - public function clearTags() - { - $this->tags = array(); - - return $this; - } - - /** - * Sets a file to require before creating the service. - * - * @param string $file A full pathname to include - * - * @return Definition The current instance - * - * @api - */ - public function setFile($file) - { - $this->file = $file; - - return $this; - } - - /** - * Gets the file to require before creating the service. - * - * @return string The full pathname to include - * - * @api - */ - public function getFile() - { - return $this->file; - } - - /** - * Sets the scope of the service - * - * @param string $scope Whether the service must be shared or not - * - * @return Definition The current instance - * - * @api - */ - public function setScope($scope) - { - $this->scope = $scope; - - return $this; - } - - /** - * Returns the scope of the service - * - * @return string - * - * @api - */ - public function getScope() - { - return $this->scope; - } - - /** - * Sets the visibility of this service. - * - * @param Boolean $boolean - * - * @return Definition The current instance - * - * @api - */ - public function setPublic($boolean) - { - $this->public = (Boolean) $boolean; - - return $this; - } - - /** - * Whether this service is public facing - * - * @return Boolean - * - * @api - */ - public function isPublic() - { - return $this->public; - } - - /** - * Sets whether this definition is synthetic, that is not constructed by the - * container, but dynamically injected. - * - * @param Boolean $boolean - * - * @return Definition the current instance - * - * @api - */ - public function setSynthetic($boolean) - { - $this->synthetic = (Boolean) $boolean; - - return $this; - } - - /** - * Whether this definition is synthetic, that is not constructed by the - * container, but dynamically injected. - * - * @return Boolean - * - * @api - */ - public function isSynthetic() - { - return $this->synthetic; - } - - /** - * Whether this definition is abstract, that means it merely serves as a - * template for other definitions. - * - * @param Boolean $boolean - * - * @return Definition the current instance - * - * @api - */ - public function setAbstract($boolean) - { - $this->abstract = (Boolean) $boolean; - - return $this; - } - - /** - * Whether this definition is abstract, that means it merely serves as a - * template for other definitions. - * - * @return Boolean - * - * @api - */ - public function isAbstract() - { - return $this->abstract; - } - - /** - * Sets a configurator to call after the service is fully initialized. - * - * @param mixed $callable A PHP callable - * - * @return Definition The current instance - * - * @api - */ - public function setConfigurator($callable) - { - $this->configurator = $callable; - - return $this; - } - - /** - * Gets the configurator to call after the service is fully initialized. - * - * @return mixed The PHP callable to call - * - * @api - */ - public function getConfigurator() - { - return $this->configurator; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/core/vendor/Symfony/Component/DependencyInjection/DefinitionDecorator.php deleted file mode 100644 index 8652d80fe3203c78058fe966c1252d9186e6acfe..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException; - -/** - * This definition decorates another definition. - * - * @author Johannes M. Schmitt - * - * @api - */ -class DefinitionDecorator extends Definition -{ - private $parent; - private $changes; - - /** - * Constructor. - * - * @param Definition $parent The Definition instance to decorate. - * - * @api - */ - public function __construct($parent) - { - parent::__construct(); - - $this->parent = $parent; - $this->changes = array(); - } - - /** - * Returns the Definition being decorated. - * - * @return Definition - * - * @api - */ - public function getParent() - { - return $this->parent; - } - - /** - * Returns all changes tracked for the Definition object. - * - * @return array An array of changes for this Definition - * - * @api - */ - public function getChanges() - { - return $this->changes; - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setClass($class) - { - $this->changes['class'] = true; - - return parent::setClass($class); - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setFactoryClass($class) - { - $this->changes['factory_class'] = true; - - return parent::setFactoryClass($class); - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setFactoryMethod($method) - { - $this->changes['factory_method'] = true; - - return parent::setFactoryMethod($method); - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setFactoryService($service) - { - $this->changes['factory_service'] = true; - - return parent::setFactoryService($service); - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setConfigurator($callable) - { - $this->changes['configurator'] = true; - - return parent::setConfigurator($callable); - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setFile($file) - { - $this->changes['file'] = true; - - return parent::setFile($file); - } - - /** - * {@inheritDoc} - * - * @api - */ - public function setPublic($boolean) - { - $this->changes['public'] = true; - - return parent::setPublic($boolean); - } - - /** - * Gets an argument to pass to the service constructor/factory method. - * - * If replaceArgument() has been used to replace an argument, this method - * will return the replacement value. - * - * @param integer $index - * - * @return mixed The argument value - * - * @api - */ - public function getArgument($index) - { - if (array_key_exists('index_'.$index, $this->arguments)) { - return $this->arguments['index_'.$index]; - } - - $lastIndex = count(array_filter(array_keys($this->arguments), 'is_int')) - 1; - - if ($index < 0 || $index > $lastIndex) { - throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, $lastIndex)); - } - - return $this->arguments[$index]; - } - - /** - * You should always use this method when overwriting existing arguments - * of the parent definition. - * - * If you directly call setArguments() keep in mind that you must follow - * certain conventions when you want to overwrite the arguments of the - * parent definition, otherwise your arguments will only be appended. - * - * @param integer $index - * @param mixed $value - * - * @return DefinitionDecorator the current instance - * @throws InvalidArgumentException when $index isn't an integer - * - * @api - */ - public function replaceArgument($index, $value) - { - if (!is_int($index)) { - throw new InvalidArgumentException('$index must be an integer.'); - } - - $this->arguments['index_'.$index] = $value; - - return $this; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php b/core/vendor/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php deleted file mode 100644 index c05dc6d49d8fa1dc4eaf5006977d73443dbea31f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Dumper; - -/** - * DumperInterface is the interface implemented by service container dumper classes. - * - * @author Fabien Potencier - * - * @api - */ -interface DumperInterface -{ - /** - * Dumps the service container. - * - * @param array $options An array of options - * - * @return string The representation of the service container - * - * @api - */ - function dump(array $options = array()); -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/core/vendor/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php deleted file mode 100644 index 133c6217ff87d69dca3a53ece4847a1f98d7f09b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ /dev/null @@ -1,273 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Dumper; - -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * GraphvizDumper dumps a service container as a graphviz file. - * - * You can convert the generated dot file with the dot utility (http://www.graphviz.org/): - * - * dot -Tpng container.dot > foo.png - * - * @author Fabien Potencier - */ -class GraphvizDumper extends Dumper -{ - private $nodes; - private $edges; - private $options = array( - 'graph' => array('ratio' => 'compress'), - 'node' => array('fontsize' => 11, 'fontname' => 'Arial', 'shape' => 'record'), - 'edge' => array('fontsize' => 9, 'fontname' => 'Arial', 'color' => 'grey', 'arrowhead' => 'open', 'arrowsize' => 0.5), - 'node.instance' => array('fillcolor' => '#9999ff', 'style' => 'filled'), - 'node.definition' => array('fillcolor' => '#eeeeee'), - 'node.missing' => array('fillcolor' => '#ff9999', 'style' => 'filled'), - ); - - /** - * Dumps the service container as a graphviz graph. - * - * Available options: - * - * * graph: The default options for the whole graph - * * node: The default options for nodes - * * edge: The default options for edges - * * node.instance: The default options for services that are defined directly by object instances - * * node.definition: The default options for services that are defined via service definition instances - * * node.missing: The default options for missing services - * - * @param array $options An array of options - * - * @return string The dot representation of the service container - */ - public function dump(array $options = array()) - { - foreach (array('graph', 'node', 'edge', 'node.instance', 'node.definition', 'node.missing') as $key) { - if (isset($options[$key])) { - $this->options[$key] = array_merge($this->options[$key], $options[$key]); - } - } - - $this->nodes = $this->findNodes(); - - $this->edges = array(); - foreach ($this->container->getDefinitions() as $id => $definition) { - $this->edges[$id] = array_merge( - $this->findEdges($id, $definition->getArguments(), true, ''), - $this->findEdges($id, $definition->getProperties(), false, '') - ); - - foreach ($definition->getMethodCalls() as $call) { - $this->edges[$id] = array_merge( - $this->edges[$id], - $this->findEdges($id, $call[1], false, $call[0].'()') - ); - } - } - - return $this->startDot().$this->addNodes().$this->addEdges().$this->endDot(); - } - - /** - * Returns all nodes. - * - * @return string A string representation of all nodes - */ - private function addNodes() - { - $code = ''; - foreach ($this->nodes as $id => $node) { - $aliases = $this->getAliases($id); - - $code .= sprintf(" node_%s [label=\"%s\\n%s\\n\", shape=%s%s];\n", $this->dotize($id), $id.($aliases ? ' ('.implode(', ', $aliases).')' : ''), $node['class'], $this->options['node']['shape'], $this->addAttributes($node['attributes'])); - } - - return $code; - } - - /** - * Returns all edges. - * - * @return string A string representation of all edges - */ - private function addEdges() - { - $code = ''; - foreach ($this->edges as $id => $edges) { - foreach ($edges as $edge) { - $code .= sprintf(" node_%s -> node_%s [label=\"%s\" style=\"%s\"];\n", $this->dotize($id), $this->dotize($edge['to']), $edge['name'], $edge['required'] ? 'filled' : 'dashed'); - } - } - - return $code; - } - - /** - * Finds all edges belonging to a specific service id. - * - * @param string $id The service id used to find edges - * @param array $arguments An array of arguments - * @param Boolean $required - * @param string $name - * - * @return array An array of edges - */ - private function findEdges($id, $arguments, $required, $name) - { - $edges = array(); - foreach ($arguments as $argument) { - if (is_object($argument) && $argument instanceof Parameter) { - $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null; - } elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) { - $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null; - } - - if ($argument instanceof Reference) { - if (!$this->container->has((string) $argument)) { - $this->nodes[(string) $argument] = array('name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']); - } - - $edges[] = array('name' => $name, 'required' => $required, 'to' => $argument); - } elseif (is_array($argument)) { - $edges = array_merge($edges, $this->findEdges($id, $argument, $required, $name)); - } - } - - return $edges; - } - - /** - * Finds all nodes. - * - * @return array An array of all nodes - */ - private function findNodes() - { - $nodes = array(); - - $container = clone $this->container; - - foreach ($container->getDefinitions() as $id => $definition) { - $nodes[$id] = array('class' => str_replace('\\', '\\\\', $this->container->getParameterBag()->resolveValue($definition->getClass())), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted'))); - - $container->setDefinition($id, new Definition('stdClass')); - } - - foreach ($container->getServiceIds() as $id) { - $service = $container->get($id); - - if (in_array($id, array_keys($container->getAliases()))) { - continue; - } - - if (!$container->hasDefinition($id)) { - $nodes[$id] = array('class' => str_replace('\\', '\\\\', get_class($service)), 'attributes' => $this->options['node.instance']); - } - } - - return $nodes; - } - - /** - * Returns the start dot. - * - * @return string The string representation of a start dot - */ - private function startDot() - { - return sprintf("digraph sc {\n %s\n node [%s];\n edge [%s];\n\n", - $this->addOptions($this->options['graph']), - $this->addOptions($this->options['node']), - $this->addOptions($this->options['edge']) - ); - } - - /** - * Returns the end dot. - * - * @return string - */ - private function endDot() - { - return "}\n"; - } - - /** - * Adds attributes - * - * @param array $attributes An array of attributes - * - * @return string A comma separated list of attributes - */ - private function addAttributes($attributes) - { - $code = array(); - foreach ($attributes as $k => $v) { - $code[] = sprintf('%s="%s"', $k, $v); - } - - return $code ? ', '.implode(', ', $code) : ''; - } - - /** - * Adds options - * - * @param array $options An array of options - * - * @return string A space separated list of options - */ - private function addOptions($options) - { - $code = array(); - foreach ($options as $k => $v) { - $code[] = sprintf('%s="%s"', $k, $v); - } - - return implode(' ', $code); - } - - /** - * Dotizes an identifier. - * - * @param string $id The identifier to dotize - * - * @return string A dotized string - */ - private function dotize($id) - { - return strtolower(preg_replace('/[^\w]/i', '_', $id)); - } - - /** - * Compiles an array of aliases for a specified service id. - * - * @param string $id A service id - * - * @return array An array of aliases - */ - private function getAliases($id) - { - $aliases = array(); - foreach ($this->container->getAliases() as $alias => $origin) { - if ($id == $origin) { - $aliases[] = $alias; - } - } - - return $aliases; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/core/vendor/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php deleted file mode 100644 index a567dfe45752ef6c149fad0345fd70f61b30c828..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ /dev/null @@ -1,1137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Dumper; - -use Symfony\Component\DependencyInjection\Variable; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; - -/** - * PhpDumper dumps a service container as a PHP class. - * - * @author Fabien Potencier - * @author Johannes M. Schmitt - * - * @api - */ -class PhpDumper extends Dumper -{ - /** - * Characters that might appear in the generated variable name as first character - * @var string - */ - const FIRST_CHARS = 'abcdefghijklmnopqrstuvwxyz'; - - /** - * Characters that might appear in the generated variable name as any but the first character - * @var string - */ - const NON_FIRST_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_'; - - private $inlinedDefinitions; - private $definitionVariables; - private $referenceVariables; - private $variableCount; - private $reservedVariables = array('instance', 'class'); - - /** - * {@inheritDoc} - * - * @api - */ - public function __construct(ContainerBuilder $container) - { - parent::__construct($container); - - $this->inlinedDefinitions = new \SplObjectStorage; - } - - /** - * Dumps the service container as a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing of the service container - * - * @api - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'class' => 'ProjectServiceContainer', - 'base_class' => 'Container', - ), $options); - - $code = $this->startClass($options['class'], $options['base_class']); - - if ($this->container->isFrozen()) { - $code .= $this->addFrozenConstructor(); - } else { - $code .= $this->addConstructor(); - } - - $code .= - $this->addServices(). - $this->addDefaultParametersMethod(). - $this->endClass() - ; - - return $code; - } - - /** - * Generates Service local temp variables. - * - * @param string $cId - * @param string $definition - * - * @return string - */ - private function addServiceLocalTempVariables($cId, $definition) - { - static $template = " \$%s = %s;\n"; - - $localDefinitions = array_merge( - array($definition), - $this->getInlinedDefinitions($definition) - ); - - $calls = $behavior = array(); - foreach ($localDefinitions as $iDefinition) { - $this->getServiceCallsFromArguments($iDefinition->getArguments(), $calls, $behavior); - $this->getServiceCallsFromArguments($iDefinition->getMethodCalls(), $calls, $behavior); - $this->getServiceCallsFromArguments($iDefinition->getProperties(), $calls, $behavior); - } - - $code = ''; - foreach ($calls as $id => $callCount) { - if ('service_container' === $id || $id === $cId) { - continue; - } - - if ($callCount > 1) { - $name = $this->getNextVariableName(); - $this->referenceVariables[$id] = new Variable($name); - - if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $behavior[$id]) { - $code .= sprintf($template, $name, $this->getServiceCall($id)); - } else { - $code .= sprintf($template, $name, $this->getServiceCall($id, new Reference($id, ContainerInterface::NULL_ON_INVALID_REFERENCE))); - } - } - } - - if ('' !== $code) { - $code .= "\n"; - } - - return $code; - } - - /** - * Generates the require_once statement for service includes. - * - * @param string $id The service id - * @param Definition $definition - * - * @return string - */ - private function addServiceInclude($id, $definition) - { - $template = " require_once %s;\n"; - $code = ''; - - if (null !== $file = $definition->getFile()) { - $code .= sprintf($template, $this->dumpValue($file)); - } - - foreach ($this->getInlinedDefinitions($definition) as $definition) { - if (null !== $file = $definition->getFile()) { - $code .= sprintf($template, $this->dumpValue($file)); - } - } - - if ('' !== $code) { - $code .= "\n"; - } - - return $code; - } - - /** - * Generates the inline definition of a service. - * - * @param string $id - * @param Definition $definition - * - * @return string - */ - private function addServiceInlinedDefinitions($id, $definition) - { - $code = ''; - $variableMap = $this->definitionVariables; - $nbOccurrences = new \SplObjectStorage(); - $processed = new \SplObjectStorage(); - $inlinedDefinitions = $this->getInlinedDefinitions($definition); - - foreach ($inlinedDefinitions as $definition) { - if (false === $nbOccurrences->contains($definition)) { - $nbOccurrences->offsetSet($definition, 1); - } else { - $i = $nbOccurrences->offsetGet($definition); - $nbOccurrences->offsetSet($definition, $i+1); - } - } - - foreach ($inlinedDefinitions as $sDefinition) { - if ($processed->contains($sDefinition)) { - continue; - } - $processed->offsetSet($sDefinition); - - $class = $this->dumpValue($sDefinition->getClass()); - if ($nbOccurrences->offsetGet($sDefinition) > 1 || count($sDefinition->getMethodCalls()) > 0 || $sDefinition->getProperties() || null !== $sDefinition->getConfigurator() || false !== strpos($class, '$')) { - $name = $this->getNextVariableName(); - $variableMap->offsetSet($sDefinition, new Variable($name)); - - // a construct like: - // $a = new ServiceA(ServiceB $b); $b = new ServiceB(ServiceA $a); - // this is an indication for a wrong implementation, you can circumvent this problem - // by setting up your service structure like this: - // $b = new ServiceB(); - // $a = new ServiceA(ServiceB $b); - // $b->setServiceA(ServiceA $a); - if ($this->hasReference($id, $sDefinition->getArguments())) { - throw new ServiceCircularReferenceException($id, array($id)); - } - - $arguments = array(); - foreach ($sDefinition->getArguments() as $argument) { - $arguments[] = $this->dumpValue($argument); - } - - if (null !== $sDefinition->getFactoryMethod()) { - if (null !== $sDefinition->getFactoryClass()) { - $code .= sprintf(" \$%s = call_user_func(array(%s, '%s')%s);\n", $name, $this->dumpValue($sDefinition->getFactoryClass()), $sDefinition->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : ''); - } elseif (null !== $sDefinition->getFactoryService()) { - $code .= sprintf(" \$%s = %s->%s(%s);\n", $name, $this->getServiceCall($sDefinition->getFactoryService()), $sDefinition->getFactoryMethod(), implode(', ', $arguments)); - } else { - throw new RuntimeException('Factory service or factory class must be defined in service definition for '.$id); - } - } elseif (false !== strpos($class, '$')) { - $code .= sprintf(" \$class = %s;\n \$%s = new \$class(%s);\n", $class, $name, implode(', ', $arguments)); - } else { - $code .= sprintf(" \$%s = new \\%s(%s);\n", $name, substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); - } - - if (!$this->hasReference($id, $sDefinition->getMethodCalls()) && !$this->hasReference($id, $sDefinition->getProperties())) { - $code .= $this->addServiceMethodCalls(null, $sDefinition, $name); - $code .= $this->addServiceProperties(null, $sDefinition, $name); - $code .= $this->addServiceConfigurator(null, $sDefinition, $name); - } - - $code .= "\n"; - } - } - - return $code; - } - - /** - * Adds the service return statement. - * - * @param string $id Service id - * @param Definition $definition - * - * @return string - */ - private function addServiceReturn($id, $definition) - { - if ($this->isSimpleInstance($id, $definition)) { - return " }\n"; - } - - return "\n return \$instance;\n }\n"; - } - - /** - * Generates the service instance. - * - * @param string $id - * @param Definition $definition - * - * @return string - * - * @throws InvalidArgumentException - * @throws RuntimeException - */ - private function addServiceInstance($id, $definition) - { - $class = $this->dumpValue($definition->getClass()); - - if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) { - throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); - } - - $arguments = array(); - foreach ($definition->getArguments() as $value) { - $arguments[] = $this->dumpValue($value); - } - - $simple = $this->isSimpleInstance($id, $definition); - - $instantiation = ''; - if (ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) { - $instantiation = "\$this->services['$id'] = ".($simple ? '' : '$instance'); - } elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { - $instantiation = "\$this->services['$id'] = \$this->scopedServices['$scope']['$id'] = ".($simple ? '' : '$instance'); - } elseif (!$simple) { - $instantiation = '$instance'; - } - - $return = ''; - if ($simple) { - $return = 'return '; - } else { - $instantiation .= ' = '; - } - - if (null !== $definition->getFactoryMethod()) { - if (null !== $definition->getFactoryClass()) { - $code = sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : ''); - } elseif (null !== $definition->getFactoryService()) { - $code = sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments)); - } else { - throw new RuntimeException('Factory method requires a factory service or factory class in service definition for '.$id); - } - } elseif (false !== strpos($class, '$')) { - $code = sprintf(" \$class = %s;\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments)); - } else { - $code = sprintf(" $return{$instantiation}new \\%s(%s);\n", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); - } - - if (!$simple) { - $code .= "\n"; - } - - return $code; - } - - /** - * Checks if the definition is a simple instance. - * - * @param string $id - * @param Definition $definition - * - * @return Boolean - */ - private function isSimpleInstance($id, $definition) - { - foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) { - if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) { - continue; - } - - if ($sDefinition->getMethodCalls() || $sDefinition->getProperties() || $sDefinition->getConfigurator()) { - return false; - } - } - - return true; - } - - /** - * Adds method calls to a service definition. - * - * @param string $id - * @param Definition $definition - * @param string $variableName - * - * @return string - */ - private function addServiceMethodCalls($id, $definition, $variableName = 'instance') - { - $calls = ''; - foreach ($definition->getMethodCalls() as $call) { - $arguments = array(); - foreach ($call[1] as $value) { - $arguments[] = $this->dumpValue($value); - } - - $calls .= $this->wrapServiceConditionals($call[1], sprintf(" \$%s->%s(%s);\n", $variableName, $call[0], implode(', ', $arguments))); - } - - return $calls; - } - - private function addServiceProperties($id, $definition, $variableName = 'instance') - { - $code = ''; - foreach ($definition->getProperties() as $name => $value) { - $code .= sprintf(" \$%s->%s = %s;\n", $variableName, $name, $this->dumpValue($value)); - } - - return $code; - } - - /** - * Generates the inline definition setup. - * - * @param string $id - * @param Definition $definition - * @return string - */ - private function addServiceInlinedDefinitionsSetup($id, $definition) - { - $this->referenceVariables[$id] = new Variable('instance'); - - $code = ''; - $processed = new \SplObjectStorage(); - foreach ($this->getInlinedDefinitions($definition) as $iDefinition) { - if ($processed->contains($iDefinition)) { - continue; - } - $processed->offsetSet($iDefinition); - - if (!$this->hasReference($id, $iDefinition->getMethodCalls())) { - continue; - } - - if ($iDefinition->getMethodCalls()) { - $code .= $this->addServiceMethodCalls(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition)); - } - if ($iDefinition->getConfigurator()) { - $code .= $this->addServiceConfigurator(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition)); - } - } - - if ('' !== $code) { - $code .= "\n"; - } - - return $code; - } - - /** - * Adds configurator definition - * - * @param string $id - * @param Definition $definition - * @param string $variableName - * - * @return string - */ - private function addServiceConfigurator($id, $definition, $variableName = 'instance') - { - if (!$callable = $definition->getConfigurator()) { - return ''; - } - - if (is_array($callable)) { - if (is_object($callable[0]) && $callable[0] instanceof Reference) { - return sprintf(" %s->%s(\$%s);\n", $this->getServiceCall((string) $callable[0]), $callable[1], $variableName); - } - - return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); - } - - return sprintf(" %s(\$%s);\n", $callable, $variableName); - } - - /** - * Adds a service - * - * @param string $id - * @param Definition $definition - * - * @return string - */ - private function addService($id, $definition) - { - $name = Container::camelize($id); - $this->definitionVariables = new \SplObjectStorage(); - $this->referenceVariables = array(); - $this->variableCount = 0; - - $return = ''; - if ($definition->isSynthetic()) { - $return = sprintf('@throws RuntimeException always since this service is expected to be injected dynamically'); - } elseif ($class = $definition->getClass()) { - $return = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'Object' : $class, $class); - } elseif ($definition->getFactoryClass()) { - $return = sprintf('@return Object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod()); - } elseif ($definition->getFactoryService()) { - $return = sprintf('@return Object An instance returned by %s::%s().', $definition->getFactoryService(), $definition->getFactoryMethod()); - } - - $doc = ''; - if (ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope()) { - $doc .= <<isPublic()) { - $doc .= <<getScope(); - if (ContainerInterface::SCOPE_CONTAINER !== $scope && ContainerInterface::SCOPE_PROTOTYPE !== $scope) { - $code .= <<scopedServices['$scope'])) { - throw new InactiveScopeException('$id', '$scope'); - } - - -EOF; - } - - if ($definition->isSynthetic()) { - $code .= sprintf(" throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id); - } else { - $code .= - $this->addServiceInclude($id, $definition). - $this->addServiceLocalTempVariables($id, $definition). - $this->addServiceInlinedDefinitions($id, $definition). - $this->addServiceInstance($id, $definition). - $this->addServiceInlinedDefinitionsSetup($id, $definition). - $this->addServiceMethodCalls($id, $definition). - $this->addServiceProperties($id, $definition). - $this->addServiceConfigurator($id, $definition). - $this->addServiceReturn($id, $definition) - ; - } - - $this->definitionVariables = null; - $this->referenceVariables = null; - - return $code; - } - - /** - * Adds a service alias. - * - * @param string $alias - * @param string $id - * - * @return string - */ - private function addServiceAlias($alias, $id) - { - $name = Container::camelize($alias); - $type = 'Object'; - - if ($this->container->hasDefinition($id)) { - $class = $this->container->getDefinition($id)->getClass(); - $type = 0 === strpos($class, '%') ? 'Object' : $class; - } - - return <<getServiceCall($id)}; - } - -EOF; - } - - /** - * Adds multiple services - * - * @return string - */ - private function addServices() - { - $publicServices = $privateServices = $aliasServices = ''; - $definitions = $this->container->getDefinitions(); - ksort($definitions); - foreach ($definitions as $id => $definition) { - if ($definition->isPublic()) { - $publicServices .= $this->addService($id, $definition); - } else { - $privateServices .= $this->addService($id, $definition); - } - } - - $aliases = $this->container->getAliases(); - ksort($aliases); - foreach ($aliases as $alias => $id) { - $aliasServices .= $this->addServiceAlias($alias, $id); - } - - return $publicServices.$aliasServices.$privateServices; - } - - /** - * Adds the class headers. - * - * @param string $class Class name - * @param string $baseClass The name of the base class - * - * @return string - */ - private function startClass($class, $baseClass) - { - $bagClass = $this->container->isFrozen() ? 'use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;' : 'use Symfony\Component\DependencyInjection\ParameterBag\\ParameterBag;'; - - return <<container->getParameterBag()->all() ? 'new ParameterBag($this->getDefaultParameters())' : null; - - $code = <<container->getScopes()) > 0) { - $code .= "\n"; - $code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n"; - $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n"; - } - - $code .= <<parameters = \$this->getDefaultParameters(); - - \$this->services = - \$this->scopedServices = - \$this->scopeStacks = array(); - - \$this->set('service_container', \$this); - -EOF; - - $code .= "\n"; - if (count($scopes = $this->container->getScopes()) > 0) { - $code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n"; - $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n"; - } else { - $code .= " \$this->scopes = array();\n"; - $code .= " \$this->scopeChildren = array();\n"; - } - - $code .= <<container->getParameterBag()->all()) { - return ''; - } - - $parameters = $this->exportParameters($this->container->getParameterBag()->all()); - - $code = ''; - if ($this->container->isFrozen()) { - $code .= <<parameters)) { - throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name)); - } - - return \$this->parameters[\$name]; - } - - /** - * {@inheritdoc} - */ - public function hasParameter(\$name) - { - return array_key_exists(strtolower(\$name), \$this->parameters); - } - - /** - * {@inheritdoc} - */ - public function setParameter(\$name, \$value) - { - throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); - } - - /** - * {@inheritDoc} - */ - public function getParameterBag() - { - if (null === \$this->parameterBag) { - \$this->parameterBag = new FrozenParameterBag(\$this->parameters); - } - - return \$this->parameterBag; - } -EOF; - } - - $code .= << $value) { - if (is_array($value)) { - $value = $this->exportParameters($value, $path.'/'.$key, $indent + 4); - } elseif ($value instanceof Variable) { - throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain variable references. Variable "%s" found in "%s".', $value, $path.'/'.$key)); - } elseif ($value instanceof Definition) { - throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain service definitions. Definition for "%s" found in "%s".', $value->getClass(), $path.'/'.$key)); - } elseif ($value instanceof Reference) { - throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain references to other services (reference to service "%s" found in "%s").', $value, $path.'/'.$key)); - } else { - $value = var_export($value, true); - } - - $php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), var_export($key, true), $value); - } - - return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4)); - } - - /** - * Ends the class definition. - * - * @return string - */ - private function endClass() - { - return <<has('%s')", $service); - } - - // re-indent the wrapped code - $code = implode("\n", array_map(function ($line) { return $line ? ' '.$line : $line; }, explode("\n", $code))); - - return sprintf(" if (%s) {\n%s }\n", implode(' && ', $conditions), $code); - } - - /** - * Builds service calls from arguments - * - * @param array $arguments - * @param string &$calls By reference - * @param string &$behavior By reference - */ - private function getServiceCallsFromArguments(array $arguments, array &$calls, array &$behavior) - { - foreach ($arguments as $argument) { - if (is_array($argument)) { - $this->getServiceCallsFromArguments($argument, $calls, $behavior); - } elseif ($argument instanceof Reference) { - $id = (string) $argument; - - if (!isset($calls[$id])) { - $calls[$id] = 0; - } - if (!isset($behavior[$id])) { - $behavior[$id] = $argument->getInvalidBehavior(); - } elseif (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $behavior[$id]) { - $behavior[$id] = $argument->getInvalidBehavior(); - } - - $calls[$id] += 1; - } - } - } - - /** - * Returns the inline definition - * - * @param Definition $definition - * - * @return array - */ - private function getInlinedDefinitions(Definition $definition) - { - if (false === $this->inlinedDefinitions->contains($definition)) { - $definitions = array_merge( - $this->getDefinitionsFromArguments($definition->getArguments()), - $this->getDefinitionsFromArguments($definition->getMethodCalls()), - $this->getDefinitionsFromArguments($definition->getProperties()) - ); - - $this->inlinedDefinitions->offsetSet($definition, $definitions); - - return $definitions; - } - - return $this->inlinedDefinitions->offsetGet($definition); - } - - /** - * Gets the definition from arguments - * - * @param array $arguments - * - * @return array - */ - private function getDefinitionsFromArguments(array $arguments) - { - $definitions = array(); - foreach ($arguments as $argument) { - if (is_array($argument)) { - $definitions = array_merge($definitions, $this->getDefinitionsFromArguments($argument)); - } elseif ($argument instanceof Definition) { - $definitions = array_merge( - $definitions, - $this->getInlinedDefinitions($argument), - array($argument) - ); - } - } - - return $definitions; - } - - /** - * Checks if a service id has a reference - * - * @param string $id - * @param array $arguments - * - * @return Boolean - */ - private function hasReference($id, array $arguments) - { - foreach ($arguments as $argument) { - if (is_array($argument)) { - if ($this->hasReference($id, $argument)) { - return true; - } - } elseif ($argument instanceof Reference) { - if ($id === (string) $argument) { - return true; - } - } - } - - return false; - } - - /** - * Dumps values. - * - * @param array $value - * @param Boolean $interpolate - * - * @return string - */ - private function dumpValue($value, $interpolate = true) - { - if (is_array($value)) { - $code = array(); - foreach ($value as $k => $v) { - $code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate)); - } - - return sprintf('array(%s)', implode(', ', $code)); - } elseif (is_object($value) && $value instanceof Definition) { - if (null !== $this->definitionVariables && $this->definitionVariables->contains($value)) { - return $this->dumpValue($this->definitionVariables->offsetGet($value), $interpolate); - } - if (count($value->getMethodCalls()) > 0) { - throw new RuntimeException('Cannot dump definitions which have method calls.'); - } - if (null !== $value->getConfigurator()) { - throw new RuntimeException('Cannot dump definitions which have a configurator.'); - } - - $arguments = array(); - foreach ($value->getArguments() as $argument) { - $arguments[] = $this->dumpValue($argument); - } - $class = $this->dumpValue($value->getClass()); - - if (false !== strpos($class, '$')) { - throw new RuntimeException('Cannot dump definitions which have a variable class name.'); - } - - if (null !== $value->getFactoryMethod()) { - if (null !== $value->getFactoryClass()) { - return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($value->getFactoryClass()), $value->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : ''); - } elseif (null !== $value->getFactoryService()) { - return sprintf("%s->%s(%s)", $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments)); - } else { - throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.'); - } - } - - return sprintf("new \\%s(%s)", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); - } elseif (is_object($value) && $value instanceof Variable) { - return '$'.$value; - } elseif (is_object($value) && $value instanceof Reference) { - if (null !== $this->referenceVariables && isset($this->referenceVariables[$id = (string) $value])) { - return $this->dumpValue($this->referenceVariables[$id], $interpolate); - } - - return $this->getServiceCall((string) $value, $value); - } elseif (is_object($value) && $value instanceof Parameter) { - return $this->dumpParameter($value); - } elseif (true === $interpolate && is_string($value)) { - if (preg_match('/^%([^%]+)%$/', $value, $match)) { - // we do this to deal with non string values (Boolean, integer, ...) - // the preg_replace_callback converts them to strings - return $this->dumpParameter(strtolower($match[1])); - } else { - $that = $this; - $replaceParameters = function ($match) use ($that) - { - return "'.".$that->dumpParameter(strtolower($match[2])).".'"; - }; - - $code = str_replace('%%', '%', preg_replace_callback('/(?container->isFrozen() && $this->container->hasParameter($name)) { - return $this->dumpValue($this->container->getParameter($name), false); - } - - return sprintf("\$this->getParameter('%s')", strtolower($name)); - } - - /** - * Gets a service call - * - * @param string $id - * @param Reference $reference - * - * @return string - */ - private function getServiceCall($id, Reference $reference = null) - { - if ('service_container' === $id) { - return '$this'; - } - - if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) { - return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id); - } else { - if ($this->container->hasAlias($id)) { - $id = (string) $this->container->getAlias($id); - } - - return sprintf('$this->get(\'%s\')', $id); - } - } - - /** - * Returns the next name to use - * - * @return string - */ - private function getNextVariableName() - { - $firstChars = self::FIRST_CHARS; - $firstCharsLength = strlen($firstChars); - $nonFirstChars = self::NON_FIRST_CHARS; - $nonFirstCharsLength = strlen($nonFirstChars); - - while (true) { - $name = ''; - $i = $this->variableCount; - - if ('' === $name) { - $name .= $firstChars[$i%$firstCharsLength]; - $i = intval($i/$firstCharsLength); - } - - while ($i > 0) { - $i -= 1; - $name .= $nonFirstChars[$i%$nonFirstCharsLength]; - $i = intval($i/$nonFirstCharsLength); - } - - $this->variableCount += 1; - - // check that the name is not reserved - if (in_array($name, $this->reservedVariables, true)) { - continue; - } - - return $name; - } - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/core/vendor/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php deleted file mode 100644 index 6a91b99fd878bc6f3a144a0f07a4dc302391316a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ /dev/null @@ -1,301 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Dumper; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Parameter; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -/** - * XmlDumper dumps a service container as an XML string. - * - * @author Fabien Potencier - * @author Martin Hasoň - * - * @api - */ -class XmlDumper extends Dumper -{ - /** - * @var \DOMDocument - */ - private $document; - - /** - * Dumps the service container as an XML string. - * - * @param array $options An array of options - * - * @return string An xml string representing of the service container - * - * @api - */ - public function dump(array $options = array()) - { - $this->document = new \DOMDocument('1.0', 'utf-8'); - $this->document->formatOutput = true; - - $container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container'); - $container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd'); - - $this->addParameters($container); - $this->addServices($container); - - $this->document->appendChild($container); - $xml = $this->document->saveXML(); - $this->document = null; - - return $xml; - } - - /** - * Adds parameters. - * - * @param DOMElement $parent - */ - private function addParameters(\DOMElement $parent) - { - $data = $this->container->getParameterBag()->all(); - if (!$data) { - return; - } - - if ($this->container->isFrozen()) { - $data = $this->escape($data); - } - - $parameters = $this->document->createElement('parameters'); - $parent->appendChild($parameters); - $this->convertParameters($data, 'parameter', $parameters); - } - - /** - * Adds method calls. - * - * @param array $methodcalls - * @param DOMElement $parent - */ - private function addMethodCalls(array $methodcalls, \DOMElement $parent) - { - foreach ($methodcalls as $methodcall) { - $call = $this->document->createElement('call'); - $call->setAttribute('method', $methodcall[0]); - if (count($methodcall[1])) { - $this->convertParameters($methodcall[1], 'argument', $call); - } - $parent->appendChild($call); - } - } - - /** - * Adds a service. - * - * @param Definition $definition - * @param string $id - * @param DOMElement $parent - */ - private function addService($definition, $id, \DOMElement $parent) - { - $service = $this->document->createElement('service'); - if (null !== $id) { - $service->setAttribute('id', $id); - } - if ($definition->getClass()) { - $service->setAttribute('class', $definition->getClass()); - } - if ($definition->getFactoryMethod()) { - $service->setAttribute('factory-method', $definition->getFactoryMethod()); - } - if ($definition->getFactoryService()) { - $service->setAttribute('factory-service', $definition->getFactoryService()); - } - if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) { - $service->setAttribute('scope', $scope); - } - if (!$definition->isPublic()) { - $service->setAttribute('public', 'false'); - } - - foreach ($definition->getTags() as $name => $tags) { - foreach ($tags as $attributes) { - $tag = $this->document->createElement('tag'); - $tag->setAttribute('name', $name); - foreach ($attributes as $key => $value) { - $tag->setAttribute($key, $value); - } - $service->appendChild($tag); - } - } - - if ($definition->getFile()) { - $file = $this->document->createElement('file'); - $file->appendChild($this->document->createTextNode($definition->getFile())); - $service->appendChild($file); - } - - if ($parameters = $definition->getArguments()) { - $this->convertParameters($parameters, 'argument', $service); - } - - if ($parameters = $definition->getProperties()) { - $this->convertParameters($parameters, 'property', $service, 'name'); - } - - $this->addMethodCalls($definition->getMethodCalls(), $service); - - if ($callable = $definition->getConfigurator()) { - $configurator = $this->document->createElement('configurator'); - if (is_array($callable)) { - $configurator->setAttribute((is_object($callable[0]) && $callable[0] instanceof Reference ? 'service' : 'class'), $callable[0]); - $configurator->setAttribute('method', $callable[1]); - } else { - $configurator->setAttribute('function', $callable); - } - $service->appendChild($configurator); - } - - $parent->appendChild($service); - } - - /** - * Adds a service alias. - * - * @param string $alias - * @param string $id - * @param DOMElement $parent - */ - private function addServiceAlias($alias, $id, \DOMElement $parent) - { - $service = $this->document->createElement('service'); - $service->setAttribute('id', $alias); - $service->setAttribute('alias', $id); - if (!$id->isPublic()) { - $service->setAttribute('public', 'false'); - } - $parent->appendChild($service); - } - - /** - * Adds services. - * - * @param DOMElement $parent - */ - private function addServices(\DOMElement $parent) - { - $definitions = $this->container->getDefinitions(); - if (!$definitions) { - return; - } - - $services = $this->document->createElement('services'); - foreach ($definitions as $id => $definition) { - $this->addService($definition, $id, $services); - } - - foreach ($this->container->getAliases() as $alias => $id) { - $this->addServiceAlias($alias, $id, $services); - } - $parent->appendChild($services); - } - - /** - * Converts parameters. - * - * @param array $parameters - * @param string $type - * @param DOMElement $parent - * @param string $keyAttribute - */ - private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key') - { - $withKeys = array_keys($parameters) !== range(0, count($parameters) - 1); - foreach ($parameters as $key => $value) { - $element = $this->document->createElement($type); - if ($withKeys) { - $element->setAttribute($keyAttribute, $key); - } - - if (is_array($value)) { - $element->setAttribute('type', 'collection'); - $this->convertParameters($value, $type, $element, 'key'); - } elseif (is_object($value) && $value instanceof Reference) { - $element->setAttribute('type', 'service'); - $element->setAttribute('id', (string) $value); - $behaviour = $value->getInvalidBehavior(); - if ($behaviour == ContainerInterface::NULL_ON_INVALID_REFERENCE) { - $element->setAttribute('on-invalid', 'null'); - } elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { - $element->setAttribute('on-invalid', 'ignore'); - } - } elseif (is_object($value) && $value instanceof Definition) { - $element->setAttribute('type', 'service'); - $this->addService($value, null, $element); - } else { - if (in_array($value, array('null', 'true', 'false'), true)) { - $element->setAttribute('type', 'string'); - } - $text = $this->document->createTextNode(self::phpToXml($value)); - $element->appendChild($text); - } - $parent->appendChild($element); - } - } - - /** - * Escapes arguments - * - * @param array $arguments - * - * @return array - */ - private function escape($arguments) - { - $args = array(); - foreach ($arguments as $k => $v) { - if (is_array($v)) { - $args[$k] = $this->escape($v); - } elseif (is_string($v)) { - $args[$k] = str_replace('%', '%%', $v); - } else { - $args[$k] = $v; - } - } - - return $args; - } - - /** - * Converts php types to xml types. - * - * @param mixed $value Value to convert - */ - static public function phpToXml($value) - { - switch (true) { - case null === $value: - return 'null'; - case true === $value: - return 'true'; - case false === $value: - return 'false'; - case is_object($value) && $value instanceof Parameter: - return '%'.$value.'%'; - case is_object($value) || is_resource($value): - throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); - default: - return (string) $value; - } - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/core/vendor/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php deleted file mode 100644 index 5768c1e927b11797b36373e0d9493d02ea93542b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ /dev/null @@ -1,278 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Dumper; - -use Symfony\Component\Yaml\Yaml; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Parameter; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -/** - * YamlDumper dumps a service container as a YAML string. - * - * @author Fabien Potencier - * - * @api - */ -class YamlDumper extends Dumper -{ - /** - * Dumps the service container as an YAML string. - * - * @param array $options An array of options - * - * @return string A YAML string representing of the service container - * - * @api - */ - public function dump(array $options = array()) - { - return $this->addParameters()."\n".$this->addServices(); - } - - /** - * Adds a service - * - * @param string $id - * @param Definition $definition - * - * @return string - */ - private function addService($id, $definition) - { - $code = " $id:\n"; - if ($definition->getClass()) { - $code .= sprintf(" class: %s\n", $definition->getClass()); - } - - $tagsCode = ''; - foreach ($definition->getTags() as $name => $tags) { - foreach ($tags as $attributes) { - $att = array(); - foreach ($attributes as $key => $value) { - $att[] = sprintf('%s: %s', Yaml::dump($key), Yaml::dump($value)); - } - $att = $att ? ', '.implode(' ', $att) : ''; - - $tagsCode .= sprintf(" - { name: %s%s }\n", Yaml::dump($name), $att); - } - } - if ($tagsCode) { - $code .= " tags:\n".$tagsCode; - } - - if ($definition->getFile()) { - $code .= sprintf(" file: %s\n", $definition->getFile()); - } - - if ($definition->getFactoryMethod()) { - $code .= sprintf(" factory_method: %s\n", $definition->getFactoryMethod()); - } - - if ($definition->getFactoryService()) { - $code .= sprintf(" factory_service: %s\n", $definition->getFactoryService()); - } - - if ($definition->getArguments()) { - $code .= sprintf(" arguments: %s\n", Yaml::dump($this->dumpValue($definition->getArguments()), 0)); - } - - if ($definition->getProperties()) { - $code .= sprintf(" properties: %s\n", Yaml::dump($this->dumpValue($definition->getProperties()), 0)); - } - - if ($definition->getMethodCalls()) { - $code .= sprintf(" calls:\n %s\n", str_replace("\n", "\n ", Yaml::dump($this->dumpValue($definition->getMethodCalls()), 1))); - } - - if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) { - $code .= sprintf(" scope: %s\n", $scope); - } - - if ($callable = $definition->getConfigurator()) { - if (is_array($callable)) { - if (is_object($callable[0]) && $callable[0] instanceof Reference) { - $callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]); - } else { - $callable = array($callable[0], $callable[1]); - } - } - - $code .= sprintf(" configurator: %s\n", Yaml::dump($callable, 0)); - } - - return $code; - } - - /** - * Adds a service alias - * - * @param string $alias - * @param string $id - * - * @return string - */ - private function addServiceAlias($alias, $id) - { - if ($id->isPublic()) { - return sprintf(" %s: @%s\n", $alias, $id); - } else { - return sprintf(" %s:\n alias: %s\n public: false", $alias, $id); - } - } - - /** - * Adds services - * - * @return string - */ - private function addServices() - { - if (!$this->container->getDefinitions()) { - return ''; - } - - $code = "services:\n"; - foreach ($this->container->getDefinitions() as $id => $definition) { - $code .= $this->addService($id, $definition); - } - - foreach ($this->container->getAliases() as $alias => $id) { - $code .= $this->addServiceAlias($alias, $id); - } - - return $code; - } - - /** - * Adds parameters - * - * @return string - */ - private function addParameters() - { - if (!$this->container->getParameterBag()->all()) { - return ''; - } - - if ($this->container->isFrozen()) { - $parameters = $this->prepareParameters($this->container->getParameterBag()->all()); - } else { - $parameters = $this->container->getParameterBag()->all(); - } - - return Yaml::dump(array('parameters' => $parameters), 2); - } - - /** - * Dumps the value to YAML format - * - * @param mixed $value - * - * @throws RuntimeException When trying to dump object or resource - */ - private function dumpValue($value) - { - if (is_array($value)) { - $code = array(); - foreach ($value as $k => $v) { - $code[$k] = $this->dumpValue($v); - } - - return $code; - } elseif (is_object($value) && $value instanceof Reference) { - return $this->getServiceCall((string) $value, $value); - } elseif (is_object($value) && $value instanceof Parameter) { - return $this->getParameterCall((string) $value); - } elseif (is_object($value) || is_resource($value)) { - throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); - } - - return $value; - } - - /** - * Gets the service call. - * - * @param string $id - * @param Reference $reference - * - * @return string - */ - private function getServiceCall($id, Reference $reference = null) - { - if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) { - return sprintf('@?%s', $id); - } - - return sprintf('@%s', $id); - } - - /** - * Gets parameter call. - * - * @param string $id - * - * @return string - */ - private function getParameterCall($id) - { - return sprintf('%%%s%%', $id); - } - - /** - * Prepares parameters - * - * @param array $parameters - * - * @return array - */ - private function prepareParameters($parameters) - { - $filtered = array(); - foreach ($parameters as $key => $value) { - if (is_array($value)) { - $value = $this->prepareParameters($value); - } elseif ($value instanceof Reference) { - $value = '@'.$value; - } - - $filtered[$key] = $value; - } - - return $this->escape($filtered); - } - - /** - * Escapes arguments - * - * @param array $arguments - * - * @return array - */ - private function escape($arguments) - { - $args = array(); - foreach ($arguments as $k => $v) { - if (is_array($v)) { - $args[$k] = $this->escape($v); - } elseif (is_string($v)) { - $args[$k] = str_replace('%', '%%', $v); - } else { - $args[$k] = $v; - } - } - - return $args; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php b/core/vendor/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php deleted file mode 100644 index b633f9006c37cba8bc735a09d7ab44c91728c3f8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Extension; - -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * ConfigurationExtensionInterface is the interface implemented by container extension classes. - * - * @author Kevin Bond - */ -interface ConfigurationExtensionInterface -{ - /** - * Returns extension configuration - * - * @param array $config $config An array of configuration values - * @param ContainerBuilder $container A ContainerBuilder instance - * - * @return ConfigurationInterface|null The configuration or null - */ - function getConfiguration(array $config, ContainerBuilder $container); -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php b/core/vendor/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php deleted file mode 100644 index 726652c05e50359c031193b66a6e49f725ffeb4f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * IntrospectableContainerInterface defines additional introspection functionality - * for containers, allowing logic to be implemented based on a Container's state. - * - * @author Evan Villemez - * - */ -interface IntrospectableContainerInterface extends ContainerInterface -{ - /** - * Check for whether or not a service has been initialized. - * - * @param string $id - * - * @return Boolean true if the service has been initialized, false otherwise - * - */ - function initialized($id); - -} \ No newline at end of file diff --git a/core/vendor/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php b/core/vendor/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php deleted file mode 100644 index fa2456572a9a720bcd4f5a343cc366b16046f0e5..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * 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; -use Symfony\Component\Config\Loader\Loader; - -/** - * ClosureLoader loads service definitions from a PHP closure. - * - * The Closure has access to the container as its first argument. - * - * @author Fabien Potencier - */ -class ClosureLoader extends Loader -{ - private $container; - - /** - * Constructor. - * - * @param ContainerBuilder $container A ContainerBuilder instance - */ - public function __construct(ContainerBuilder $container) - { - $this->container = $container; - } - - /** - * Loads a Closure. - * - * @param \Closure $closure The resource - * @param string $type The resource type - */ - public function load($closure, $type = null) - { - call_user_func($closure, $this->container); - } - - /** - * 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) - { - return $resource instanceof \Closure; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php b/core/vendor/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php deleted file mode 100644 index 4eabd6d51e63c3bc95a0e409c2dcb071afcaf251..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * 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\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; - -/** - * IniFileLoader loads parameters from INI files. - * - * @author Fabien Potencier - */ -class IniFileLoader extends FileLoader -{ - /** - * Loads a resource. - * - * @param mixed $file The resource - * @param string $type The resource type - * - * @throws InvalidArgumentException When ini file is not valid - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $this->container->addResource(new FileResource($path)); - - $result = parse_ini_file($path, true); - if (false === $result || array() === $result) { - throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $file)); - } - - if (isset($result['parameters']) && is_array($result['parameters'])) { - foreach ($result['parameters'] as $key => $value) { - $this->container->setParameter($key, $value); - } - } - } - - /** - * 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) - { - return is_string($resource) && 'ini' === pathinfo($resource, PATHINFO_EXTENSION); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/core/vendor/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php deleted file mode 100644 index 98fb2dabf9255bba321113d5023a49955fbb00e4..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ /dev/null @@ -1,505 +0,0 @@ - - * - * 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\DefinitionDecorator; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Alias; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\SimpleXMLElement; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -/** - * XmlFileLoader loads XML files service definitions. - * - * @author Fabien Potencier - */ -class XmlFileLoader extends FileLoader -{ - /** - * Loads an XML file. - * - * @param mixed $file The resource - * @param string $type The resource type - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $xml = $this->parseFile($path); - $xml->registerXPathNamespace('container', 'http://symfony.com/schema/dic/services'); - - $this->container->addResource(new FileResource($path)); - - // anonymous services - $xml = $this->processAnonymousServices($xml, $path); - - // imports - $this->parseImports($xml, $path); - - // parameters - $this->parseParameters($xml, $path); - - // extensions - $this->loadFromExtensions($xml); - - // services - $this->parseDefinitions($xml, $path); - } - - /** - * 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) - { - return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION); - } - - /** - * Parses parameters - * - * @param SimpleXMLElement $xml - * @param string $file - */ - private function parseParameters(SimpleXMLElement $xml, $file) - { - if (!$xml->parameters) { - return; - } - - $this->container->getParameterBag()->add($xml->parameters->getArgumentsAsPhp('parameter')); - } - - /** - * Parses imports - * - * @param SimpleXMLElement $xml - * @param string $file - */ - private function parseImports(SimpleXMLElement $xml, $file) - { - if (false === $imports = $xml->xpath('//container:imports/container:import')) { - return; - } - - foreach ($imports as $import) { - $this->setCurrentDir(dirname($file)); - $this->import((string) $import['resource'], null, (Boolean) $import->getAttributeAsPhp('ignore-errors'), $file); - } - } - - /** - * Parses multiple definitions - * - * @param SimpleXMLElement $xml - * @param string $file - */ - private function parseDefinitions(SimpleXMLElement $xml, $file) - { - if (false === $services = $xml->xpath('//container:services/container:service')) { - return; - } - - foreach ($services as $service) { - $this->parseDefinition((string) $service['id'], $service, $file); - } - } - - /** - * Parses an individual Definition - * - * @param string $id - * @param SimpleXMLElement $service - * @param string $file - */ - private function parseDefinition($id, $service, $file) - { - if ((string) $service['alias']) { - $public = true; - if (isset($service['public'])) { - $public = $service->getAttributeAsPhp('public'); - } - $this->container->setAlias($id, new Alias((string) $service['alias'], $public)); - - return; - } - - if (isset($service['parent'])) { - $definition = new DefinitionDecorator((string) $service['parent']); - } else { - $definition = new Definition(); - } - - foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'abstract') as $key) { - if (isset($service[$key])) { - $method = 'set'.str_replace('-', '', $key); - $definition->$method((string) $service->getAttributeAsPhp($key)); - } - } - - if ($service->file) { - $definition->setFile((string) $service->file); - } - - $definition->setArguments($service->getArgumentsAsPhp('argument')); - $definition->setProperties($service->getArgumentsAsPhp('property')); - - if (isset($service->configurator)) { - if (isset($service->configurator['function'])) { - $definition->setConfigurator((string) $service->configurator['function']); - } else { - if (isset($service->configurator['service'])) { - $class = new Reference((string) $service->configurator['service'], ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false); - } else { - $class = (string) $service->configurator['class']; - } - - $definition->setConfigurator(array($class, (string) $service->configurator['method'])); - } - } - - foreach ($service->call as $call) { - $definition->addMethodCall((string) $call['method'], $call->getArgumentsAsPhp('argument')); - } - - foreach ($service->tag as $tag) { - $parameters = array(); - foreach ($tag->attributes() as $name => $value) { - if ('name' === $name) { - continue; - } - - $parameters[$name] = SimpleXMLElement::phpize($value); - } - - $definition->addTag((string) $tag['name'], $parameters); - } - - $this->container->setDefinition($id, $definition); - } - - /** - * Parses a XML file. - * - * @param string $file Path to a file - * - * @throws InvalidArgumentException When loading of XML file returns error - */ - private function parseFile($file) - { - $dom = new \DOMDocument(); - libxml_use_internal_errors(true); - if (!$dom->load($file, defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0)) { - throw new InvalidArgumentException(implode("\n", $this->getXmlErrors())); - } - $dom->validateOnParse = true; - $dom->normalizeDocument(); - libxml_use_internal_errors(false); - $this->validate($dom, $file); - - return simplexml_import_dom($dom, 'Symfony\\Component\\DependencyInjection\\SimpleXMLElement'); - } - - /** - * Processes anonymous services - * - * @param SimpleXMLElement $xml - * @param string $file - * - * @return array An array of anonymous services - */ - private function processAnonymousServices(SimpleXMLElement $xml, $file) - { - $definitions = array(); - $count = 0; - - // anonymous services as arguments - if (false === $nodes = $xml->xpath('//container:argument[@type="service"][not(@id)]')) { - return $xml; - } - foreach ($nodes as $node) { - // give it a unique name - $node['id'] = sprintf('%s_%d', md5($file), ++$count); - - $definitions[(string) $node['id']] = array($node->service, $file, false); - $node->service['id'] = (string) $node['id']; - } - - // anonymous services "in the wild" - if (false === $nodes = $xml->xpath('//container:services/container:service[not(@id)]')) { - return $xml; - } - foreach ($nodes as $node) { - // give it a unique name - $node['id'] = sprintf('%s_%d', md5($file), ++$count); - - $definitions[(string) $node['id']] = array($node, $file, true); - $node->service['id'] = (string) $node['id']; - } - - // resolve definitions - krsort($definitions); - foreach ($definitions as $id => $def) { - // anonymous services are always private - $def[0]['public'] = false; - - $this->parseDefinition($id, $def[0], $def[1]); - - $oNode = dom_import_simplexml($def[0]); - if (true === $def[2]) { - $nNode = new \DOMElement('_services'); - $oNode->parentNode->replaceChild($nNode, $oNode); - $nNode->setAttribute('id', $id); - } else { - $oNode->parentNode->removeChild($oNode); - } - } - - return $xml; - } - - /** - * Validates an XML document. - * - * @param DOMDocument $dom - * @param string $file - */ - private function validate(\DOMDocument $dom, $file) - { - $this->validateSchema($dom, $file); - $this->validateExtensions($dom, $file); - } - - /** - * Validates a documents XML schema. - * - * @param \DOMDocument $dom - * @param string $file - * - * @throws RuntimeException When extension references a non-existent XSD file - * @throws InvalidArgumentException When XML doesn't validate its XSD schema - */ - private function validateSchema(\DOMDocument $dom, $file) - { - $schemaLocations = array('http://symfony.com/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd')); - - if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) { - $items = preg_split('/\s+/', $element); - for ($i = 0, $nb = count($items); $i < $nb; $i += 2) { - if (!$this->container->hasExtension($items[$i])) { - continue; - } - - if (($extension = $this->container->getExtension($items[$i])) && false !== $extension->getXsdValidationBasePath()) { - $path = str_replace($extension->getNamespace(), str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]); - - if (!is_file($path)) { - throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s"', get_class($extension), $path)); - } - - $schemaLocations[$items[$i]] = $path; - } - } - } - - $tmpfiles = array(); - $imports = ''; - foreach ($schemaLocations as $namespace => $location) { - $parts = explode('/', $location); - if (0 === stripos($location, 'phar://')) { - $tmpfile = tempnam(sys_get_temp_dir(), 'sf2'); - if ($tmpfile) { - copy($location, $tmpfile); - $tmpfiles[] = $tmpfile; - $parts = explode('/', str_replace('\\', '/', $tmpfile)); - } - } - $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; - $location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts)); - - $imports .= sprintf(' '."\n", $namespace, $location); - } - - $source = << - - - -$imports - -EOF - ; - - $current = libxml_use_internal_errors(true); - $valid = $dom->schemaValidateSource($source); - foreach ($tmpfiles as $tmpfile) { - @unlink($tmpfile); - } - if (!$valid) { - throw new InvalidArgumentException(implode("\n", $this->getXmlErrors())); - } - libxml_use_internal_errors($current); - } - - /** - * Validates an extension. - * - * @param \DOMDocument $dom - * @param string $file - * - * @throws InvalidArgumentException When no extension is found corresponding to a tag - */ - private function validateExtensions(\DOMDocument $dom, $file) - { - foreach ($dom->documentElement->childNodes as $node) { - if (!$node instanceof \DOMElement || 'http://symfony.com/schema/dic/services' === $node->namespaceURI) { - continue; - } - - // can it be handled by an extension? - if (!$this->container->hasExtension($node->namespaceURI)) { - $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf( - 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', - $node->tagName, - $file, - $node->namespaceURI, - $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none' - )); - } - } - } - - /** - * Returns an array of XML errors. - * - * @return array - */ - private function getXmlErrors() - { - $errors = array(); - foreach (libxml_get_errors() as $error) { - $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', - LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', - $error->code, - trim($error->message), - $error->file ? $error->file : 'n/a', - $error->line, - $error->column - ); - } - - libxml_clear_errors(); - - return $errors; - } - - /** - * Loads from an extension. - * - * @param SimpleXMLElement $xml - */ - private function loadFromExtensions(SimpleXMLElement $xml) - { - foreach (dom_import_simplexml($xml)->childNodes as $node) { - if (!$node instanceof \DOMElement || $node->namespaceURI === 'http://symfony.com/schema/dic/services') { - continue; - } - - $values = static::convertDomElementToArray($node); - if (!is_array($values)) { - $values = array(); - } - - $this->container->loadFromExtension($node->namespaceURI, $values); - } - } - - /** - * Converts a \DomElement object to a PHP array. - * - * The following rules applies during the conversion: - * - * * Each tag is converted to a key value or an array - * if there is more than one "value" - * - * * The content of a tag is set under a "value" key (bar) - * if the tag also has some nested tags - * - * * The attributes are converted to keys () - * - * * The nested-tags are converted to keys (bar) - * - * @param \DomElement $element A \DomElement instance - * - * @return array A PHP array - */ - static public function convertDomElementToArray(\DomElement $element) - { - $empty = true; - $config = array(); - foreach ($element->attributes as $name => $node) { - $config[$name] = SimpleXMLElement::phpize($node->value); - $empty = false; - } - - $nodeValue = false; - foreach ($element->childNodes as $node) { - if ($node instanceof \DOMText) { - if (trim($node->nodeValue)) { - $nodeValue = trim($node->nodeValue); - $empty = false; - } - } elseif (!$node instanceof \DOMComment) { - if ($node instanceof \DOMElement && '_services' === $node->nodeName) { - $value = new Reference($node->getAttribute('id')); - } else { - $value = static::convertDomElementToArray($node); - } - - $key = $node->localName; - if (isset($config[$key])) { - if (!is_array($config[$key]) || !is_int(key($config[$key]))) { - $config[$key] = array($config[$key]); - } - $config[$key][] = $value; - } else { - $config[$key] = $value; - } - - $empty = false; - } - } - - if (false !== $nodeValue) { - $value = SimpleXMLElement::phpize($nodeValue); - if (count($config)) { - $config['value'] = $value; - } else { - $config = $value; - } - } - - return !$empty ? $config : null; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/core/vendor/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php deleted file mode 100644 index e16321921190f65b48dbd6140023f51086f6ede4..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ /dev/null @@ -1,331 +0,0 @@ - - * - * 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\DefinitionDecorator; -use Symfony\Component\DependencyInjection\Alias; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Yaml; - -/** - * YamlFileLoader loads YAML files service definitions. - * - * The YAML format does not support anonymous services (cf. the XML loader). - * - * @author Fabien Potencier - */ -class YamlFileLoader extends FileLoader -{ - /** - * Loads a Yaml file. - * - * @param mixed $file The resource - * @param string $type The resource type - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $content = $this->loadFile($path); - - $this->container->addResource(new FileResource($path)); - - // empty file - if (null === $content) { - return; - } - - // imports - $this->parseImports($content, $file); - - // parameters - if (isset($content['parameters'])) { - foreach ($content['parameters'] as $key => $value) { - $this->container->setParameter($key, $this->resolveServices($value)); - } - } - - // extensions - $this->loadFromExtensions($content); - - // services - $this->parseDefinitions($content, $file); - } - - /** - * 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) - { - return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION); - } - - /** - * Parses all imports - * - * @param array $content - * @param string $file - */ - private function parseImports($content, $file) - { - if (!isset($content['imports'])) { - return; - } - - foreach ($content['imports'] as $import) { - $this->setCurrentDir(dirname($file)); - $this->import($import['resource'], null, isset($import['ignore_errors']) ? (Boolean) $import['ignore_errors'] : false, $file); - } - } - - /** - * Parses definitions - * - * @param array $content - * @param string $file - */ - private function parseDefinitions($content, $file) - { - if (!isset($content['services'])) { - return; - } - - foreach ($content['services'] as $id => $service) { - $this->parseDefinition($id, $service, $file); - } - } - - /** - * Parses a definition. - * - * @param string $id - * @param array $service - * @param string $file - */ - private function parseDefinition($id, $service, $file) - { - if (is_string($service) && 0 === strpos($service, '@')) { - $this->container->setAlias($id, substr($service, 1)); - - return; - } elseif (isset($service['alias'])) { - $public = !array_key_exists('public', $service) || (Boolean) $service['public']; - $this->container->setAlias($id, new Alias($service['alias'], $public)); - - return; - } - - if (isset($service['parent'])) { - $definition = new DefinitionDecorator($service['parent']); - } else { - $definition = new Definition(); - } - - if (isset($service['class'])) { - $definition->setClass($service['class']); - } - - if (isset($service['scope'])) { - $definition->setScope($service['scope']); - } - - if (isset($service['synthetic'])) { - $definition->setSynthetic($service['synthetic']); - } - - if (isset($service['public'])) { - $definition->setPublic($service['public']); - } - - if (isset($service['abstract'])) { - $definition->setAbstract($service['abstract']); - } - - if (isset($service['factory_class'])) { - $definition->setFactoryClass($service['factory_class']); - } - - if (isset($service['factory_method'])) { - $definition->setFactoryMethod($service['factory_method']); - } - - if (isset($service['factory_service'])) { - $definition->setFactoryService($service['factory_service']); - } - - if (isset($service['file'])) { - $definition->setFile($service['file']); - } - - if (isset($service['arguments'])) { - $definition->setArguments($this->resolveServices($service['arguments'])); - } - - if (isset($service['properties'])) { - $definition->setProperties($this->resolveServices($service['properties'])); - } - - if (isset($service['configurator'])) { - if (is_string($service['configurator'])) { - $definition->setConfigurator($service['configurator']); - } else { - $definition->setConfigurator(array($this->resolveServices($service['configurator'][0]), $service['configurator'][1])); - } - } - - if (isset($service['calls'])) { - foreach ($service['calls'] as $call) { - $args = isset($call[1]) ? $this->resolveServices($call[1]) : array(); - $definition->addMethodCall($call[0], $args); - } - } - - if (isset($service['tags'])) { - if (!is_array($service['tags'])) { - throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s.', $id, $file)); - } - - foreach ($service['tags'] as $tag) { - if (!isset($tag['name'])) { - throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file)); - } - - $name = $tag['name']; - unset($tag['name']); - - foreach ($tag as $attribute => $value) { - if (!is_scalar($value)) { - throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s" in %s.', $id, $name, $file)); - } - } - - $definition->addTag($name, $tag); - } - } - - $this->container->setDefinition($id, $definition); - } - - /** - * Loads a YAML file. - * - * @param string $file - * - * @return array The file content - */ - private function loadFile($file) - { - return $this->validate(Yaml::parse($file), $file); - } - - /** - * Validates a YAML file. - * - * @param mixed $content - * @param string $file - * - * @return array - * - * @throws InvalidArgumentException When service file is not valid - */ - private function validate($content, $file) - { - if (null === $content) { - return $content; - } - - if (!is_array($content)) { - throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); - } - - foreach (array_keys($content) as $namespace) { - if (in_array($namespace, array('imports', 'parameters', 'services'))) { - continue; - } - - if (!$this->container->hasExtension($namespace)) { - $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf( - 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', - $namespace, - $file, - $namespace, - $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none' - )); - } - } - - return $content; - } - - /** - * Resolves services. - * - * @param string $value - * - * @return Reference - */ - private function resolveServices($value) - { - if (is_array($value)) { - $value = array_map(array($this, 'resolveServices'), $value); - } elseif (is_string($value) && 0 === strpos($value, '@')) { - if (0 === strpos($value, '@?')) { - $value = substr($value, 2); - $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; - } else { - $value = substr($value, 1); - $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - } - - if ('=' === substr($value, -1)) { - $value = substr($value, 0, -1); - $strict = false; - } else { - $strict = true; - } - - $value = new Reference($value, $invalidBehavior, $strict); - } - - return $value; - } - - /** - * Loads from Extensions - * - * @param array $content - */ - private function loadFromExtensions($content) - { - foreach ($content as $namespace => $values) { - if (in_array($namespace, array('imports', 'parameters', 'services'))) { - continue; - } - - if (!is_array($values)) { - $values = array(); - } - - $this->container->loadFromExtension($namespace, $values); - } - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/core/vendor/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd deleted file mode 100644 index 7d46e8caa6e887b55ee3571550495b75127b9717..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/vendor/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/core/vendor/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php deleted file mode 100644 index dade5770f8f88d3466d5a35d50f6823f3d03ceae..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ /dev/null @@ -1,261 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\ParameterBag; - -use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; -use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -/** - * Holds parameters. - * - * @author Fabien Potencier - * - * @api - */ -class ParameterBag implements ParameterBagInterface -{ - protected $parameters; - protected $resolved; - - /** - * Constructor. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function __construct(array $parameters = array()) - { - $this->parameters = array(); - $this->add($parameters); - $this->resolved = false; - } - - /** - * Clears all parameters. - * - * @api - */ - public function clear() - { - $this->parameters = array(); - } - - /** - * Adds parameters to the service container parameters. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function add(array $parameters) - { - foreach ($parameters as $key => $value) { - $this->parameters[strtolower($key)] = $value; - } - } - - /** - * Gets the service container parameters. - * - * @return array An array of parameters - * - * @api - */ - public function all() - { - return $this->parameters; - } - - /** - * Gets a service container parameter. - * - * @param string $name The parameter name - * - * @return mixed The parameter value - * - * @throws ParameterNotFoundException if the parameter is not defined - * - * @api - */ - public function get($name) - { - $name = strtolower($name); - - if (!array_key_exists($name, $this->parameters)) { - throw new ParameterNotFoundException($name); - } - - return $this->parameters[$name]; - } - - /** - * Sets a service container parameter. - * - * @param string $name The parameter name - * @param mixed $value The parameter value - * - * @api - */ - public function set($name, $value) - { - $this->parameters[strtolower($name)] = $value; - } - - /** - * Returns true if a parameter name is defined. - * - * @param string $name The parameter name - * - * @return Boolean true if the parameter name is defined, false otherwise - * - * @api - */ - public function has($name) - { - return array_key_exists(strtolower($name), $this->parameters); - } - - /** - * Replaces parameter placeholders (%name%) by their values for all parameters. - */ - public function resolve() - { - if ($this->resolved) { - return; - } - - $parameters = array(); - foreach ($this->parameters as $key => $value) { - try { - $value = $this->resolveValue($value); - $parameters[$key] = $this->unescapeValue($value); - } catch (ParameterNotFoundException $e) { - $e->setSourceKey($key); - - throw $e; - } - } - - $this->parameters = $parameters; - $this->resolved = true; - } - - /** - * Replaces parameter placeholders (%name%) by their values. - * - * @param mixed $value A value - * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) - * - * @return mixed The resolved value - * - * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist - * @throws ParameterCircularReferenceException if a circular reference if detected - * @throws RuntimeException when a given parameter has a type problem. - */ - public function resolveValue($value, array $resolving = array()) - { - if (is_array($value)) { - $args = array(); - foreach ($value as $k => $v) { - $args[$this->resolveValue($k, $resolving)] = $this->resolveValue($v, $resolving); - } - - return $args; - } - - if (!is_string($value)) { - return $value; - } - - return $this->resolveString($value, $resolving); - } - - /** - * Resolves parameters inside a string - * - * @param string $value The string to resolve - * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) - * - * @return string The resolved string - * - * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist - * @throws ParameterCircularReferenceException if a circular reference if detected - * @throws RuntimeException when a given parameter has a type problem. - */ - public function resolveString($value, array $resolving = array()) - { - // we do this to deal with non string values (Boolean, integer, ...) - // as the preg_replace_callback throw an exception when trying - // a non-string in a parameter value - if (preg_match('/^%([^%\s]+)%$/', $value, $match)) { - $key = strtolower($match[1]); - - if (isset($resolving[$key])) { - throw new ParameterCircularReferenceException(array_keys($resolving)); - } - - $resolving[$key] = true; - - return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving); - } - - $self = $this; - - return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($self, $resolving, $value) { - // skip %% - if (!isset($match[1])) { - return '%%'; - } - - $key = strtolower($match[1]); - if (isset($resolving[$key])) { - throw new ParameterCircularReferenceException(array_keys($resolving)); - } - - $resolved = $self->get($key); - - if (!is_string($resolved) && !is_numeric($resolved)) { - throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, gettype($resolved), $value)); - } - - $resolved = (string) $resolved; - $resolving[$key] = true; - - return $self->isResolved() ? $resolved : $self->resolveString($resolved, $resolving); - }, $value); - } - - public function isResolved() - { - return $this->resolved; - } - - private function unescapeValue($value) - { - if (is_string($value)) { - return str_replace('%%', '%', $value); - } - - if (is_array($value)) { - $result = array(); - foreach ($value as $k => $v) { - $result[$k] = $this->unescapeValue($v); - } - - return $result; - } - - return $value; - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/core/vendor/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php deleted file mode 100644 index b530d5dc66aa84ae2ace9a0e38974222fd66ad2c..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\ParameterBag; - -use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; - -/** - * ParameterBagInterface. - * - * @author Fabien Potencier - * - * @api - */ -interface ParameterBagInterface -{ - /** - * Clears all parameters. - * - * @api - */ - function clear(); - - /** - * Adds parameters to the service container parameters. - * - * @param array $parameters An array of parameters - * - * @api - */ - function add(array $parameters); - - /** - * Gets the service container parameters. - * - * @return array An array of parameters - * - * @api - */ - function all(); - - /** - * Gets a service container parameter. - * - * @param string $name The parameter name - * - * @return mixed The parameter value - * - * @throws ParameterNotFoundException if the parameter is not defined - * - * @api - */ - function get($name); - - /** - * Sets a service container parameter. - * - * @param string $name The parameter name - * @param mixed $value The parameter value - * - * @api - */ - function set($name, $value); - - /** - * Returns true if a parameter name is defined. - * - * @param string $name The parameter name - * - * @return Boolean true if the parameter name is defined, false otherwise - * - * @api - */ - function has($name); - - /** - * Replaces parameter placeholders (%name%) by their values for all parameters. - */ - function resolve(); - - /** - * Replaces parameter placeholders (%name%) by their values. - * - * @param mixed $value A value - * - * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist - */ - function resolveValue($value); -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/README.md b/core/vendor/Symfony/Component/DependencyInjection/README.md deleted file mode 100644 index 06ebe3dfa2ba31f7491a141332c6d885d929149f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/README.md +++ /dev/null @@ -1,78 +0,0 @@ -DependencyInjection Component -============================= - -DependencyInjection manages your services via a robust and flexible Dependency -Injection Container. - -Here is a simple example that shows how to register services and parameters: - - use Symfony\Component\DependencyInjection\ContainerBuilder; - use Symfony\Component\DependencyInjection\Reference; - - $sc = new ContainerBuilder(); - $sc - ->register('foo', '%foo.class%') - ->addArgument(new Reference('bar')) - ; - $sc->setParameter('foo.class', 'Foo'); - - $sc->get('foo'); - -Method Calls (Setter Injection): - - $sc = new ContainerBuilder(); - - $sc - ->register('bar', '%bar.class%') - ->addMethodCall('setFoo', array(new Reference('foo'))) - ; - $sc->setParameter('bar.class', 'Bar'); - - $sc->get('bar'); - -Factory Class: - -If your service is retrieved by calling a static method: - - $sc = new ContainerBuilder(); - - $sc - ->register('bar', '%bar.class%') - ->setFactoryClass('%bar.class%') - ->setFactoryMethod('getInstance') - ->addArgument('Aarrg!!!') - ; - $sc->setParameter('bar.class', 'Bar'); - - $sc->get('bar'); - -File Include: - -For some services, especially those that are difficult or impossible to -autoload, you may need the container to include a file before -instantiating your class. - - $sc = new ContainerBuilder(); - - $sc - ->register('bar', '%bar.class%') - ->setFile('/path/to/file') - ->addArgument('Aarrg!!!') - ; - $sc->setParameter('bar.class', 'Bar'); - - $sc->get('bar'); - -Resources ---------- - -You can run the unit tests with the following command: - - phpunit -c src/Symfony/Component/DependencyInjection/ - -If you also want to run the unit tests that depend on other Symfony -Components, declare the following environment variables before running -PHPUnit: - - export SYMFONY_CONFIG=../path/to/Config - export SYMFONY_YAML=../path/to/Yaml diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php b/core/vendor/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php deleted file mode 100644 index 52577817a981e16eea61131233e0c751dc68fcf8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Tests\Compiler; - -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Compiler\Compiler; -use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; -use Symfony\Component\DependencyInjection\Compiler\RepeatedPass; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -class AnalyzeServiceReferencesPassTest extends \PHPUnit_Framework_TestCase -{ - public function testProcess() - { - $container = new ContainerBuilder(); - - $a = $container - ->register('a') - ->addArgument($ref1 = new Reference('b')) - ; - - $b = $container - ->register('b') - ->addMethodCall('setA', array($ref2 = new Reference('a'))) - ; - - $c = $container - ->register('c') - ->addArgument($ref3 = new Reference('a')) - ->addArgument($ref4 = new Reference('b')) - ; - - $d = $container - ->register('d') - ->setProperty('foo', $ref5 = new Reference('b')) - ; - - $graph = $this->process($container); - - $this->assertCount(3, $edges = $graph->getNode('b')->getInEdges()); - $this->assertSame($ref1, $edges[0]->getValue()); - $this->assertSame($ref4, $edges[1]->getValue()); - $this->assertSame($ref5, $edges[2]->getValue()); - } - - public function testProcessDetectsReferencesFromInlinedDefinitions() - { - $container = new ContainerBuilder(); - - $container - ->register('a') - ; - - $container - ->register('b') - ->addArgument(new Definition(null, array($ref = new Reference('a')))) - ; - - $graph = $this->process($container); - - $this->assertCount(1, $refs = $graph->getNode('a')->getInEdges()); - $this->assertSame($ref, $refs[0]->getValue()); - } - - public function testProcessDoesNotSaveDuplicateReferences() - { - $container = new ContainerBuilder(); - - $container - ->register('a') - ; - $container - ->register('b') - ->addArgument(new Definition(null, array($ref1 = new Reference('a')))) - ->addArgument(new Definition(null, array($ref2 = new Reference('a')))) - ; - - $graph = $this->process($container); - - $this->assertCount(2, $graph->getNode('a')->getInEdges()); - } - - protected function process(ContainerBuilder $container) - { - $pass = new RepeatedPass(array(new AnalyzeServiceReferencesPass())); - $pass->process($container); - - return $container->getCompiler()->getServiceReferenceGraph(); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php deleted file mode 100644 index 5ab7bab8e9005c8bb2a082c52e6e42f04bea820a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ /dev/null @@ -1,159 +0,0 @@ -getDefaultParameters())); - } - - /** - * Gets the 'bar' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return FooClass A FooClass instance. - */ - protected function getBarService() - { - $this->services['bar'] = $instance = new \FooClass('foo', $this->get('foo.baz'), $this->getParameter('foo_bar')); - - $this->get('foo.baz')->configure($instance); - - return $instance; - } - - /** - * Gets the 'factory_service' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return Object An instance returned by foo.baz::getInstance(). - */ - protected function getFactoryServiceService() - { - return $this->services['factory_service'] = $this->get('foo.baz')->getInstance(); - } - - /** - * Gets the 'foo' service. - * - * @return FooClass A FooClass instance. - */ - protected function getFooService() - { - $a = $this->get('foo.baz'); - - $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo'), 'bar' => $this->getParameter('foo')), true, $this); - - $instance->setBar($this->get('bar')); - $instance->initialize(); - $instance->foo = 'bar'; - $instance->moo = $a; - sc_configure($instance); - - return $instance; - } - - /** - * Gets the 'foo.baz' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return Object A %baz_class% instance. - */ - protected function getFoo_BazService() - { - $this->services['foo.baz'] = $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance')); - - call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance); - - return $instance; - } - - /** - * Gets the 'foo_bar' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return Object A %foo_class% instance. - */ - protected function getFooBarService() - { - $class = $this->getParameter('foo_class'); - return $this->services['foo_bar'] = new $class(); - } - - /** - * Gets the 'method_call1' service. - * - * This service is shared. - * This method always returns the same instance of the service. - * - * @return FooClass A FooClass instance. - */ - protected function getMethodCall1Service() - { - require_once '%path%foo.php'; - - $this->services['method_call1'] = $instance = new \FooClass(); - - $instance->setBar($this->get('foo')); - $instance->setBar($this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - if ($this->has('foo3')) { - $instance->setBar($this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - } - if ($this->has('foobaz')) { - $instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)); - } - - return $instance; - } - - /** - * Gets the alias_for_foo service alias. - * - * @return FooClass An instance of the foo service - */ - protected function getAliasForFooService() - { - return $this->get('foo'); - } - - /** - * Gets the default parameters. - * - * @return array An array of the default parameters - */ - protected function getDefaultParameters() - { - return array( - 'baz_class' => 'BazClass', - 'foo_class' => 'FooClass', - 'foo' => 'bar', - ); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml b/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml deleted file mode 100644 index 787b4ef7f61e6dce366f647fce3cf28924eb6516..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml deleted file mode 100644 index 2aa47a5d9957efd424a5f6f0c841c85308371d01..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ /dev/null @@ -1,43 +0,0 @@ -parameters: - baz_class: BazClass - foo_class: FooClass - foo: bar - -services: - foo: - class: FooClass - tags: - - { name: foo, foo: foo } - - { name: foo, bar: bar } - factory_method: getInstance - arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', bar: '%foo%' }, true, '@service_container'] - properties: { foo: bar, moo: '@foo.baz' } - calls: - - [setBar, ['@bar']] - - [initialize, { }] - - scope: prototype - configurator: sc_configure - bar: - class: FooClass - arguments: [foo, '@foo.baz', '%foo_bar%'] - configurator: ['@foo.baz', configure] - foo.baz: - class: %baz_class% - factory_method: getInstance - configurator: ['%baz_class%', configureStatic1] - foo_bar: - class: %foo_class% - method_call1: - class: FooClass - file: %path%foo.php - calls: - - [setBar, ['@foo']] - - [setBar, ['@?foo2']] - - [setBar, ['@?foo3']] - - [setBar, ['@?foobaz']] - - factory_service: - factory_method: getInstance - factory_service: foo.baz - alias_for_foo: @foo diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php b/core/vendor/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php deleted file mode 100644 index 85f02a2b8f6b5bb6e403050ced59dd8a6a10cbd9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Tests\Loader; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; - -class ClosureLoaderTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - - /** - * @covers Symfony\Component\DependencyInjection\Loader\ClosureLoader::supports - */ - public function testSupports() - { - $loader = new ClosureLoader(new ContainerBuilder()); - - $this->assertTrue($loader->supports(function ($container) {}), '->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\ClosureLoader::load - */ - public function testLoad() - { - $loader = new ClosureLoader($container = new ContainerBuilder()); - - $loader->load(function ($container) - { - $container->setParameter('foo', 'foo'); - }); - - $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a \Closure resource'); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/core/vendor/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php deleted file mode 100644 index 12fa7183593600d597934e2964d2b873663b2f24..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ /dev/null @@ -1,320 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Tests\Loader; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\Config\Loader\Loader; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\Loader\IniFileLoader; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\FileLocator; - -class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase -{ - static protected $fixturesPath; - - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - - static public function setUpBeforeClass() - { - self::$fixturesPath = realpath(__DIR__.'/../Fixtures/'); - require_once self::$fixturesPath.'/includes/foo.php'; - require_once self::$fixturesPath.'/includes/ProjectExtension.php'; - require_once self::$fixturesPath.'/includes/ProjectWithXsdExtension.php'; - } - - public function testLoad() - { - $loader = new XmlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini')); - - try { - $loader->load('foo.xml'); - $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist'); - $this->assertStringStartsWith('The file "foo.xml" does not exist (in:', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist'); - } - } - - public function testParseFile() - { - $loader = new XmlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini')); - $r = new \ReflectionObject($loader); - $m = $r->getMethod('parseFile'); - $m->setAccessible(true); - - try { - $m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini'); - $this->fail('->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); - $this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); - } - - $loader = new XmlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/xml')); - - try { - $m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml'); - $this->fail('->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); - $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); - } - - $xml = $m->invoke($loader, self::$fixturesPath.'/xml/services1.xml'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', get_class($xml), '->parseFile() returns an SimpleXMLElement object'); - } - - public function testLoadParameters() - { - $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - $loader->load('services2.xml'); - - $actual = $container->getParameterBag()->all(); - $expected = array('a string', 'foo' => 'bar', 'values' => array(0, 'integer' => 4, 100 => null, 'true', true, false, 'on', 'off', 'float' => 1.3, 1000.3, 'a string', array('foo', 'bar')), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value')); - - $this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones'); - } - - public function testLoadImports() - { - $container = new ContainerBuilder(); - $resolver = new LoaderResolver(array( - new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')), - new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')), - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')), - )); - $loader->setResolver($resolver); - $loader->load('services4.xml'); - - $actual = $container->getParameterBag()->all(); - $expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true); - - $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); - - // Bad import throws no exception due to ignore_errors value. - $loader->load('services4_bad_import.xml'); - } - - public function testLoadAnonymousServices() - { - $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - $loader->load('services5.xml'); - $services = $container->getDefinitions(); - $this->assertEquals(3, count($services), '->load() attributes unique ids to anonymous services'); - $args = $services['foo']->getArguments(); - $this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services'); - $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); - $inner = $services[(string) $args[0]]; - $this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); - - $args = $inner->getArguments(); - $this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services'); - $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); - $inner = $services[(string) $args[0]]; - $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); - } - - public function testLoadServices() - { - $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - $loader->load('services6.xml'); - $services = $container->getDefinitions(); - $this->assertTrue(isset($services['foo']), '->load() parses elements'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts element to Definition instances'); - $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); - $this->assertEquals('container', $services['scope.container']->getScope()); - $this->assertEquals('custom', $services['scope.custom']->getScope()); - $this->assertEquals('prototype', $services['scope.prototype']->getScope()); - $this->assertEquals('getInstance', $services['constructor']->getFactoryMethod(), '->load() parses the factory-method attribute'); - $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); - $this->assertEquals(array('foo', new Reference('foo'), array(true, false)), $services['arguments']->getArguments(), '->load() parses the argument tags'); - $this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag'); - $this->assertEquals(array(new Reference('baz', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag'); - $this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag'); - $this->assertEquals(array(array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); - $this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag'); - $this->assertNull($services['factory_service']->getClass()); - $this->assertEquals('getInstance', $services['factory_service']->getFactoryMethod()); - $this->assertEquals('baz_factory', $services['factory_service']->getFactoryService()); - - $aliases = $container->getAliases(); - $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses elements'); - $this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases'); - $this->assertTrue($aliases['alias_for_foo']->isPublic()); - $this->assertTrue(isset($aliases['another_alias_for_foo'])); - $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); - $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); - } - - public function testConvertDomElementToArray() - { - $doc = new \DOMDocument("1.0"); - $doc->loadXML('bar'); - $this->assertEquals('bar', XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - - $doc = new \DOMDocument("1.0"); - $doc->loadXML(''); - $this->assertEquals(array('foo' => 'bar'), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - - $doc = new \DOMDocument("1.0"); - $doc->loadXML('bar'); - $this->assertEquals(array('foo' => 'bar'), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - - $doc = new \DOMDocument("1.0"); - $doc->loadXML('barbar'); - $this->assertEquals(array('foo' => array('value' => 'bar', 'foo' => 'bar')), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - - $doc = new \DOMDocument("1.0"); - $doc->loadXML(''); - $this->assertEquals(array('foo' => null), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - - $doc = new \DOMDocument("1.0"); - $doc->loadXML(''); - $this->assertEquals(array('foo' => null), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - - $doc = new \DOMDocument("1.0"); - $doc->loadXML(''); - $this->assertEquals(array('foo' => array(array('foo' => 'bar'), array('foo' => 'bar'))), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array'); - } - - public function testExtensions() - { - $container = new ContainerBuilder(); - $container->registerExtension(new \ProjectExtension()); - $container->registerExtension(new \ProjectWithXsdExtension()); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - - // extension without an XSD - $loader->load('extensions/services1.xml'); - $container->compile(); - $services = $container->getDefinitions(); - $parameters = $container->getParameterBag()->all(); - - $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); - $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); - - $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements'); - $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements'); - - // extension with an XSD - $container = new ContainerBuilder(); - $container->registerExtension(new \ProjectExtension()); - $container->registerExtension(new \ProjectWithXsdExtension()); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - $loader->load('extensions/services2.xml'); - $container->compile(); - $services = $container->getDefinitions(); - $parameters = $container->getParameterBag()->all(); - - $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); - $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); - - $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements'); - $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements'); - - $container = new ContainerBuilder(); - $container->registerExtension(new \ProjectExtension()); - $container->registerExtension(new \ProjectWithXsdExtension()); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - - // extension with an XSD (does not validate) - try { - $loader->load('extensions/services3.xml'); - $this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); - $this->assertRegexp('/The attribute \'bar\' is not allowed/', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); - } - - // non-registered extension - try { - $loader->load('extensions/services4.xml'); - $this->fail('->load() throws an InvalidArgumentException if the tag is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid'); - $this->assertStringStartsWith('There is no extension able to load the configuration for "project:bar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid'); - } - } - - public function testExtensionInPhar() - { - if (extension_loaded('suhosin') && false === strpos(ini_get('suhosin.executor.include.whitelist'), 'phar')) { - $this->markTestSkipped('To run this test, add "phar" to the "suhosin.executor.include.whitelist" settings in your php.ini file.'); - } - - require_once self::$fixturesPath.'/includes/ProjectWithXsdExtensionInPhar.phar'; - - // extension with an XSD in PHAR archive - $container = new ContainerBuilder(); - $container->registerExtension(new \ProjectWithXsdExtensionInPhar()); - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); - $loader->load('extensions/services6.xml'); - - // extension with an XSD in PHAR archive (does not validate) - try { - $loader->load('extensions/services7.xml'); - $this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); - $this->assertRegexp('/The attribute \'bar\' is not allowed/', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); - } - } - - /** - * @covers Symfony\Component\DependencyInjection\Loader\XmlFileLoader::supports - */ - public function testSupports() - { - $loader = new XmlFileLoader(new ContainerBuilder(), new 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'); - } - - public function testNoNamingConflictsForAnonymousServices() - { - $container = new ContainerBuilder(); - - $loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension1')); - $loader1->load('services.xml'); - $services = $container->getDefinitions(); - $this->assertEquals(2, count($services), '->load() attributes unique ids to anonymous services'); - $loader2 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension2')); - $loader2->load('services.xml'); - $services = $container->getDefinitions(); - $this->assertEquals(4, count($services), '->load() attributes unique ids to anonymous services'); - - $services = $container->getDefinitions(); - $args1 = $services['extension1.foo']->getArguments(); - $inner1 = $services[(string) $args1[0]]; - $this->assertEquals('BarClass1', $inner1->getClass(), '->load() uses the same configuration as for the anonymous ones'); - $args2 = $services['extension2.foo']->getArguments(); - $inner2 = $services[(string) $args2[0]]; - $this->assertEquals('BarClass2', $inner2->getClass(), '->load() uses the same configuration as for the anonymous ones'); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/core/vendor/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php deleted file mode 100644 index 5f5f265baaba8d9e74820383a82c708fa4696d94..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ /dev/null @@ -1,215 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Tests\ParameterBag; - -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; -use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -class ParameterBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::__construct - */ - public function testConstructor() - { - $bag = new ParameterBag($parameters = array( - 'foo' => 'foo', - 'bar' => 'bar', - )); - $this->assertEquals($parameters, $bag->all(), '__construct() takes an array of parameters as its first argument'); - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::clear - */ - public function testClear() - { - $bag = new ParameterBag($parameters = array( - 'foo' => 'foo', - 'bar' => 'bar', - )); - $bag->clear(); - $this->assertEquals(array(), $bag->all(), '->clear() removes all parameters'); - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::get - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::set - */ - public function testGetSet() - { - $bag = new ParameterBag(array('foo' => 'bar')); - $bag->set('bar', 'foo'); - $this->assertEquals('foo', $bag->get('bar'), '->set() sets the value of a new parameter'); - - $bag->set('foo', 'baz'); - $this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter'); - - $bag->set('Foo', 'baz1'); - $this->assertEquals('baz1', $bag->get('foo'), '->set() converts the key to lowercase'); - $this->assertEquals('baz1', $bag->get('FOO'), '->get() converts the key to lowercase'); - - try { - $bag->get('baba'); - $this->fail('->get() throws an \InvalidArgumentException if the key does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws an \InvalidArgumentException if the key does not exist'); - $this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->get() throws an \InvalidArgumentException if the key does not exist'); - } - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::has - */ - public function testHas() - { - $bag = new ParameterBag(array('foo' => 'bar')); - $this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined'); - $this->assertTrue($bag->has('Foo'), '->has() converts the key to lowercase'); - $this->assertFalse($bag->has('bar'), '->has() returns false if a parameter is not defined'); - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolveValue - */ - public function testResolveValue() - { - $bag = new ParameterBag(array()); - $this->assertEquals('foo', $bag->resolveValue('foo'), '->resolveValue() returns its argument unmodified if no placeholders are found'); - - $bag = new ParameterBag(array('foo' => 'bar')); - $this->assertEquals('I\'m a bar', $bag->resolveValue('I\'m a %foo%'), '->resolveValue() replaces placeholders by their values'); - $this->assertEquals(array('bar' => 'bar'), $bag->resolveValue(array('%foo%' => '%foo%')), '->resolveValue() replaces placeholders in keys and values of arrays'); - $this->assertEquals(array('bar' => array('bar' => array('bar' => 'bar'))), $bag->resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%')))), '->resolveValue() replaces placeholders in nested arrays'); - $this->assertEquals('I\'m a %%foo%%', $bag->resolveValue('I\'m a %%foo%%'), '->resolveValue() supports % escaping by doubling it'); - $this->assertEquals('I\'m a bar %%foo bar', $bag->resolveValue('I\'m a %foo% %%foo %foo%'), '->resolveValue() supports % escaping by doubling it'); - $this->assertEquals(array('foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar'))), $bag->resolveValue(array('foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar')))), '->resolveValue() supports % escaping by doubling it'); - - $bag = new ParameterBag(array('foo' => true)); - $this->assertTrue($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); - $bag = new ParameterBag(array('foo' => null)); - $this->assertNull($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); - - $bag = new ParameterBag(array('foo' => 'bar', 'baz' => '%%%foo% %foo%%% %%foo%% %%%foo%%%')); - $this->assertEquals('%%bar bar%% %%foo%% %%bar%%', $bag->resolveValue('%baz%'), '->resolveValue() replaces params placed besides escaped %'); - - $bag = new ParameterBag(array('baz' => '%%s?%%s')); - $this->assertEquals('%%s?%%s', $bag->resolveValue('%baz%'), '->resolveValue() is not replacing greedily'); - - $bag = new ParameterBag(array()); - try { - $bag->resolveValue('%foobar%'); - $this->fail('->resolveValue() throws an InvalidArgumentException if a placeholder references a non-existent parameter'); - } catch (ParameterNotFoundException $e) { - $this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); - } - - try { - $bag->resolveValue('foo %foobar% bar'); - $this->fail('->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); - } catch (ParameterNotFoundException $e) { - $this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); - } - - $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => array())); - try { - $bag->resolveValue('%foo%'); - $this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); - } catch (RuntimeException $e) { - $this->assertEquals('A string value must be composed of strings and/or numbers, but found parameter "bar" of type array inside string value "a %bar%".', $e->getMessage(), '->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); - } - - $bag = new ParameterBag(array('foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%')); - try { - $bag->resolveValue('%foo%'); - $this->fail('->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); - } catch (ParameterCircularReferenceException $e) { - $this->assertEquals('Circular reference detected for parameter "foo" ("foo" > "bar" > "foobar" > "foo").', $e->getMessage(), '->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); - } - - $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => 'a %foobar%', 'foobar' => 'a %foo%')); - try { - $bag->resolveValue('%foo%'); - $this->fail('->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); - } catch (ParameterCircularReferenceException $e) { - $this->assertEquals('Circular reference detected for parameter "foo" ("foo" > "bar" > "foobar" > "foo").', $e->getMessage(), '->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); - } - - $bag = new ParameterBag(array('host' => 'foo.bar', 'port' => 1337)); - $this->assertEquals('foo.bar:1337', $bag->resolveValue('%host%:%port%')); - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolve - */ - public function testResolveIndicatesWhyAParameterIsNeeded() - { - $bag = new ParameterBag(array('foo' => '%bar%')); - - try { - $bag->resolve(); - } catch (ParameterNotFoundException $e) { - $this->assertEquals('The parameter "foo" has a dependency on a non-existent parameter "bar".', $e->getMessage()); - } - - $bag = new ParameterBag(array('foo' => '%bar%')); - - try { - $bag->resolve(); - } catch (ParameterNotFoundException $e) { - $this->assertEquals('The parameter "foo" has a dependency on a non-existent parameter "bar".', $e->getMessage()); - } - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolve - */ - public function testResolveUnescapesValue() - { - $bag = new ParameterBag(array( - 'foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar')), - 'bar' => 'I\'m a %%foo%%', - )); - - $bag->resolve(); - - $this->assertEquals('I\'m a %foo%', $bag->get('bar'), '->resolveValue() supports % escaping by doubling it'); - $this->assertEquals(array('bar' => array('ding' => 'I\'m a bar %foo %bar')), $bag->get('foo'), '->resolveValue() supports % escaping by doubling it'); - } - - /** - * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolve - * @dataProvider stringsWithSpacesProvider - */ - public function testResolveStringWithSpacesReturnsString($expected, $test, $description) - { - $bag = new ParameterBag(array('foo' => 'bar')); - - try { - $this->assertEquals($expected, $bag->resolveString($test), $description); - } catch (ParameterNotFoundException $e) { - $this->fail(sprintf('%s - "%s"', $description, $expected)); - } - } - - public function stringsWithSpacesProvider() - { - return array( - array('bar', '%foo%', 'Parameters must be wrapped by %.'), - array('% foo %', '% foo %', 'Parameters should not have spaces.'), - array('{% set my_template = "foo" %}', '{% set my_template = "foo" %}', 'Twig-like strings are not parameters.'), - array('50% is less than 100%', '50% is less than 100%', 'Text between % signs is allowed, if there are spaces.'), - ); - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/Tests/bootstrap.php b/core/vendor/Symfony/Component/DependencyInjection/Tests/bootstrap.php deleted file mode 100644 index 77fe27526b6d2b80dff04fa72c4ca75b0e3d5edc..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/Tests/bootstrap.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -spl_autoload_register(function ($class) { - foreach (array( - 'SYMFONY_CONFIG' => 'Config', - 'SYMFONY_YAML' => 'Yaml', - ) as $env => $name) { - if (isset($_SERVER[$env]) && 0 === strpos(ltrim($class, '/'), 'Symfony\Component\\'.$name)) { - if (file_exists($file = $_SERVER[$env].'/'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\\'.$name)).'.php')) { - require_once $file; - } - } - } - - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\DependencyInjection')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\DependencyInjection')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/Symfony/Component/DependencyInjection/composer.json b/core/vendor/Symfony/Component/DependencyInjection/composer.json deleted file mode 100644 index adf6f1109d9856c0fa5fd18dccab56db587f4340..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "symfony/dependency-injection", - "type": "library", - "description": "Symfony DependencyInjection Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2" - }, - "suggest": { - "symfony/yaml": "self.version", - "symfony/config": "self.version" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\DependencyInjection": "" } - }, - "target-dir": "Symfony/Component/DependencyInjection", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -} diff --git a/core/vendor/Symfony/Component/DependencyInjection/phpunit.xml.dist b/core/vendor/Symfony/Component/DependencyInjection/phpunit.xml.dist deleted file mode 100644 index bb81f45c1bd05d3f97f43096ddfa6b967db4942e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/DependencyInjection/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - - - - diff --git a/core/vendor/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/vendor/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php deleted file mode 100644 index 53a0f6784ce01b776854a52574fd00625452e971..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ /dev/null @@ -1,200 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Lazily loads listeners and subscribers from the dependency injection - * container - * - * @author Fabien Potencier - * @author Bernhard Schussek - * @author Jordan Alliot - */ -class ContainerAwareEventDispatcher extends EventDispatcher -{ - /** - * The container from where services are loaded - * @var ContainerInterface - */ - private $container; - - /** - * The service IDs of the event listeners and subscribers - * @var array - */ - private $listenerIds = array(); - - /** - * The services registered as listeners - * @var array - */ - private $listeners = array(); - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * Adds a service as event listener - * - * @param string $eventName Event for which the listener is added - * @param array $callback The service ID of the listener service & the method - * name that has to be called - * @param integer $priority The higher this value, the earlier an event listener - * will be triggered in the chain. - * Defaults to 0. - */ - public function addListenerService($eventName, $callback, $priority = 0) - { - if (!is_array($callback) || 2 !== count($callback)) { - throw new \InvalidArgumentException('Expected an array("service", "method") argument'); - } - - $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority); - } - - public function removeListener($eventName, $listener) - { - $this->lazyLoad($eventName); - - if (isset($this->listeners[$eventName])) { - foreach ($this->listeners[$eventName] as $key => $l) { - foreach ($this->listenerIds[$eventName] as $i => $args) { - list($serviceId, $method, $priority) = $args; - if ($key === $serviceId.'.'.$method) { - if ($listener === array($l, $method)) { - unset($this->listeners[$eventName][$key]); - if (empty($this->listeners[$eventName])) { - unset($this->listeners[$eventName]); - } - unset($this->listenerIds[$eventName][$i]); - if (empty($this->listenerIds[$eventName])) { - unset($this->listenerIds[$eventName]); - } - } - } - } - } - } - - parent::removeListener($eventName, $listener); - } - - /** - * @see EventDispatcherInterface::hasListeners - */ - public function hasListeners($eventName = null) - { - if (null === $eventName) { - return (Boolean) count($this->listenerIds) || (Boolean) count($this->listeners); - } - - if (isset($this->listenerIds[$eventName])) { - return true; - } - - return parent::hasListeners($eventName); - } - - /** - * @see EventDispatcherInterface::getListeners - */ - public function getListeners($eventName = null) - { - if (null === $eventName) { - foreach (array_keys($this->listenerIds) as $serviceEventName) { - $this->lazyLoad($serviceEventName); - } - } else { - $this->lazyLoad($eventName); - } - - return parent::getListeners($eventName); - } - - /** - * Adds a service as event subscriber - * - * @param string $serviceId The service ID of the subscriber service - * @param string $class The service's class name (which must implement EventSubscriberInterface) - */ - public function addSubscriberService($serviceId, $class) - { - foreach ($class::getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->listenerIds[$eventName][] = array($serviceId, $params, 0); - } elseif (is_string($params[0])) { - $this->listenerIds[$eventName][] = array($serviceId, $params[0], isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * {@inheritDoc} - * - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @throws \InvalidArgumentException if the service is not defined - */ - public function dispatch($eventName, Event $event = null) - { - $this->lazyLoad($eventName); - - return parent::dispatch($eventName, $event); - } - - public function getContainer() - { - return $this->container; - } - - /** - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - */ - protected function lazyLoad($eventName) - { - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as $args) { - list($serviceId, $method, $priority) = $args; - $listener = $this->container->get($serviceId); - - $key = $serviceId.'.'.$method; - if (!isset($this->listeners[$eventName][$key])) { - $this->addListener($eventName, array($listener, $method), $priority); - } elseif ($listener !== $this->listeners[$eventName][$key]) { - parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); - $this->addListener($eventName, array($listener, $method), $priority); - } - - $this->listeners[$eventName][$key] = $listener; - } - } - } -} diff --git a/core/vendor/Symfony/Component/EventDispatcher/EventDispatcher.php b/core/vendor/Symfony/Component/EventDispatcher/EventDispatcher.php deleted file mode 100644 index b2fb51ada8779005fe339076ec6b56c240b8626d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/EventDispatcher.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * @author Fabien Potencier - * @author Jordi Boggiano - * @author Jordan Alliot - * - * @api - */ -class EventDispatcher implements EventDispatcherInterface -{ - private $listeners = array(); - private $sorted = array(); - - /** - * @see EventDispatcherInterface::dispatch - * - * @api - */ - public function dispatch($eventName, Event $event = null) - { - if (null === $event) { - $event = new Event(); - } - - $event->setDispatcher($this); - $event->setName($eventName); - - if (!isset($this->listeners[$eventName])) { - return $event; - } - - $this->doDispatch($this->getListeners($eventName), $eventName, $event); - - return $event; - } - - /** - * @see EventDispatcherInterface::getListeners - */ - public function getListeners($eventName = null) - { - if (null !== $eventName) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - - return $this->sorted[$eventName]; - } - - foreach (array_keys($this->listeners) as $eventName) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - } - - return $this->sorted; - } - - /** - * @see EventDispatcherInterface::hasListeners - */ - public function hasListeners($eventName = null) - { - return (Boolean) count($this->getListeners($eventName)); - } - - /** - * @see EventDispatcherInterface::addListener - * - * @api - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->listeners[$eventName][$priority][] = $listener; - unset($this->sorted[$eventName]); - } - - /** - * @see EventDispatcherInterface::removeListener - */ - public function removeListener($eventName, $listener) - { - if (!isset($this->listeners[$eventName])) { - return; - } - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - if (false !== ($key = array_search($listener, $listeners))) { - unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]); - } - } - } - - /** - * @see EventDispatcherInterface::addSubscriber - * - * @api - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->addListener($eventName, array($subscriber, $params)); - } elseif (is_string($params[0])) { - $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * @see EventDispatcherInterface::removeSubscriber - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_array($params) && is_array($params[0])) { - foreach ($params as $listener) { - $this->removeListener($eventName, array($subscriber, $listener[0])); - } - } else { - $this->removeListener($eventName, array($subscriber, is_string($params) ? $params : $params[0])); - } - } - } - - /** - * Triggers the listeners of an event. - * - * This method can be overridden to add functionality that is executed - * for each listener. - * - * @param array[callback] $listeners The event listeners. - * @param string $eventName The name of the event to dispatch. - * @param Event $event The event object to pass to the event handlers/listeners. - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - foreach ($listeners as $listener) { - call_user_func($listener, $event); - if ($event->isPropagationStopped()) { - break; - } - } - } - - /** - * Sorts the internal list of listeners for the given event by priority. - * - * @param string $eventName The name of the event. - */ - private function sortListeners($eventName) - { - $this->sorted[$eventName] = array(); - - if (isset($this->listeners[$eventName])) { - krsort($this->listeners[$eventName]); - $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]); - } - } -} diff --git a/core/vendor/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/core/vendor/Symfony/Component/EventDispatcher/EventDispatcherInterface.php deleted file mode 100644 index d47ee66aa201c095b3312602417ba5e34248b696..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Bernhard Schussek - * - * @api - */ -interface EventDispatcherInterface -{ - /** - * Dispatches an event to all registered listeners. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - * @param Event $event The event to pass to the event handlers/listeners. - * If not supplied, an empty Event instance is created. - * - * @return Event - * - * @api - */ - function dispatch($eventName, Event $event = null); - - /** - * Adds an event listener that listens on the specified events. - * - * @param string $eventName The event to listen on - * @param callable $listener The listener - * @param integer $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - * - * @api - */ - function addListener($eventName, $listener, $priority = 0); - - /** - * Adds an event subscriber. - * - * The subscriber is asked for all the events he is - * interested in and added as a listener for these events. - * - * @param EventSubscriberInterface $subscriber The subscriber. - * - * @api - */ - function addSubscriber(EventSubscriberInterface $subscriber); - - /** - * Removes an event listener from the specified events. - * - * @param string|array $eventName The event(s) to remove a listener from - * @param callable $listener The listener to remove - */ - function removeListener($eventName, $listener); - - /** - * Removes an event subscriber. - * - * @param EventSubscriberInterface $subscriber The subscriber - */ - function removeSubscriber(EventSubscriberInterface $subscriber); - - /** - * Gets the listeners of a specific event or all listeners. - * - * @param string $eventName The name of the event - * - * @return array The event listeners for the specified event, or all event listeners by event name - */ - function getListeners($eventName = null); - - /** - * Checks whether an event has any registered listeners. - * - * @param string $eventName The name of the event - * - * @return Boolean true if the specified event has any listeners, false otherwise - */ - function hasListeners($eventName = null); -} diff --git a/core/vendor/Symfony/Component/EventDispatcher/GenericEvent.php b/core/vendor/Symfony/Component/EventDispatcher/GenericEvent.php deleted file mode 100644 index 0e792d0e6f9f0e0d0bb64c090e6c50cdc93f132b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/GenericEvent.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event encapsulation class. - * - * Encapsulates events thus decoupling the observer from the subject they encapsulate. - * - * @author Drak - */ -class GenericEvent extends Event implements \ArrayAccess -{ - /** - * Observer pattern subject. - * - * @var mixed usually object or callable - */ - protected $subject; - - /** - * Array of arguments. - * - * @var array - */ - protected $arguments; - - /** - * Encapsulate an event with $subject, $args, and $data. - * - * @param mixed $subject The subject of the event, usually an object. - * @param array $arguments Arguments to store in the event. - */ - public function __construct($subject = null, array $arguments = array()) - { - $this->subject = $subject; - $this->arguments = $arguments; - } - - /** - * Getter for subject property. - * - * @return mixed $subject The observer subject. - */ - public function getSubject() - { - return $this->subject; - } - - /** - * Get argument by key. - * - * @param string $key Key. - * - * @throws \InvalidArgumentException If key is not found. - * - * @return mixed Contents of array key. - */ - public function getArgument($key) - { - if ($this->hasArgument($key)) { - return $this->arguments[$key]; - } - - throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName())); - } - - /** - * Add argument to event. - * - * @param string $key Argument name. - * @param mixed $value Value. - * - * @return GenericEvent - */ - public function setArgument($key, $value) - { - $this->arguments[$key] = $value; - - return $this; - } - - /** - * Getter for all arguments. - * - * @return array - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * Set args property. - * - * @param array $args Arguments. - * - * @return GenericEvent - */ - public function setArguments(array $args = array()) - { - $this->arguments = $args; - - return $this; - } - - /** - * Has argument. - * - * @param string $key Key of arguments array. - * - * @return boolean - */ - public function hasArgument($key) - { - return array_key_exists($key, $this->arguments); - } - - /** - * ArrayAccess for argument getter. - * - * @param string $key Array key. - * - * @throws \InvalidArgumentException If key does not exist in $this->args. - * - * @return mixed - */ - public function offsetGet($key) - { - return $this->getArgument($key); - } - - /** - * ArrayAccess for argument setter. - * - * @param string $key Array key to set. - * @param mixed $value Value. - * - * @return void - */ - public function offsetSet($key, $value) - { - $this->setArgument($key, $value); - } - - /** - * ArrayAccess for unset argument. - * - * @param string $key Array key. - * - * @return void - */ - public function offsetUnset($key) - { - if ($this->hasArgument($key)) { - unset($this->arguments[$key]); - } - } - - /** - * ArrayAccess has argument. - * - * @param string $key Array key. - * - * @return boolean - */ - public function offsetExists($key) - { - return $this->hasArgument($key); - } -} diff --git a/core/vendor/Symfony/Component/EventDispatcher/README.md b/core/vendor/Symfony/Component/EventDispatcher/README.md deleted file mode 100644 index 421b8c6dec3321bf5a1bbb49d5a17e385fb089c6..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/README.md +++ /dev/null @@ -1,30 +0,0 @@ -EventDispatcher Component -========================= - -EventDispatcher implements a lightweight version of the Observer design -pattern. - - use Symfony\Component\EventDispatcher\EventDispatcher; - use Symfony\Component\EventDispatcher\Event; - - $dispatcher = new EventDispatcher(); - - $dispatcher->addListener('event_name', function (Event $event) { - // ... - }); - - $dispatcher->dispatch('event_name'); - -Resources ---------- - -You can run the unit tests with the following command: - - phpunit -c src/Symfony/Component/EventDispatcher/ - -If you also want to run the unit tests that depend on other Symfony -Components, declare the following environment variables before running -PHPUnit: - - export SYMFONY_DEPENDENCY_INJECTION=../path/to/DependencyInjection - export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel diff --git a/core/vendor/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/core/vendor/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php deleted file mode 100644 index 10f5e17d99d6e531430ed5a1f6b51c30ca8dda94..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ /dev/null @@ -1,256 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\Scope; -use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - } - - public function testAddAListenerService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testAddASubscriberService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.subscriber', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testPreventDuplicateListenerService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10); - - $dispatcher->dispatch('onEvent', $event); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testTriggerAListenerServiceOutOfScope() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $container->leaveScope('scope'); - $dispatcher->dispatch('onEvent'); - } - - public function testReEnteringAScope() - { - $event = new Event(); - - $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service1 - ->expects($this->exactly(2)) - ->method('onEvent') - ->with($event) - ; - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service1, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - $dispatcher->dispatch('onEvent', $event); - - $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service2 - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container->enterScope('scope'); - $container->set('service.listener', $service2, 'scope'); - - $dispatcher->dispatch('onEvent', $event); - - $container->leaveScope('scope'); - - $dispatcher->dispatch('onEvent'); - } - - public function testHasListenersOnLazyLoad() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $event->setDispatcher($dispatcher); - $event->setName('onEvent'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $this->assertTrue($dispatcher->hasListeners()); - - if ($dispatcher->hasListeners('onEvent')) { - $dispatcher->dispatch('onEvent'); - } - } - - public function testGetListenersOnLazyLoad() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $listeners = $dispatcher->getListeners(); - - $this->assertTrue(isset($listeners['onEvent'])); - - $this->assertCount(1, $dispatcher->getListeners('onEvent')); - } - - public function testRemoveAfterDispatch() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', new Event()); - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } - - public function testRemoveBeforeDispatch() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } -} - -class Service -{ - function onEvent(Event $e) - { - } -} - -class SubscriberService implements EventSubscriberInterface -{ - static function getSubscribedEvents() { - return array( - 'onEvent' => 'onEvent', - 'onEvent' => array('onEvent', 10), - 'onEvent' => array('onEvent'), - ); - } - - function onEvent(Event $e) - { - } -} diff --git a/core/vendor/Symfony/Component/EventDispatcher/Tests/bootstrap.php b/core/vendor/Symfony/Component/EventDispatcher/Tests/bootstrap.php deleted file mode 100644 index b71ee5286667a39f9910227ae9bf405c753d0820..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/Tests/bootstrap.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -spl_autoload_register(function ($class) { - foreach (array( - 'SYMFONY_DEPENDENCY_INJECTION' => 'DependencyInjection', - 'SYMFONY_HTTP_KERNEL' => 'HttpKernel', - ) as $env => $name) { - if (isset($_SERVER[$env]) && 0 === strpos(ltrim($class, '/'), 'Symfony\Component\\'.$name)) { - if (file_exists($file = $_SERVER[$env].'/'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\\'.$name)).'.php')) { - require_once $file; - } - } - } - - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\EventDispatcher')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\EventDispatcher')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/Symfony/Component/EventDispatcher/composer.json b/core/vendor/Symfony/Component/EventDispatcher/composer.json deleted file mode 100644 index d93d09f2039572024b2d0df187f2c08ab275aa97..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "symfony/event-dispatcher", - "type": "library", - "description": "Symfony EventDispatcher Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2" - }, - "suggest": { - "symfony/dependency-injection": "self.version", - "symfony/http-kernel": "self.version" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\EventDispatcher": "" } - }, - "target-dir": "Symfony/Component/EventDispatcher", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -} diff --git a/core/vendor/Symfony/Component/EventDispatcher/phpunit.xml.dist b/core/vendor/Symfony/Component/EventDispatcher/phpunit.xml.dist deleted file mode 100644 index cb261a4c1fc811d3bf4f43bb1046e13303c47bdd..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - - - - diff --git a/core/vendor/Symfony/Component/HttpFoundation/Cookie.php b/core/vendor/Symfony/Component/HttpFoundation/Cookie.php deleted file mode 100644 index 0511162aa6d8a8332a2bd21bd6f27a5f9e7fcc29..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Cookie.php +++ /dev/null @@ -1,203 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Represents a cookie - * - * @author Johannes M. Schmitt - * - * @api - */ -class Cookie -{ - protected $name; - protected $value; - protected $domain; - protected $expire; - protected $path; - protected $secure; - protected $httpOnly; - - /** - * Constructor. - * - * @param string $name The name of the cookie - * @param string $value The value of the cookie - * @param integer|string|\DateTime $expire The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available to - * @param Boolean $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client - * @param Boolean $httpOnly Whether the cookie will be made accessible only through the HTTP protocol - * - * @api - */ - public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true) - { - // from PHP source code - if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { - throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); - } - - if (empty($name)) { - throw new \InvalidArgumentException('The cookie name cannot be empty.'); - } - - // convert expiration time to a Unix timestamp - if ($expire instanceof \DateTime) { - $expire = $expire->format('U'); - } elseif (!is_numeric($expire)) { - $expire = strtotime($expire); - - if (false === $expire || -1 === $expire) { - throw new \InvalidArgumentException('The cookie expiration time is not valid.'); - } - } - - $this->name = $name; - $this->value = $value; - $this->domain = $domain; - $this->expire = $expire; - $this->path = empty($path) ? '/' : $path; - $this->secure = (Boolean) $secure; - $this->httpOnly = (Boolean) $httpOnly; - } - - public function __toString() - { - $str = urlencode($this->getName()).'='; - - if ('' === (string) $this->getValue()) { - $str .= 'deleted; expires='.gmdate("D, d-M-Y H:i:s T", time() - 31536001); - } else { - $str .= urlencode($this->getValue()); - - if ($this->getExpiresTime() !== 0) { - $str .= '; expires='.gmdate("D, d-M-Y H:i:s T", $this->getExpiresTime()); - } - } - - if ('/' !== $this->path) { - $str .= '; path='.$this->path; - } - - if (null !== $this->getDomain()) { - $str .= '; domain='.$this->getDomain(); - } - - if (true === $this->isSecure()) { - $str .= '; secure'; - } - - if (true === $this->isHttpOnly()) { - $str .= '; httponly'; - } - - return $str; - } - - /** - * Gets the name of the cookie. - * - * @return string - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Gets the value of the cookie. - * - * @return string - * - * @api - */ - public function getValue() - { - return $this->value; - } - - /** - * Gets the domain that the cookie is available to. - * - * @return string - * - * @api - */ - public function getDomain() - { - return $this->domain; - } - - /** - * Gets the time the cookie expires. - * - * @return integer - * - * @api - */ - public function getExpiresTime() - { - return $this->expire; - } - - /** - * Gets the path on the server in which the cookie will be available on. - * - * @return string - * - * @api - */ - public function getPath() - { - return $this->path; - } - - /** - * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client. - * - * @return Boolean - * - * @api - */ - public function isSecure() - { - return $this->secure; - } - - /** - * Checks whether the cookie will be made accessible only through the HTTP protocol. - * - * @return Boolean - * - * @api - */ - public function isHttpOnly() - { - return $this->httpOnly; - } - - /** - * Whether this cookie is about to be cleared - * - * @return Boolean - * - * @api - */ - public function isCleared() - { - return $this->expire < time(); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php b/core/vendor/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php deleted file mode 100644 index 9c7fe6812a31d950910cbaa2befc16f1dd3532e1..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when the access on a file was denied. - * - * @author Bernhard Schussek - */ -class AccessDeniedException extends FileException -{ - /** - * Constructor. - * - * @param string $path The path to the accessed file - */ - public function __construct($path) - { - parent::__construct(sprintf('The file %s could not be accessed', $path)); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileException.php b/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileException.php deleted file mode 100644 index 43c6cc8998c5d2f87e1dd9f0146f3369ca42ca24..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when an error occurred in the component File - * - * @author Bernhard Schussek - */ -class FileException extends \RuntimeException -{ -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php b/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php deleted file mode 100644 index 5b1aef8e2b2977c6ccbc11c9e0030a3a95035017..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when a file was not found - * - * @author Bernhard Schussek - */ -class FileNotFoundException extends FileException -{ - /** - * Constructor. - * - * @param string $path The path to the file that was not found - */ - public function __construct($path) - { - parent::__construct(sprintf('The file "%s" does not exist', $path)); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/UploadException.php b/core/vendor/Symfony/Component/HttpFoundation/File/Exception/UploadException.php deleted file mode 100644 index 694e864d1c56b41f9d015512d199df66c9274734..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/UploadException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when an error occurred during file upload - * - * @author Bernhard Schussek - */ -class UploadException extends FileException -{ -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/File.php b/core/vendor/Symfony/Component/HttpFoundation/File/File.php deleted file mode 100644 index 20a80cafd739af6a143e1ed76db1086bbc39c67e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/File.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; - -/** - * A file in the file system. - * - * @author Bernhard Schussek - * - * @api - */ -class File extends \SplFileInfo -{ - /** - * Constructs a new file from the given path. - * - * @param string $path The path to the file - * @param Boolean $checkPath Whether to check the path or not - * - * @throws FileNotFoundException If the given path is not a file - * - * @api - */ - public function __construct($path, $checkPath = true) - { - if ($checkPath && !is_file($path)) { - throw new FileNotFoundException($path); - } - - parent::__construct($path); - } - - /** - * Returns the extension based on the mime type. - * - * If the mime type is unknown, returns null. - * - * @return string|null The guessed extension or null if it cannot be guessed - * - * @api - */ - public function guessExtension() - { - $type = $this->getMimeType(); - $guesser = ExtensionGuesser::getInstance(); - - return $guesser->guess($type); - } - - /** - * Returns the mime type of the file. - * - * The mime type is guessed using the functions finfo(), mime_content_type() - * and the system binary "file" (in this order), depending on which of those - * is available on the current operating system. - * - * @return string|null The guessed mime type (i.e. "application/pdf") - * - * @api - */ - public function getMimeType() - { - $guesser = MimeTypeGuesser::getInstance(); - - return $guesser->guess($this->getPathname()); - } - - /** - * Returns the extension of the file. - * - * \SplFileInfo::getExtension() is not available before PHP 5.3.6 - * - * @return string The extension - * - * @api - */ - public function getExtension() - { - return pathinfo($this->getBasename(), PATHINFO_EXTENSION); - } - - /** - * Moves the file to a new location. - * - * @param string $directory The destination folder - * @param string $name The new file name - * - * @return File A File object representing the new file - * - * @throws FileException if the target file could not be created - * - * @api - */ - public function move($directory, $name = null) - { - if (!is_dir($directory)) { - if (false === @mkdir($directory, 0777, true)) { - throw new FileException(sprintf('Unable to create the "%s" directory', $directory)); - } - } elseif (!is_writable($directory)) { - throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); - } - - $target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : basename($name)); - - if (!@rename($this->getPathname(), $target)) { - $error = error_get_last(); - throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); - } - - chmod($target, 0666 & ~umask()); - - return new File($target); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php deleted file mode 100644 index b73cd999107c6bb255ea2038661197a85a07fd9d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * A singleton mime type to file extension guesser. - * - * A default guesser is provided. - * You can register custom guessers by calling the register() - * method on the singleton instance. - * - * - * $guesser = ExtensionGuesser::getInstance(); - * $guesser->register(new MyCustomExtensionGuesser()); - * - * - * The last registered guesser is preferred over previously registered ones. - * - */ -class ExtensionGuesser implements ExtensionGuesserInterface -{ - /** - * The singleton instance - * @var ExtensionGuesser - */ - static private $instance = null; - - /** - * All registered ExtensionGuesserInterface instances - * @var array - */ - protected $guessers = array(); - - /** - * Returns the singleton instance - * - * @return ExtensionGuesser - */ - static public function getInstance() - { - if (null === self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Registers all natively provided extension guessers - */ - private function __construct() - { - $this->register(new MimeTypeExtensionGuesser()); - } - - /** - * Registers a new extension guesser - * - * When guessing, this guesser is preferred over previously registered ones. - * - * @param ExtensionGuesserInterface $guesser - */ - public function register(ExtensionGuesserInterface $guesser) - { - array_unshift($this->guessers, $guesser); - } - - /** - * Tries to guess the extension - * - * The mime type is passed to each registered mime type guesser in reverse order - * of their registration (last registered is queried first). Once a guesser - * returns a value that is not NULL, this method terminates and returns the - * value. - * - * @param string $mimeType The mime type - * @return string The guessed extension or NULL, if none could be guessed - */ - public function guess($mimeType) - { - foreach ($this->guessers as $guesser) { - $extension = $guesser->guess($mimeType); - - if (null !== $extension) { - break; - } - } - - return $extension; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php deleted file mode 100644 index 5b14ef9ed3c479d328643283af840ab65722406d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * Guesses the file extension corresponding to a given mime type - */ -interface ExtensionGuesserInterface -{ - /** - * Makes a best guess for a file extension, given a mime type - * - * @param string $mimeType The mime type - * @return string The guessed extension or NULL, if none could be guessed - */ - function guess($mimeType); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php deleted file mode 100644 index 12b84cdc9aa52ece03ca7ea436e0c16123b548f5..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type with the binary "file" (only available on *nix) - * - * @author Bernhard Schussek - */ -class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface -{ - private $cmd; - - /** - * Constructor. - * - * The $cmd pattern must contain a "%s" string that will be replaced - * with the file name to guess. - * - * The command output must start with the mime type of the file. - * - * @param string $cmd The command to run to get the mime type of a file - */ - public function __construct($cmd = 'file -b --mime %s 2>/dev/null') - { - $this->cmd = $cmd; - } - - /** - * Returns whether this guesser is supported on the current OS - * - * @return Boolean - */ - static public function isSupported() - { - return !defined('PHP_WINDOWS_VERSION_BUILD'); - } - - /** - * Guesses the mime type of the file with the given path - * - * @see MimeTypeGuesserInterface::guess() - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!self::isSupported()) { - return null; - } - - ob_start(); - - // need to use --mime instead of -i. see #6641 - passthru(sprintf($this->cmd, escapeshellarg($path)), $return); - if ($return > 0) { - ob_end_clean(); - - return null; - } - - $type = trim(ob_get_clean()); - - if (!preg_match('#^([a-z0-9\-]+/[a-z0-9\-]+)#i', $type, $match)) { - // it's not a type, but an error message - return null; - } - - return $match[1]; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php deleted file mode 100644 index 45d5a086eda35e18809c0e38c9da72e433b1775c..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type using the PECL extension FileInfo - * - * @author Bernhard Schussek - */ -class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface -{ - /** - * Returns whether this guesser is supported on the current OS/PHP setup - * - * @return Boolean - */ - static public function isSupported() - { - return function_exists('finfo_open'); - } - - /** - * Guesses the mime type of the file with the given path - * - * @see MimeTypeGuesserInterface::guess() - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!self::isSupported()) { - return null; - } - - if (!$finfo = new \finfo(FILEINFO_MIME_TYPE)) { - return null; - } - - return $finfo->file($path); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php deleted file mode 100644 index d73a093dfdda72899881267796bb457158fb5ea5..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * A singleton mime type guesser. - * - * By default, all mime type guessers provided by the framework are installed - * (if available on the current OS/PHP setup). You can register custom - * guessers by calling the register() method on the singleton instance. - * - * - * $guesser = MimeTypeGuesser::getInstance(); - * $guesser->register(new MyCustomMimeTypeGuesser()); - * - * - * The last registered guesser is preferred over previously registered ones. - * - * @author Bernhard Schussek - */ -class MimeTypeGuesser implements MimeTypeGuesserInterface -{ - /** - * The singleton instance - * @var MimeTypeGuesser - */ - static private $instance = null; - - /** - * All registered MimeTypeGuesserInterface instances - * @var array - */ - protected $guessers = array(); - - /** - * Returns the singleton instance - * - * @return MimeTypeGuesser - */ - static public function getInstance() - { - if (null === self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Registers all natively provided mime type guessers - */ - private function __construct() - { - if (FileBinaryMimeTypeGuesser::isSupported()) { - $this->register(new FileBinaryMimeTypeGuesser()); - } - - if (FileinfoMimeTypeGuesser::isSupported()) { - $this->register(new FileinfoMimeTypeGuesser()); - } - } - - /** - * Registers a new mime type guesser - * - * When guessing, this guesser is preferred over previously registered ones. - * - * @param MimeTypeGuesserInterface $guesser - */ - public function register(MimeTypeGuesserInterface $guesser) - { - array_unshift($this->guessers, $guesser); - } - - /** - * Tries to guess the mime type of the given file - * - * The file is passed to each registered mime type guesser in reverse order - * of their registration (last registered is queried first). Once a guesser - * returns a value that is not NULL, this method terminates and returns the - * value. - * - * @param string $path The path to the file - * - * @return string The mime type or NULL, if none could be guessed - * - * @throws FileException If the file does not exist - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!$this->guessers) { - throw new \LogicException('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)'); - } - - foreach ($this->guessers as $guesser) { - if (null !== $mimeType = $guesser->guess($path)) { - return $mimeType; - } - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php deleted file mode 100644 index 66178bb952ea4d23d295c475737bdfa7420af64d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * Guesses the mime type of a file - * - * @author Bernhard Schussek - */ -interface MimeTypeGuesserInterface -{ - /** - * Guesses the mime type of the file with the given path. - * - * @param string $path The path to the file - * - * @return string The mime type or NULL, if none could be guessed - * - * @throws FileNotFoundException If the file does not exist - * @throws AccessDeniedException If the file could not be read - */ - function guess($path); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/UploadedFile.php b/core/vendor/Symfony/Component/HttpFoundation/File/UploadedFile.php deleted file mode 100644 index 4e51c50010865cc5b9267f0bc8ef4d12972fc2c5..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ /dev/null @@ -1,223 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; - -/** - * A file uploaded through a form. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - * @author Fabien Potencier - * - * @api - */ -class UploadedFile extends File -{ - /** - * Whether the test mode is activated. - * - * Local files are used in test mode hence the code should not enforce HTTP uploads. - * - * @var Boolean - */ - private $test = false; - - /** - * The original name of the uploaded file. - * - * @var string - */ - private $originalName; - - /** - * The mime type provided by the uploader. - * - * @var string - */ - private $mimeType; - - /** - * The file size provided by the uploader. - * - * @var string - */ - private $size; - - /** - * The UPLOAD_ERR_XXX constant provided by the uploader. - * - * @var integer - */ - private $error; - - /** - * Accepts the information of the uploaded file as provided by the PHP global $_FILES. - * - * The file object is only created when the uploaded file is valid (i.e. when the - * isValid() method returns true). Otherwise the only methods that could be called - * on an UploadedFile instance are: - * - * * getClientOriginalName, - * * getClientMimeType, - * * isValid, - * * getError. - * - * Calling any other method on an non-valid instance will cause an unpredictable result. - * - * @param string $path The full temporary path to the file - * @param string $originalName The original file name - * @param string $mimeType The type of the file as provided by PHP - * @param integer $size The file size - * @param integer $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants) - * @param Boolean $test Whether the test mode is active - * - * @throws FileException If file_uploads is disabled - * @throws FileNotFoundException If the file does not exist - * - * @api - */ - public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) - { - if (!ini_get('file_uploads')) { - throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path'))); - } - - $this->originalName = basename($originalName); - $this->mimeType = $mimeType ?: 'application/octet-stream'; - $this->size = $size; - $this->error = $error ?: UPLOAD_ERR_OK; - $this->test = (Boolean) $test; - - parent::__construct($path, UPLOAD_ERR_OK === $this->error); - } - - /** - * Returns the original file name. - * - * It is extracted from the request from which the file has been uploaded. - * Then is should not be considered as a safe value. - * - * @return string|null The original name - * - * @api - */ - public function getClientOriginalName() - { - return $this->originalName; - } - - /** - * Returns the file mime type. - * - * It is extracted from the request from which the file has been uploaded. - * Then is should not be considered as a safe value. - * - * @return string|null The mime type - * - * @api - */ - public function getClientMimeType() - { - return $this->mimeType; - } - - /** - * Returns the file size. - * - * It is extracted from the request from which the file has been uploaded. - * Then is should not be considered as a safe value. - * - * @return integer|null The file size - * - * @api - */ - public function getClientSize() - { - return $this->size; - } - - /** - * Returns the upload error. - * - * If the upload was successful, the constant UPLOAD_ERR_OK is returned. - * Otherwise one of the other UPLOAD_ERR_XXX constants is returned. - * - * @return integer The upload error - * - * @api - */ - public function getError() - { - return $this->error; - } - - /** - * Returns whether the file was uploaded successfully. - * - * @return Boolean True if no error occurred during uploading - * - * @api - */ - public function isValid() - { - return $this->error === UPLOAD_ERR_OK; - } - - /** - * Moves the file to a new location. - * - * @param string $directory The destination folder - * @param string $name The new file name - * - * @return File A File object representing the new file - * - * @throws FileException if the file has not been uploaded via Http - * - * @api - */ - public function move($directory, $name = null) - { - if ($this->isValid() && ($this->test || is_uploaded_file($this->getPathname()))) { - return parent::move($directory, $name); - } - - throw new FileException(sprintf('The file "%s" has not been uploaded via Http', $this->getPathname())); - } - - /** - * Returns the maximum size of an uploaded file as configured in php.ini - * - * @return type The maximum size of an uploaded file in bytes - */ - static public function getMaxFilesize() - { - $max = trim(ini_get('upload_max_filesize')); - - if ('' === $max) { - return PHP_INT_MAX; - } - - switch (strtolower(substr($max, -1))) { - case 'g': - $max *= 1024; - case 'm': - $max *= 1024; - case 'k': - $max *= 1024; - } - - return (integer) $max; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/FileBag.php b/core/vendor/Symfony/Component/HttpFoundation/FileBag.php deleted file mode 100644 index 702ab84c0222248d0aba8e23e8b0d9922ec691fa..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/FileBag.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * FileBag is a container for HTTP headers. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * - * @api - */ -class FileBag extends ParameterBag -{ - static private $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type'); - - /** - * Constructor. - * - * @param array $parameters An array of HTTP files - * - * @api - */ - public function __construct(array $parameters = array()) - { - $this->replace($parameters); - } - - /** - * (non-PHPdoc) - * @see Symfony\Component\HttpFoundation\ParameterBag::replace() - * - * @api - */ - public function replace(array $files = array()) - { - $this->parameters = array(); - $this->add($files); - } - - /** - * (non-PHPdoc) - * @see Symfony\Component\HttpFoundation\ParameterBag::set() - * - * @api - */ - public function set($key, $value) - { - if (is_array($value) || $value instanceof UploadedFile) { - parent::set($key, $this->convertFileInformation($value)); - } else { - throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.'); - } - } - - /** - * (non-PHPdoc) - * @see Symfony\Component\HttpFoundation\ParameterBag::add() - * - * @api - */ - public function add(array $files = array()) - { - foreach ($files as $key => $file) { - $this->set($key, $file); - } - } - - /** - * Converts uploaded files to UploadedFile instances. - * - * @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information - * - * @return array A (multi-dimensional) array of UploadedFile instances - */ - protected function convertFileInformation($file) - { - if ($file instanceof UploadedFile) { - return $file; - } - - $file = $this->fixPhpFilesArray($file); - if (is_array($file)) { - $keys = array_keys($file); - sort($keys); - - if ($keys == self::$fileKeys) { - if (UPLOAD_ERR_NO_FILE == $file['error']) { - $file = null; - } else { - $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']); - } - } else { - $file = array_map(array($this, 'convertFileInformation'), $file); - } - } - - return $file; - } - - /** - * Fixes a malformed PHP $_FILES array. - * - * PHP has a bug that the format of the $_FILES array differs, depending on - * whether the uploaded file fields had normal field names or array-like - * field names ("normal" vs. "parent[child]"). - * - * This method fixes the array to look like the "normal" $_FILES array. - * - * It's safe to pass an already converted array, in which case this method - * just returns the original array unmodified. - * - * @param array $data - * - * @return array - */ - protected function fixPhpFilesArray($data) - { - if (!is_array($data)) { - return $data; - } - - $keys = array_keys($data); - sort($keys); - - if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) { - return $data; - } - - $files = $data; - foreach (self::$fileKeys as $k) { - unset($files[$k]); - } - - foreach (array_keys($data['name']) as $key) { - $files[$key] = $this->fixPhpFilesArray(array( - 'error' => $data['error'][$key], - 'name' => $data['name'][$key], - 'type' => $data['type'][$key], - 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key] - )); - } - - return $files; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/HeaderBag.php b/core/vendor/Symfony/Component/HttpFoundation/HeaderBag.php deleted file mode 100644 index 88ad1afd682259b393c40ce7e990cd3a9cd9c2e8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/HeaderBag.php +++ /dev/null @@ -1,323 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * HeaderBag is a container for HTTP headers. - * - * @author Fabien Potencier - * - * @api - */ -class HeaderBag implements \IteratorAggregate, \Countable -{ - protected $headers; - protected $cacheControl; - - /** - * Constructor. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function __construct(array $headers = array()) - { - $this->cacheControl = array(); - $this->headers = array(); - foreach ($headers as $key => $values) { - $this->set($key, $values); - } - } - - /** - * Returns the headers as a string. - * - * @return string The headers - */ - public function __toString() - { - if (!$this->headers) { - return ''; - } - - $max = max(array_map('strlen', array_keys($this->headers))) + 1; - $content = ''; - ksort($this->headers); - foreach ($this->headers as $name => $values) { - $name = implode('-', array_map('ucfirst', explode('-', $name))); - foreach ($values as $value) { - $content .= sprintf("%-{$max}s %s\r\n", $name.':', $value); - } - } - - return $content; - } - - /** - * Returns the headers. - * - * @return array An array of headers - * - * @api - */ - public function all() - { - return $this->headers; - } - - /** - * Returns the parameter keys. - * - * @return array An array of parameter keys - * - * @api - */ - public function keys() - { - return array_keys($this->headers); - } - - /** - * Replaces the current HTTP headers by a new set. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function replace(array $headers = array()) - { - $this->headers = array(); - $this->add($headers); - } - - /** - * Adds new headers the current HTTP headers set. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function add(array $headers) - { - foreach ($headers as $key => $values) { - $this->set($key, $values); - } - } - - /** - * Returns a header value by name. - * - * @param string $key The header name - * @param mixed $default The default value - * @param Boolean $first Whether to return the first value or all header values - * - * @return string|array The first header value if $first is true, an array of values otherwise - * - * @api - */ - public function get($key, $default = null, $first = true) - { - $key = strtr(strtolower($key), '_', '-'); - - if (!array_key_exists($key, $this->headers)) { - if (null === $default) { - return $first ? null : array(); - } - - return $first ? $default : array($default); - } - - if ($first) { - return count($this->headers[$key]) ? $this->headers[$key][0] : $default; - } - - return $this->headers[$key]; - } - - /** - * Sets a header by name. - * - * @param string $key The key - * @param string|array $values The value or an array of values - * @param Boolean $replace Whether to replace the actual value of not (true by default) - * - * @api - */ - public function set($key, $values, $replace = true) - { - $key = strtr(strtolower($key), '_', '-'); - - $values = (array) $values; - - if (true === $replace || !isset($this->headers[$key])) { - $this->headers[$key] = $values; - } else { - $this->headers[$key] = array_merge($this->headers[$key], $values); - } - - if ('cache-control' === $key) { - $this->cacheControl = $this->parseCacheControl($values[0]); - } - } - - /** - * Returns true if the HTTP header is defined. - * - * @param string $key The HTTP header - * - * @return Boolean true if the parameter exists, false otherwise - * - * @api - */ - public function has($key) - { - return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers); - } - - /** - * Returns true if the given HTTP header contains the given value. - * - * @param string $key The HTTP header name - * @param string $value The HTTP value - * - * @return Boolean true if the value is contained in the header, false otherwise - * - * @api - */ - public function contains($key, $value) - { - return in_array($value, $this->get($key, null, false)); - } - - /** - * Removes a header. - * - * @param string $key The HTTP header name - * - * @api - */ - public function remove($key) - { - $key = strtr(strtolower($key), '_', '-'); - - unset($this->headers[$key]); - - if ('cache-control' === $key) { - $this->cacheControl = array(); - } - } - - /** - * Returns the HTTP header value converted to a date. - * - * @param string $key The parameter key - * @param \DateTime $default The default value - * - * @return \DateTime The filtered value - * - * @api - */ - public function getDate($key, \DateTime $default = null) - { - if (null === $value = $this->get($key)) { - return $default; - } - - if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { - throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value)); - } - - return $date; - } - - public function addCacheControlDirective($key, $value = true) - { - $this->cacheControl[$key] = $value; - - $this->set('Cache-Control', $this->getCacheControlHeader()); - } - - public function hasCacheControlDirective($key) - { - return array_key_exists($key, $this->cacheControl); - } - - public function getCacheControlDirective($key) - { - return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; - } - - public function removeCacheControlDirective($key) - { - unset($this->cacheControl[$key]); - - $this->set('Cache-Control', $this->getCacheControlHeader()); - } - - /** - * Returns an iterator for headers. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->headers); - } - - /** - * Returns the number of headers. - * - * @return int The number of headers - */ - public function count() - { - return count($this->headers); - } - - protected function getCacheControlHeader() - { - $parts = array(); - ksort($this->cacheControl); - foreach ($this->cacheControl as $key => $value) { - if (true === $value) { - $parts[] = $key; - } else { - if (preg_match('#[^a-zA-Z0-9._-]#', $value)) { - $value = '"'.$value.'"'; - } - - $parts[] = "$key=$value"; - } - } - - return implode(', ', $parts); - } - - /** - * Parses a Cache-Control HTTP header. - * - * @param string $header The value of the Cache-Control HTTP header - * - * @return array An array representing the attribute values - */ - protected function parseCacheControl($header) - { - $cacheControl = array(); - preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER); - foreach ($matches as $match) { - $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true); - } - - return $cacheControl; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/JsonResponse.php b/core/vendor/Symfony/Component/HttpFoundation/JsonResponse.php deleted file mode 100644 index d30899fa8912bf7681f1cc69357355f04b7be7ab..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/JsonResponse.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Response represents an HTTP response in JSON format. - * - * @author Igor Wiedler - */ -class JsonResponse extends Response -{ - protected $data; - protected $callback; - - /** - * Constructor. - * - * @param mixed $data The response data - * @param integer $status The response status code - * @param array $headers An array of response headers - */ - public function __construct($data = array(), $status = 200, $headers = array()) - { - parent::__construct('', $status, $headers); - - $this->setData($data); - } - - /** - * {@inheritDoc} - */ - static public function create($data = array(), $status = 200, $headers = array()) - { - return new static($data, $status, $headers); - } - - /** - * Sets the JSONP callback. - * - * @param string $callback - * - * @return JsonResponse - */ - public function setCallback($callback = null) - { - if ($callback) { - // taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/ - $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; - if (!preg_match($pattern, $callback)) { - throw new \InvalidArgumentException('The callback name is not valid.'); - } - } - - $this->callback = $callback; - - return $this->update(); - } - - /** - * Sets the data to be sent as json. - * - * @param mixed $data - * - * @return JsonResponse - */ - public function setData($data = array()) - { - // root should be JSON object, not array - if (is_array($data) && 0 === count($data)) { - $data = new \ArrayObject(); - } - - $this->data = json_encode($data); - - return $this->update(); - } - - /** - * Updates the content and headers according to the json data and callback. - * - * @return JsonResponse - */ - protected function update() - { - if ($this->callback) { - // Not using application/javascript for compatibility reasons with older browsers. - $this->headers->set('Content-Type', 'text/javascript', true); - - return $this->setContent(sprintf('%s(%s);', $this->callback, $this->data)); - } - - $this->headers->set('Content-Type', 'application/json', false); - - return $this->setContent($this->data); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/ParameterBag.php b/core/vendor/Symfony/Component/HttpFoundation/ParameterBag.php deleted file mode 100644 index b4fa6760520f66b3c82ba3bba677465485ffdb7e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/ParameterBag.php +++ /dev/null @@ -1,301 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ParameterBag is a container for key/value pairs. - * - * @author Fabien Potencier - * - * @api - */ -class ParameterBag implements \IteratorAggregate, \Countable -{ - /** - * Parameter storage. - * - * @var array - */ - protected $parameters; - - /** - * Constructor. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function __construct(array $parameters = array()) - { - $this->parameters = $parameters; - } - - /** - * Returns the parameters. - * - * @return array An array of parameters - * - * @api - */ - public function all() - { - return $this->parameters; - } - - /** - * Returns the parameter keys. - * - * @return array An array of parameter keys - * - * @api - */ - public function keys() - { - return array_keys($this->parameters); - } - - /** - * Replaces the current parameters by a new set. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function replace(array $parameters = array()) - { - $this->parameters = $parameters; - } - - /** - * Adds parameters. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function add(array $parameters = array()) - { - $this->parameters = array_replace($this->parameters, $parameters); - } - - /** - * Returns a parameter by name. - * - * @param string $path The key - * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items - * - * @api - */ - public function get($path, $default = null, $deep = false) - { - if (!$deep || false === $pos = strpos($path, '[')) { - return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default; - } - - $root = substr($path, 0, $pos); - if (!array_key_exists($root, $this->parameters)) { - return $default; - } - - $value = $this->parameters[$root]; - $currentKey = null; - for ($i = $pos, $c = strlen($path); $i < $c; $i++) { - $char = $path[$i]; - - if ('[' === $char) { - if (null !== $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i)); - } - - $currentKey = ''; - } elseif (']' === $char) { - if (null === $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i)); - } - - if (!is_array($value) || !array_key_exists($currentKey, $value)) { - return $default; - } - - $value = $value[$currentKey]; - $currentKey = null; - } else { - if (null === $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i)); - } - - $currentKey .= $char; - } - } - - if (null !== $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Path must end with "]".')); - } - - return $value; - } - - /** - * Sets a parameter by name. - * - * @param string $key The key - * @param mixed $value The value - * - * @api - */ - public function set($key, $value) - { - $this->parameters[$key] = $value; - } - - /** - * Returns true if the parameter is defined. - * - * @param string $key The key - * - * @return Boolean true if the parameter exists, false otherwise - * - * @api - */ - public function has($key) - { - return array_key_exists($key, $this->parameters); - } - - /** - * Removes a parameter. - * - * @param string $key The key - * - * @api - */ - public function remove($key) - { - unset($this->parameters[$key]); - } - - /** - * Returns the alphabetic characters of the parameter value. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items - * - * @return string The filtered value - * - * @api - */ - public function getAlpha($key, $default = '', $deep = false) - { - return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default, $deep)); - } - - /** - * Returns the alphabetic characters and digits of the parameter value. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items - * - * @return string The filtered value - * - * @api - */ - public function getAlnum($key, $default = '', $deep = false) - { - return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep)); - } - - /** - * Returns the digits of the parameter value. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items - * - * @return string The filtered value - * - * @api - */ - public function getDigits($key, $default = '', $deep = false) - { - // we need to remove - and + because they're allowed in the filter - return str_replace(array('-', '+'), '', $this->filter($key, $default, $deep, FILTER_SANITIZE_NUMBER_INT)); - } - - /** - * Returns the parameter value converted to integer. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items - * - * @return integer The filtered value - * - * @api - */ - public function getInt($key, $default = 0, $deep = false) - { - return (int) $this->get($key, $default, $deep); - } - - /** - * Filter key. - * - * @param string $key Key. - * @param mixed $default Default = null. - * @param boolean $deep Default = false. - * @param integer $filter FILTER_* constant. - * @param mixed $options Filter options. - * - * @see http://php.net/manual/en/function.filter-var.php - * - * @return mixed - */ - public function filter($key, $default = null, $deep = false, $filter=FILTER_DEFAULT, $options=array()) - { - $value = $this->get($key, $default, $deep); - - // Always turn $options into an array - this allows filter_var option shortcuts. - if (!is_array($options) && $options) { - $options = array('flags' => $options); - } - - // Add a convenience check for arrays. - if (is_array($value) && !isset($options['flags'])) { - $options['flags'] = FILTER_REQUIRE_ARRAY; - } - - return filter_var($value, $filter, $options); - } - - /** - * Returns an iterator for parameters. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->parameters); - } - - /** - * Returns the number of parameters. - * - * @return int The number of parameters - */ - public function count() - { - return count($this->parameters); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/README.md b/core/vendor/Symfony/Component/HttpFoundation/README.md deleted file mode 100644 index 8e5d8cfefd7ff9c8b8cc9ff0b618cfd95c8b9896..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/README.md +++ /dev/null @@ -1,46 +0,0 @@ -HttpFoundation Component -======================== - -HttpFoundation defines an object-oriented layer for the HTTP specification. - -It provides an abstraction for requests, responses, uploaded files, cookies, -sessions, ... - -In this example, we get a Request object from the current PHP global -variables: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\Response; - - $request = Request::createFromGlobals(); - echo $request->getPathInfo(); - -You can also create a Request directly -- that's interesting for unit testing: - - $request = Request::create('/?foo=bar', 'GET'); - echo $request->getPathInfo(); - -And here is how to create and send a Response: - - $response = new Response('Not Found', 404, array('Content-Type' => 'text/plain')); - $response->send(); - -The Request and the Response classes have many other methods that implement -the HTTP specification. - -Loading -------- - -If you are using PHP 5.3.x you must add the following to your autoloader: - - // SessionHandlerInterface - if (!interface_exists('SessionHandlerInterface')) { - $loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs'); - } - -Resources ---------- - -You can run the unit tests with the following command: - - phpunit -c src/Symfony/Component/HttpFoundation/ diff --git a/core/vendor/Symfony/Component/HttpFoundation/Request.php b/core/vendor/Symfony/Component/HttpFoundation/Request.php deleted file mode 100644 index b4fd7ace51136377a07f889c6dc98043c85ea4d1..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Request.php +++ /dev/null @@ -1,1460 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -use Symfony\Component\HttpFoundation\Session\SessionInterface; - -/** - * Request represents an HTTP request. - * - * The methods dealing with URL accept / return a raw path (% encoded): - * * getBasePath - * * getBaseUrl - * * getPathInfo - * * getRequestUri - * * getUri - * * getUriForPath - * - * @author Fabien Potencier - * - * @api - */ -class Request -{ - static protected $trustProxy = false; - - /** - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $attributes; - - /** - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $request; - - /** - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $query; - - /** - * @var \Symfony\Component\HttpFoundation\ServerBag - * - * @api - */ - public $server; - - /** - * @var \Symfony\Component\HttpFoundation\FileBag - * - * @api - */ - public $files; - - /** - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $cookies; - - /** - * @var \Symfony\Component\HttpFoundation\HeaderBag - * - * @api - */ - public $headers; - - /** - * @var string - */ - protected $content; - - /** - * @var string - */ - protected $languages; - - /** - * @var string - */ - protected $charsets; - - /** - * @var string - */ - protected $acceptableContentTypes; - - /** - * @var string - */ - protected $pathInfo; - - /** - * @var string - */ - protected $requestUri; - - /** - * @var string - */ - protected $baseUrl; - - /** - * @var string - */ - protected $basePath; - - /** - * @var string - */ - protected $method; - - /** - * @var string - */ - protected $format; - - /** - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - - /** - * @var string - */ - protected $locale; - - /** - * @var string - */ - protected $defaultLocale = 'en'; - - /** - * @var string - */ - static protected $formats; - - /** - * Constructor. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * @param string $content The raw body data - * - * @api - */ - public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content); - } - - /** - * Sets the parameters for this request. - * - * This method also re-initializes all properties. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * @param string $content The raw body data - * - * @api - */ - public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - $this->request = new ParameterBag($request); - $this->query = new ParameterBag($query); - $this->attributes = new ParameterBag($attributes); - $this->cookies = new ParameterBag($cookies); - $this->files = new FileBag($files); - $this->server = new ServerBag($server); - $this->headers = new HeaderBag($this->server->getHeaders()); - - $this->content = $content; - $this->languages = null; - $this->charsets = null; - $this->acceptableContentTypes = null; - $this->pathInfo = null; - $this->requestUri = null; - $this->baseUrl = null; - $this->basePath = null; - $this->method = null; - $this->format = null; - } - - /** - * Creates a new request with values from PHP's super globals. - * - * @return Request A new request - * - * @api - */ - static public function createFromGlobals() - { - $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER); - - if (0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') - && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH')) - ) { - parse_str($request->getContent(), $data); - $request->request = new ParameterBag($data); - } - - return $request; - } - - /** - * Creates a Request based on a given URI and configuration. - * - * @param string $uri The URI - * @param string $method The HTTP method - * @param array $parameters The request (GET) or query (POST) parameters - * @param array $cookies The request cookies ($_COOKIE) - * @param array $files The request files ($_FILES) - * @param array $server The server parameters ($_SERVER) - * @param string $content The raw body data - * - * @return Request A Request instance - * - * @api - */ - static public function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null) - { - $defaults = array( - 'SERVER_NAME' => 'localhost', - 'SERVER_PORT' => 80, - 'HTTP_HOST' => 'localhost', - 'HTTP_USER_AGENT' => 'Symfony/2.X', - 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', - 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', - 'REMOTE_ADDR' => '127.0.0.1', - 'SCRIPT_NAME' => '', - 'SCRIPT_FILENAME' => '', - 'SERVER_PROTOCOL' => 'HTTP/1.1', - 'REQUEST_TIME' => time(), - ); - - $components = parse_url($uri); - if (isset($components['host'])) { - $defaults['SERVER_NAME'] = $components['host']; - $defaults['HTTP_HOST'] = $components['host']; - } - - if (isset($components['scheme'])) { - if ('https' === $components['scheme']) { - $defaults['HTTPS'] = 'on'; - $defaults['SERVER_PORT'] = 443; - } - } - - if (isset($components['port'])) { - $defaults['SERVER_PORT'] = $components['port']; - $defaults['HTTP_HOST'] = $defaults['HTTP_HOST'].':'.$components['port']; - } - - if (isset($components['user'])) { - $defaults['PHP_AUTH_USER'] = $components['user']; - } - - if (isset($components['pass'])) { - $defaults['PHP_AUTH_PW'] = $components['pass']; - } - - if (!isset($components['path'])) { - $components['path'] = ''; - } - - switch (strtoupper($method)) { - case 'POST': - case 'PUT': - case 'DELETE': - $defaults['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - case 'PATCH': - $request = $parameters; - $query = array(); - break; - default: - $request = array(); - $query = $parameters; - break; - } - - if (isset($components['query'])) { - $queryString = html_entity_decode($components['query']); - parse_str($queryString, $qs); - if (is_array($qs)) { - $query = array_replace($qs, $query); - } - } - $queryString = http_build_query($query); - - $uri = $components['path'].($queryString ? '?'.$queryString : ''); - - $server = array_replace($defaults, $server, array( - 'REQUEST_METHOD' => strtoupper($method), - 'PATH_INFO' => '', - 'REQUEST_URI' => $uri, - 'QUERY_STRING' => $queryString, - )); - - return new static($query, $request, array(), $cookies, $files, $server, $content); - } - - /** - * Clones a request and overrides some of its parameters. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * - * @api - */ - public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) - { - $dup = clone $this; - if ($query !== null) { - $dup->query = new ParameterBag($query); - } - if ($request !== null) { - $dup->request = new ParameterBag($request); - } - if ($attributes !== null) { - $dup->attributes = new ParameterBag($attributes); - } - if ($cookies !== null) { - $dup->cookies = new ParameterBag($cookies); - } - if ($files !== null) { - $dup->files = new FileBag($files); - } - if ($server !== null) { - $dup->server = new ServerBag($server); - $dup->headers = new HeaderBag($dup->server->getHeaders()); - } - $dup->languages = null; - $dup->charsets = null; - $dup->acceptableContentTypes = null; - $dup->pathInfo = null; - $dup->requestUri = null; - $dup->baseUrl = null; - $dup->basePath = null; - $dup->method = null; - $dup->format = null; - - return $dup; - } - - /** - * Clones the current request. - * - * Note that the session is not cloned as duplicated requests - * are most of the time sub-requests of the main one. - */ - public function __clone() - { - $this->query = clone $this->query; - $this->request = clone $this->request; - $this->attributes = clone $this->attributes; - $this->cookies = clone $this->cookies; - $this->files = clone $this->files; - $this->server = clone $this->server; - $this->headers = clone $this->headers; - } - - /** - * Returns the request as a string. - * - * @return string The request - */ - public function __toString() - { - return - sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n". - $this->headers."\r\n". - $this->getContent(); - } - - /** - * Overrides the PHP global variables according to this request instance. - * - * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE, and $_FILES. - * - * @api - */ - public function overrideGlobals() - { - $_GET = $this->query->all(); - $_POST = $this->request->all(); - $_SERVER = $this->server->all(); - $_COOKIE = $this->cookies->all(); - // FIXME: populate $_FILES - - foreach ($this->headers->all() as $key => $value) { - $key = strtoupper(str_replace('-', '_', $key)); - if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) { - $_SERVER[$key] = implode(', ', $value); - } else { - $_SERVER['HTTP_'.$key] = implode(', ', $value); - } - } - - // FIXME: should read variables_order and request_order - // to know which globals to merge and in which order - $_REQUEST = array_merge($_GET, $_POST); - } - - /** - * Trusts $_SERVER entries coming from proxies. - * - * You should only call this method if your application - * is hosted behind a reverse proxy that you manage. - * - * @api - */ - static public function trustProxyData() - { - self::$trustProxy = true; - } - - /** - * Returns true if $_SERVER entries coming from proxies are trusted, - * false otherwise. - * - * @return boolean - */ - static public function isProxyTrusted() - { - return self::$trustProxy; - } - - /** - * Gets a "parameter" value. - * - * This method is mainly useful for libraries that want to provide some flexibility. - * - * Order of precedence: GET, PATH, POST, COOKIE - * - * Avoid using this method in controllers: - * - * * slow - * * prefer to get from a "named" source - * - * It is better to explicity get request parameters from the appropriate - * public property instead (query, request, attributes, ...). - * - * @param string $key the key - * @param mixed $default the default value - * @param type $deep is parameter deep in multidimensional array - * - * @return mixed - */ - public function get($key, $default = null, $deep = false) - { - return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default, $deep), $deep), $deep); - } - - /** - * Gets the Session. - * - * @return SessionInterface|null The session - * - * @api - */ - public function getSession() - { - return $this->session; - } - - /** - * Whether the request contains a Session which was started in one of the - * previous requests. - * - * @return boolean - * - * @api - */ - public function hasPreviousSession() - { - // the check for $this->session avoids malicious users trying to fake a session cookie with proper name - $sessionName = $this->hasSession() ? $this->session->getName() : null; - - return $this->cookies->has($sessionName) && $this->hasSession(); - } - - /** - * Whether the request contains a Session object. - * - * @return boolean - * - * @api - */ - public function hasSession() - { - return null !== $this->session; - } - - /** - * Sets the Session. - * - * @param SessionInterface $session The Session - * - * @api - */ - public function setSession(SessionInterface $session) - { - $this->session = $session; - } - - /** - * Returns the client IP address. - * - * @return string The client IP address - * - * @api - */ - public function getClientIp() - { - if (self::$trustProxy) { - if ($this->server->has('HTTP_CLIENT_IP')) { - return $this->server->get('HTTP_CLIENT_IP'); - } elseif ($this->server->has('HTTP_X_FORWARDED_FOR')) { - $clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'), 2); - - return isset($clientIp[0]) ? trim($clientIp[0]) : ''; - } - } - - return $this->server->get('REMOTE_ADDR'); - } - - /** - * Returns current script name. - * - * @return string - * - * @api - */ - public function getScriptName() - { - return $this->server->get('SCRIPT_NAME', $this->server->get('ORIG_SCRIPT_NAME', '')); - } - - /** - * Returns the path being requested relative to the executed script. - * - * The path info always starts with a /. - * - * Suppose this request is instantiated from /mysite on localhost: - * - * * http://localhost/mysite returns an empty string - * * http://localhost/mysite/about returns '/about' - * * htpp://localhost/mysite/enco%20ded returns '/enco%20ded' - * * http://localhost/mysite/about?var=1 returns '/about' - * - * @return string The raw path (i.e. not urldecoded) - * - * @api - */ - public function getPathInfo() - { - if (null === $this->pathInfo) { - $this->pathInfo = $this->preparePathInfo(); - } - - return $this->pathInfo; - } - - /** - * Returns the root path from which this request is executed. - * - * Suppose that an index.php file instantiates this request object: - * - * * http://localhost/index.php returns an empty string - * * http://localhost/index.php/page returns an empty string - * * http://localhost/web/index.php returns '/web' - * * http://localhost/we%20b/index.php returns '/we%20b' - * - * @return string The raw path (i.e. not urldecoded) - * - * @api - */ - public function getBasePath() - { - if (null === $this->basePath) { - $this->basePath = $this->prepareBasePath(); - } - - return $this->basePath; - } - - /** - * Returns the root url from which this request is executed. - * - * The base URL never ends with a /. - * - * This is similar to getBasePath(), except that it also includes the - * script filename (e.g. index.php) if one exists. - * - * @return string The raw url (i.e. not urldecoded) - * - * @api - */ - public function getBaseUrl() - { - if (null === $this->baseUrl) { - $this->baseUrl = $this->prepareBaseUrl(); - } - - return $this->baseUrl; - } - - /** - * Gets the request's scheme. - * - * @return string - * - * @api - */ - public function getScheme() - { - return $this->isSecure() ? 'https' : 'http'; - } - - /** - * Returns the port on which the request is made. - * - * @return string - * - * @api - */ - public function getPort() - { - if (self::$trustProxy && $this->headers->has('X-Forwarded-Port')) { - return $this->headers->get('X-Forwarded-Port'); - } else { - return $this->server->get('SERVER_PORT'); - } - } - - /** - * Returns the user. - * - * @return string|null - */ - public function getUser() - { - return $this->server->get('PHP_AUTH_USER'); - } - - /** - * Returns the password. - * - * @return string|null - */ - public function getPassword() - { - return $this->server->get('PHP_AUTH_PW'); - } - - /** - * Returns the HTTP host being requested. - * - * The port name will be appended to the host if it's non-standard. - * - * @return string - * - * @api - */ - public function getHttpHost() - { - $scheme = $this->getScheme(); - $port = $this->getPort(); - - if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { - return $this->getHost(); - } - - return $this->getHost().':'.$port; - } - - /** - * Returns the requested URI. - * - * @return string The raw URI (i.e. not urldecoded) - * - * @api - */ - public function getRequestUri() - { - if (null === $this->requestUri) { - $this->requestUri = $this->prepareRequestUri(); - } - - return $this->requestUri; - } - - /** - * Generates a normalized URI for the Request. - * - * @return string A normalized URI for the Request - * - * @see getQueryString() - * - * @api - */ - public function getUri() - { - $qs = $this->getQueryString(); - if (null !== $qs) { - $qs = '?'.$qs; - } - - $auth = ''; - if ($user = $this->getUser()) { - $auth = $user; - } - - if ($pass = $this->getPassword()) { - $auth .= ":$pass"; - } - - if ('' !== $auth) { - $auth .= '@'; - } - - return $this->getScheme().'://'.$auth.$this->getHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs; - } - - /** - * Generates a normalized URI for the given path. - * - * @param string $path A path to use instead of the current one - * - * @return string The normalized URI for the path - * - * @api - */ - public function getUriForPath($path) - { - return $this->getScheme().'://'.$this->getHttpHost().$this->getBaseUrl().$path; - } - - /** - * Generates the normalized query string for the Request. - * - * It builds a normalized query string, where keys/value pairs are alphabetized - * and have consistent escaping. - * - * @return string|null A normalized query string for the Request - * - * @api - */ - public function getQueryString() - { - if (!$qs = $this->server->get('QUERY_STRING')) { - return null; - } - - $parts = array(); - $order = array(); - - foreach (explode('&', $qs) as $segment) { - if (false === strpos($segment, '=')) { - $parts[] = $segment; - $order[] = $segment; - } else { - $tmp = explode('=', rawurldecode($segment), 2); - $parts[] = rawurlencode($tmp[0]).'='.rawurlencode($tmp[1]); - $order[] = $tmp[0]; - } - } - array_multisort($order, SORT_ASC, $parts); - - return implode('&', $parts); - } - - /** - * Checks whether the request is secure or not. - * - * @return Boolean - * - * @api - */ - public function isSecure() - { - return ( - (strtolower($this->server->get('HTTPS')) == 'on' || $this->server->get('HTTPS') == 1) - || - (self::$trustProxy && strtolower($this->headers->get('SSL_HTTPS')) == 'on' || $this->headers->get('SSL_HTTPS') == 1) - || - (self::$trustProxy && strtolower($this->headers->get('X_FORWARDED_PROTO')) == 'https') - ); - } - - /** - * Returns the host name. - * - * @return string - * - * @api - */ - public function getHost() - { - if (self::$trustProxy && $host = $this->headers->get('X_FORWARDED_HOST')) { - $elements = explode(',', $host); - - $host = trim($elements[count($elements) - 1]); - } else { - if (!$host = $this->headers->get('HOST')) { - if (!$host = $this->server->get('SERVER_NAME')) { - $host = $this->server->get('SERVER_ADDR', ''); - } - } - } - - // Remove port number from host - $host = preg_replace('/:\d+$/', '', $host); - - // host is lowercase as per RFC 952/2181 - return trim(strtolower($host)); - } - - /** - * Sets the request method. - * - * @param string $method - * - * @api - */ - public function setMethod($method) - { - $this->method = null; - $this->server->set('REQUEST_METHOD', $method); - } - - /** - * Gets the request method. - * - * The method is always an uppercased string. - * - * @return string The request method - * - * @api - */ - public function getMethod() - { - if (null === $this->method) { - $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET')); - if ('POST' === $this->method) { - $this->method = strtoupper($this->headers->get('X-HTTP-METHOD-OVERRIDE', $this->request->get('_method', 'POST'))); - } - } - - return $this->method; - } - - /** - * Gets the mime type associated with the format. - * - * @param string $format The format - * - * @return string The associated mime type (null if not found) - * - * @api - */ - public function getMimeType($format) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - return isset(static::$formats[$format]) ? static::$formats[$format][0] : null; - } - - /** - * Gets the format associated with the mime type. - * - * @param string $mimeType The associated mime type - * - * @return string The format (null if not found) - * - * @api - */ - public function getFormat($mimeType) - { - if (false !== $pos = strpos($mimeType, ';')) { - $mimeType = substr($mimeType, 0, $pos); - } - - if (null === static::$formats) { - static::initializeFormats(); - } - - foreach (static::$formats as $format => $mimeTypes) { - if (in_array($mimeType, (array) $mimeTypes)) { - return $format; - } - } - - return null; - } - - /** - * Associates a format with mime types. - * - * @param string $format The format - * @param string|array $mimeTypes The associated mime types (the preferred one must be the first as it will be used as the content type) - * - * @api - */ - public function setFormat($format, $mimeTypes) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes); - } - - /** - * Gets the request format. - * - * Here is the process to determine the format: - * - * * format defined by the user (with setRequestFormat()) - * * _format request parameter - * * $default - * - * @param string $default The default format - * - * @return string The request format - * - * @api - */ - public function getRequestFormat($default = 'html') - { - if (null === $this->format) { - $this->format = $this->get('_format', $default); - } - - return $this->format; - } - - /** - * Sets the request format. - * - * @param string $format The request format. - * - * @api - */ - public function setRequestFormat($format) - { - $this->format = $format; - } - - /** - * Gets the format associated with the request. - * - * @return string The format (null if no content type is present) - * - * @api - */ - public function getContentType() - { - return $this->getFormat($this->server->get('CONTENT_TYPE')); - } - - /** - * Sets the default locale. - * - * @param string $locale - * - * @api - */ - public function setDefaultLocale($locale) - { - $this->setPhpDefaultLocale($this->defaultLocale = $locale); - } - - /** - * Sets the locale. - * - * @param string $locale - * - * @api - */ - public function setLocale($locale) - { - $this->setPhpDefaultLocale($this->locale = $locale); - } - - /** - * Get the locale. - * - * @return string - */ - public function getLocale() - { - return null === $this->locale ? $this->defaultLocale : $this->locale; - } - - /** - * Checks if the request method is of specified type. - * - * @param string $method Uppercase request method (GET, POST etc). - * - * @return Boolean - */ - public function isMethod($method) - { - return $this->getMethod() === strtoupper($method); - } - - /** - * Checks whether the method is safe or not. - * - * @return Boolean - * - * @api - */ - public function isMethodSafe() - { - return in_array($this->getMethod(), array('GET', 'HEAD')); - } - - /** - * Returns the request body content. - * - * @param Boolean $asResource If true, a resource will be returned - * - * @return string|resource The request body content or a resource to read the body stream. - */ - public function getContent($asResource = false) - { - if (false === $this->content || (true === $asResource && null !== $this->content)) { - throw new \LogicException('getContent() can only be called once when using the resource return type.'); - } - - if (true === $asResource) { - $this->content = false; - - return fopen('php://input', 'rb'); - } - - if (null === $this->content) { - $this->content = file_get_contents('php://input'); - } - - return $this->content; - } - - /** - * Gets the Etags. - * - * @return array The entity tags - */ - public function getETags() - { - return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY); - } - - public function isNoCache() - { - return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma'); - } - - /** - * Returns the preferred language. - * - * @param array $locales An array of ordered available locales - * - * @return string|null The preferred locale - * - * @api - */ - public function getPreferredLanguage(array $locales = null) - { - $preferredLanguages = $this->getLanguages(); - - if (empty($locales)) { - return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null; - } - - if (!$preferredLanguages) { - return $locales[0]; - } - - $preferredLanguages = array_values(array_intersect($preferredLanguages, $locales)); - - return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0]; - } - - /** - * Gets a list of languages acceptable by the client browser. - * - * @return array Languages ordered in the user browser preferences - * - * @api - */ - public function getLanguages() - { - if (null !== $this->languages) { - return $this->languages; - } - - $languages = $this->splitHttpAcceptHeader($this->headers->get('Accept-Language')); - $this->languages = array(); - foreach ($languages as $lang => $q) { - if (strstr($lang, '-')) { - $codes = explode('-', $lang); - if ($codes[0] == 'i') { - // Language not listed in ISO 639 that are not variants - // of any listed language, which can be registered with the - // i-prefix, such as i-cherokee - if (count($codes) > 1) { - $lang = $codes[1]; - } - } else { - for ($i = 0, $max = count($codes); $i < $max; $i++) { - if ($i == 0) { - $lang = strtolower($codes[0]); - } else { - $lang .= '_'.strtoupper($codes[$i]); - } - } - } - } - - $this->languages[] = $lang; - } - - return $this->languages; - } - - /** - * Gets a list of charsets acceptable by the client browser. - * - * @return array List of charsets in preferable order - * - * @api - */ - public function getCharsets() - { - if (null !== $this->charsets) { - return $this->charsets; - } - - return $this->charsets = array_keys($this->splitHttpAcceptHeader($this->headers->get('Accept-Charset'))); - } - - /** - * Gets a list of content types acceptable by the client browser - * - * @return array List of content types in preferable order - * - * @api - */ - public function getAcceptableContentTypes() - { - if (null !== $this->acceptableContentTypes) { - return $this->acceptableContentTypes; - } - - return $this->acceptableContentTypes = array_keys($this->splitHttpAcceptHeader($this->headers->get('Accept'))); - } - - /** - * Returns true if the request is a XMLHttpRequest. - * - * It works if your JavaScript library set an X-Requested-With HTTP header. - * It is known to work with Prototype, Mootools, jQuery. - * - * @return Boolean true if the request is an XMLHttpRequest, false otherwise - * - * @api - */ - public function isXmlHttpRequest() - { - return 'XMLHttpRequest' == $this->headers->get('X-Requested-With'); - } - - /** - * Splits an Accept-* HTTP header. - * - * @param string $header Header to split - * - * @return array Array indexed by the values of the Accept-* header in preferred order - */ - public function splitHttpAcceptHeader($header) - { - if (!$header) { - return array(); - } - - $values = array(); - foreach (array_filter(explode(',', $header)) as $value) { - // Cut off any q-value that might come after a semi-colon - if (preg_match('/;\s*(q=.*$)/', $value, $match)) { - $q = (float) substr(trim($match[1]), 2); - $value = trim(substr($value, 0, -strlen($match[0]))); - } else { - $q = 1; - } - - if (0 < $q) { - $values[trim($value)] = $q; - } - } - - arsort($values); - reset($values); - - return $values; - } - - /* - * The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24) - * - * Code subject to the new BSD license (http://framework.zend.com/license/new-bsd). - * - * Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - */ - - protected function prepareRequestUri() - { - $requestUri = ''; - - if ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) { - // check this first so IIS will catch - $requestUri = $this->headers->get('X_REWRITE_URL'); - } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') { - // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) - $requestUri = $this->server->get('UNENCODED_URL'); - } elseif ($this->server->has('REQUEST_URI')) { - $requestUri = $this->server->get('REQUEST_URI'); - // HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path - $schemeAndHttpHost = $this->getScheme().'://'.$this->getHttpHost(); - if (strpos($requestUri, $schemeAndHttpHost) === 0) { - $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); - } - } elseif ($this->server->has('ORIG_PATH_INFO')) { - // IIS 5.0, PHP as CGI - $requestUri = $this->server->get('ORIG_PATH_INFO'); - if ($this->server->get('QUERY_STRING')) { - $requestUri .= '?'.$this->server->get('QUERY_STRING'); - } - } - - return $requestUri; - } - - /** - * Prepares the base URL. - * - * @return string - */ - protected function prepareBaseUrl() - { - $filename = basename($this->server->get('SCRIPT_FILENAME')); - - if (basename($this->server->get('SCRIPT_NAME')) === $filename) { - $baseUrl = $this->server->get('SCRIPT_NAME'); - } elseif (basename($this->server->get('PHP_SELF')) === $filename) { - $baseUrl = $this->server->get('PHP_SELF'); - } elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) { - $baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility - } else { - // Backtrack up the script_filename to find the portion matching - // php_self - $path = $this->server->get('PHP_SELF', ''); - $file = $this->server->get('SCRIPT_FILENAME', ''); - $segs = explode('/', trim($file, '/')); - $segs = array_reverse($segs); - $index = 0; - $last = count($segs); - $baseUrl = ''; - do { - $seg = $segs[$index]; - $baseUrl = '/'.$seg.$baseUrl; - ++$index; - } while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos)); - } - - // Does the baseUrl have anything in common with the request_uri? - $requestUri = $this->getRequestUri(); - - if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) { - // full $baseUrl matches - return $prefix; - } - - if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl))) { - // directory portion of $baseUrl matches - return rtrim($prefix, '/'); - } - - $truncatedRequestUri = $requestUri; - if (($pos = strpos($requestUri, '?')) !== false) { - $truncatedRequestUri = substr($requestUri, 0, $pos); - } - - $basename = basename($baseUrl); - if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) { - // no match whatsoever; set it blank - return ''; - } - - // If using mod_rewrite or ISAPI_Rewrite strip the script filename - // out of baseUrl. $pos !== 0 makes sure it is not matching a value - // from PATH_INFO or QUERY_STRING - if ((strlen($requestUri) >= strlen($baseUrl)) && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0))) { - $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); - } - - return rtrim($baseUrl, '/'); - } - - /** - * Prepares the base path. - * - * @return string base path - */ - protected function prepareBasePath() - { - $filename = basename($this->server->get('SCRIPT_FILENAME')); - $baseUrl = $this->getBaseUrl(); - if (empty($baseUrl)) { - return ''; - } - - if (basename($baseUrl) === $filename) { - $basePath = dirname($baseUrl); - } else { - $basePath = $baseUrl; - } - - if ('\\' === DIRECTORY_SEPARATOR) { - $basePath = str_replace('\\', '/', $basePath); - } - - return rtrim($basePath, '/'); - } - - /** - * Prepares the path info. - * - * @return string path info - */ - protected function preparePathInfo() - { - $baseUrl = $this->getBaseUrl(); - - if (null === ($requestUri = $this->getRequestUri())) { - return '/'; - } - - $pathInfo = '/'; - - // Remove the query string from REQUEST_URI - if ($pos = strpos($requestUri, '?')) { - $requestUri = substr($requestUri, 0, $pos); - } - - if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) { - // If substr() returns false then PATH_INFO is set to an empty string - return '/'; - } elseif (null === $baseUrl) { - return $requestUri; - } - - return (string) $pathInfo; - } - - /** - * Initializes HTTP request formats. - */ - static protected function initializeFormats() - { - static::$formats = array( - 'html' => array('text/html', 'application/xhtml+xml'), - 'txt' => array('text/plain'), - 'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'), - 'css' => array('text/css'), - 'json' => array('application/json', 'application/x-json'), - 'xml' => array('text/xml', 'application/xml', 'application/x-xml'), - 'rdf' => array('application/rdf+xml'), - 'atom' => array('application/atom+xml'), - 'rss' => array('application/rss+xml'), - ); - } - - /** - * Sets the default PHP locale. - * - * @param string $locale - */ - private function setPhpDefaultLocale($locale) - { - // if either the class Locale doesn't exist, or an exception is thrown when - // setting the default locale, the intl module is not installed, and - // the call can be ignored: - try { - if (class_exists('Locale', false)) { - \Locale::setDefault($locale); - } - } catch (\Exception $e) { - } - } - - /* - * Returns the prefix as encoded in the string when the string starts with - * the given prefix, false otherwise. - * - * @param string $string The urlencoded string - * @param string $prefix The prefix not encoded - * - * @return string|false The prefix as it is encoded in $string, or false - */ - private function getUrlencodedPrefix($string, $prefix) - { - if (0 !== strpos(rawurldecode($string), $prefix)) { - return false; - } - - $len = strlen($prefix); - - if (preg_match("#^(%[[:xdigit:]]{2}|.){{$len}}#", $string, $match)) { - return $match[0]; - } - - return false; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/RequestMatcherInterface.php b/core/vendor/Symfony/Component/HttpFoundation/RequestMatcherInterface.php deleted file mode 100644 index 506ec79401533fe19f70254c2f3606b07ad7045f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/RequestMatcherInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RequestMatcherInterface is an interface for strategies to match a Request. - * - * @author Fabien Potencier - * - * @api - */ -interface RequestMatcherInterface -{ - /** - * Decides whether the rule(s) implemented by the strategy matches the supplied request. - * - * @param Request $request The request to check for a match - * - * @return Boolean true if the request matches, false otherwise - * - * @api - */ - function matches(Request $request); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php b/core/vendor/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php deleted file mode 100644 index 4378b814bef6f52cde4d8246d12b0fbf00a59c91..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * SessionHandlerInterface - * - * Provides forward compatability with PHP 5.4 - * - * Extensive documentation can be found at php.net, see links: - * - * @see http://php.net/sessionhandlerinterface - * @see http://php.net/session.customhandler - * @see http://php.net/session-set-save-handler - * - * @author Drak - */ -interface SessionHandlerInterface -{ - /** - * Open session. - * - * @see http://php.net/sessionhandlerinterface.open - * - * @param string $savePath Save path. - * @param string $sessionName Session Name. - * - * @throws \RuntimeException If something goes wrong starting the session. - * - * @return boolean - */ - function open($savePath, $sessionName); - - /** - * Close session. - * - * @see http://php.net/sessionhandlerinterface.close - * - * @return boolean - */ - function close(); - - /** - * Read session. - * - * @see http://php.net/sessionhandlerinterface.read - * - * @throws \RuntimeException On fatal error but not "record not found". - * - * @return string String as stored in persistent storage or empty string in all other cases. - */ - function read($sessionId); - - /** - * Commit session to storage. - * - * @see http://php.net/sessionhandlerinterface.write - * - * @param string $sessionId Session ID. - * @param string $data Session serialized data to save. - * - * @return boolean - */ - function write($sessionId, $data); - - /** - * Destroys this session. - * - * @see http://php.net/sessionhandlerinterface.destroy - * - * @param string $sessionId Session ID. - * - * @throws \RuntimeException On fatal error. - * - * @return boolean - */ - function destroy($sessionId); - - /** - * Garbage collection for storage. - * - * @see http://php.net/sessionhandlerinterface.gc - * - * @param integer $lifetime Max lifetime in seconds to keep sessions stored. - * - * @throws \RuntimeException On fatal error. - * - * @return boolean - */ - function gc($lifetime); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Response.php b/core/vendor/Symfony/Component/HttpFoundation/Response.php deleted file mode 100644 index 5d443ef488d98e037a63211d836ea250fe1c5686..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Response.php +++ /dev/null @@ -1,1117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Response represents an HTTP response. - * - * @author Fabien Potencier - * - * @api - */ -class Response -{ - /** - * @var \Symfony\Component\HttpFoundation\ResponseHeaderBag - */ - public $headers; - - /** - * @var string - */ - protected $content; - - /** - * @var string - */ - protected $version; - - /** - * @var integer - */ - protected $statusCode; - - /** - * @var string - */ - protected $statusText; - - /** - * @var string - */ - protected $charset; - - /** - * Status codes translation table. - * - * The list of codes is complete according to the - * {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry} - * (last updated 2012-02-13). - * - * Unless otherwise noted, the status code is defined in RFC2616. - * - * @var array - */ - static public $statusTexts = array( - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', // RFC2518 - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', // RFC4918 - 208 => 'Already Reported', // RFC5842 - 226 => 'IM Used', // RFC3229 - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 306 => 'Reserved', - 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', // RFC-reschke-http-status-308-07 - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 418 => 'I\'m a teapot', - 422 => 'Unprocessable Entity', // RFC4918 - 423 => 'Locked', // RFC4918 - 424 => 'Failed Dependency', // RFC4918 - 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 - 426 => 'Upgrade Required', // RFC2817 - 428 => 'Precondition Required', // RFC-nottingham-http-new-status-04 - 429 => 'Too Many Requests', // RFC-nottingham-http-new-status-04 - 431 => 'Request Header Fields Too Large', // RFC-nottingham-http-new-status-04 - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates (Experimental)', // [RFC2295] - 507 => 'Insufficient Storage', // RFC4918 - 508 => 'Loop Detected', // RFC5842 - 510 => 'Not Extended', // RFC2774 - 511 => 'Network Authentication Required', // RFC-nottingham-http-new-status-04 - ); - - /** - * Constructor. - * - * @param string $content The response content - * @param integer $status The response status code - * @param array $headers An array of response headers - * - * @api - */ - public function __construct($content = '', $status = 200, $headers = array()) - { - $this->headers = new ResponseHeaderBag($headers); - $this->setContent($content); - $this->setStatusCode($status); - $this->setProtocolVersion('1.0'); - if (!$this->headers->has('Date')) { - $this->setDate(new \DateTime(null, new \DateTimeZone('UTC'))); - } - } - - /** - * Factory method for chainability - * - * Example: - * - * return Response::create($body, 200) - * ->setSharedMaxAge(300); - * - * @param string $content The response content - * @param integer $status The response status code - * @param array $headers An array of response headers - * - * @return Response - */ - static public function create($content = '', $status = 200, $headers = array()) - { - return new static($content, $status, $headers); - } - - /** - * Returns the Response as an HTTP string. - * - * The string representation of the Response is the same as the - * one that will be sent to the client only if the prepare() method - * has been called before. - * - * @return string The Response as an HTTP string - * - * @see prepare() - */ - public function __toString() - { - return - sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n". - $this->headers."\r\n". - $this->getContent(); - } - - /** - * Clones the current Response instance. - */ - public function __clone() - { - $this->headers = clone $this->headers; - } - - /** - * Prepares the Response before it is sent to the client. - * - * This method tweaks the Response to ensure that it is - * compliant with RFC 2616. Most of the changes are based on - * the Request that is "associated" with this Response. - * - * @param Request $request A Request instance - * - * @return Response The current response. - */ - public function prepare(Request $request) - { - $headers = $this->headers; - - if ($this->isInformational() || in_array($this->statusCode, array(204, 304))) { - $this->setContent(''); - } - - // Content-type based on the Request - if (!$headers->has('Content-Type')) { - $format = $request->getRequestFormat(); - if (null !== $format && $mimeType = $request->getMimeType($format)) { - $headers->set('Content-Type', $mimeType); - } - } - - // Fix Content-Type - $charset = $this->charset ?: 'UTF-8'; - if (!$headers->has('Content-Type')) { - $headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === strpos($headers->get('Content-Type'), 'text/') && false === strpos($headers->get('Content-Type'), 'charset')) { - // add the charset - $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); - } - - // Fix Content-Length - if ($headers->has('Transfer-Encoding')) { - $headers->remove('Content-Length'); - } - - if ('HEAD' === $request->getMethod()) { - // cf. RFC2616 14.13 - $length = $headers->get('Content-Length'); - $this->setContent(''); - if ($length) { - $headers->set('Content-Length', $length); - } - } - - return $this; - } - - /** - * Sends HTTP headers. - * - * @return Response - */ - public function sendHeaders() - { - // headers have already been sent by the developer - if (headers_sent()) { - return $this; - } - - // status - header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)); - - // headers - foreach ($this->headers->all() as $name => $values) { - foreach ($values as $value) { - header($name.': '.$value, false); - } - } - - // cookies - foreach ($this->headers->getCookies() as $cookie) { - setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - - return $this; - } - - /** - * Sends content for the current web response. - * - * @return Response - */ - public function sendContent() - { - echo $this->content; - - return $this; - } - - /** - * Sends HTTP headers and content. - * - * @return Response - * - * @api - */ - public function send() - { - $this->sendHeaders(); - $this->sendContent(); - - if (function_exists('fastcgi_finish_request')) { - fastcgi_finish_request(); - } - - return $this; - } - - /** - * Sets the response content. - * - * Valid types are strings, numbers, and objects that implement a __toString() method. - * - * @param mixed $content - * - * @return Response - * - * @api - */ - public function setContent($content) - { - if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) { - throw new \UnexpectedValueException('The Response content must be a string or object implementing __toString(), "'.gettype($content).'" given.'); - } - - $this->content = (string) $content; - - return $this; - } - - /** - * Gets the current response content. - * - * @return string Content - * - * @api - */ - public function getContent() - { - return $this->content; - } - - /** - * Sets the HTTP protocol version (1.0 or 1.1). - * - * @param string $version The HTTP protocol version - * - * @return Response - * - * @api - */ - public function setProtocolVersion($version) - { - $this->version = $version; - - return $this; - } - - /** - * Gets the HTTP protocol version. - * - * @return string The HTTP protocol version - * - * @api - */ - public function getProtocolVersion() - { - return $this->version; - } - - /** - * Sets the response status code. - * - * @param integer $code HTTP status code - * @param string $text HTTP status text - * - * @return Response - * - * @throws \InvalidArgumentException When the HTTP status code is not valid - * - * @api - */ - public function setStatusCode($code, $text = null) - { - $this->statusCode = (int) $code; - if ($this->isInvalid()) { - throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code)); - } - - $this->statusText = false === $text ? '' : (null === $text ? self::$statusTexts[$this->statusCode] : $text); - - return $this; - } - - /** - * Retrieves the status code for the current web response. - * - * @return string Status code - * - * @api - */ - public function getStatusCode() - { - return $this->statusCode; - } - - /** - * Sets the response charset. - * - * @param string $charset Character set - * - * @return Response - * - * @api - */ - public function setCharset($charset) - { - $this->charset = $charset; - - return $this; - } - - /** - * Retrieves the response charset. - * - * @return string Character set - * - * @api - */ - public function getCharset() - { - return $this->charset; - } - - /** - * Returns true if the response is worth caching under any circumstance. - * - * Responses marked "private" with an explicit Cache-Control directive are - * considered uncacheable. - * - * Responses with neither a freshness lifetime (Expires, max-age) nor cache - * validator (Last-Modified, ETag) are considered uncacheable. - * - * @return Boolean true if the response is worth caching, false otherwise - * - * @api - */ - public function isCacheable() - { - if (!in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) { - return false; - } - - if ($this->headers->hasCacheControlDirective('no-store') || $this->headers->getCacheControlDirective('private')) { - return false; - } - - return $this->isValidateable() || $this->isFresh(); - } - - /** - * Returns true if the response is "fresh". - * - * Fresh responses may be served from cache without any interaction with the - * origin. A response is considered fresh when it includes a Cache-Control/max-age - * indicator or Expiration header and the calculated age is less than the freshness lifetime. - * - * @return Boolean true if the response is fresh, false otherwise - * - * @api - */ - public function isFresh() - { - return $this->getTtl() > 0; - } - - /** - * Returns true if the response includes headers that can be used to validate - * the response with the origin server using a conditional GET request. - * - * @return Boolean true if the response is validateable, false otherwise - * - * @api - */ - public function isValidateable() - { - return $this->headers->has('Last-Modified') || $this->headers->has('ETag'); - } - - /** - * Marks the response as "private". - * - * It makes the response ineligible for serving other clients. - * - * @return Response - * - * @api - */ - public function setPrivate() - { - $this->headers->removeCacheControlDirective('public'); - $this->headers->addCacheControlDirective('private'); - - return $this; - } - - /** - * Marks the response as "public". - * - * It makes the response eligible for serving other clients. - * - * @return Response - * - * @api - */ - public function setPublic() - { - $this->headers->addCacheControlDirective('public'); - $this->headers->removeCacheControlDirective('private'); - - return $this; - } - - /** - * Returns true if the response must be revalidated by caches. - * - * This method indicates that the response must not be served stale by a - * cache in any circumstance without first revalidating with the origin. - * When present, the TTL of the response should not be overridden to be - * greater than the value provided by the origin. - * - * @return Boolean true if the response must be revalidated by a cache, false otherwise - * - * @api - */ - public function mustRevalidate() - { - return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->has('must-proxy-revalidate'); - } - - /** - * Returns the Date header as a DateTime instance. - * - * @return \DateTime A \DateTime instance - * - * @throws \RuntimeException When the header is not parseable - * - * @api - */ - public function getDate() - { - return $this->headers->getDate('Date'); - } - - /** - * Sets the Date header. - * - * @param \DateTime $date A \DateTime instance - * - * @return Response - * - * @api - */ - public function setDate(\DateTime $date) - { - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT'); - - return $this; - } - - /** - * Returns the age of the response. - * - * @return integer The age of the response in seconds - */ - public function getAge() - { - if ($age = $this->headers->get('Age')) { - return $age; - } - - return max(time() - $this->getDate()->format('U'), 0); - } - - /** - * Marks the response stale by setting the Age header to be equal to the maximum age of the response. - * - * @return Response - * - * @api - */ - public function expire() - { - if ($this->isFresh()) { - $this->headers->set('Age', $this->getMaxAge()); - } - - return $this; - } - - /** - * Returns the value of the Expires header as a DateTime instance. - * - * @return \DateTime A DateTime instance - * - * @api - */ - public function getExpires() - { - return $this->headers->getDate('Expires'); - } - - /** - * Sets the Expires HTTP header with a DateTime instance. - * - * If passed a null value, it removes the header. - * - * @param \DateTime $date A \DateTime instance - * - * @return Response - * - * @api - */ - public function setExpires(\DateTime $date = null) - { - if (null === $date) { - $this->headers->remove('Expires'); - } else { - $date = clone $date; - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT'); - } - - return $this; - } - - /** - * Sets the number of seconds after the time specified in the response's Date - * header when the the response should no longer be considered fresh. - * - * First, it checks for a s-maxage directive, then a max-age directive, and then it falls - * back on an expires header. It returns null when no maximum age can be established. - * - * @return integer|null Number of seconds - * - * @api - */ - public function getMaxAge() - { - if ($age = $this->headers->getCacheControlDirective('s-maxage')) { - return $age; - } - - if ($age = $this->headers->getCacheControlDirective('max-age')) { - return $age; - } - - if (null !== $this->getExpires()) { - return $this->getExpires()->format('U') - $this->getDate()->format('U'); - } - - return null; - } - - /** - * Sets the number of seconds after which the response should no longer be considered fresh. - * - * This methods sets the Cache-Control max-age directive. - * - * @param integer $value Number of seconds - * - * @return Response - * - * @api - */ - public function setMaxAge($value) - { - $this->headers->addCacheControlDirective('max-age', $value); - - return $this; - } - - /** - * Sets the number of seconds after which the response should no longer be considered fresh by shared caches. - * - * This methods sets the Cache-Control s-maxage directive. - * - * @param integer $value Number of seconds - * - * @return Response - * - * @api - */ - public function setSharedMaxAge($value) - { - $this->setPublic(); - $this->headers->addCacheControlDirective('s-maxage', $value); - - return $this; - } - - /** - * Returns the response's time-to-live in seconds. - * - * It returns null when no freshness information is present in the response. - * - * When the responses TTL is <= 0, the response may not be served from cache without first - * revalidating with the origin. - * - * @return integer The TTL in seconds - * - * @api - */ - public function getTtl() - { - if ($maxAge = $this->getMaxAge()) { - return $maxAge - $this->getAge(); - } - - return null; - } - - /** - * Sets the response's time-to-live for shared caches. - * - * This method adjusts the Cache-Control/s-maxage directive. - * - * @param integer $seconds Number of seconds - * - * @return Response - * - * @api - */ - public function setTtl($seconds) - { - $this->setSharedMaxAge($this->getAge() + $seconds); - - return $this; - } - - /** - * Sets the response's time-to-live for private/client caches. - * - * This method adjusts the Cache-Control/max-age directive. - * - * @param integer $seconds Number of seconds - * - * @return Response - * - * @api - */ - public function setClientTtl($seconds) - { - $this->setMaxAge($this->getAge() + $seconds); - - return $this; - } - - /** - * Returns the Last-Modified HTTP header as a DateTime instance. - * - * @return \DateTime A DateTime instance - * - * @api - */ - public function getLastModified() - { - return $this->headers->getDate('Last-Modified'); - } - - /** - * Sets the Last-Modified HTTP header with a DateTime instance. - * - * If passed a null value, it removes the header. - * - * @param \DateTime $date A \DateTime instance - * - * @return Response - * - * @api - */ - public function setLastModified(\DateTime $date = null) - { - if (null === $date) { - $this->headers->remove('Last-Modified'); - } else { - $date = clone $date; - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT'); - } - - return $this; - } - - /** - * Returns the literal value of the ETag HTTP header. - * - * @return string The ETag HTTP header - * - * @api - */ - public function getEtag() - { - return $this->headers->get('ETag'); - } - - /** - * Sets the ETag value. - * - * @param string $etag The ETag unique identifier - * @param Boolean $weak Whether you want a weak ETag or not - * - * @return Response - * - * @api - */ - public function setEtag($etag = null, $weak = false) - { - if (null === $etag) { - $this->headers->remove('Etag'); - } else { - if (0 !== strpos($etag, '"')) { - $etag = '"'.$etag.'"'; - } - - $this->headers->set('ETag', (true === $weak ? 'W/' : '').$etag); - } - - return $this; - } - - /** - * Sets the response's cache headers (validation and/or expiration). - * - * Available options are: etag, last_modified, max_age, s_maxage, private, and public. - * - * @param array $options An array of cache options - * - * @return Response - * - * @api - */ - public function setCache(array $options) - { - if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) { - throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff)))); - } - - if (isset($options['etag'])) { - $this->setEtag($options['etag']); - } - - if (isset($options['last_modified'])) { - $this->setLastModified($options['last_modified']); - } - - if (isset($options['max_age'])) { - $this->setMaxAge($options['max_age']); - } - - if (isset($options['s_maxage'])) { - $this->setSharedMaxAge($options['s_maxage']); - } - - if (isset($options['public'])) { - if ($options['public']) { - $this->setPublic(); - } else { - $this->setPrivate(); - } - } - - if (isset($options['private'])) { - if ($options['private']) { - $this->setPrivate(); - } else { - $this->setPublic(); - } - } - - return $this; - } - - /** - * Modifies the response so that it conforms to the rules defined for a 304 status code. - * - * This sets the status, removes the body, and discards any headers - * that MUST NOT be included in 304 responses. - * - * @return Response - * - * @see http://tools.ietf.org/html/rfc2616#section-10.3.5 - * - * @api - */ - public function setNotModified() - { - $this->setStatusCode(304); - $this->setContent(null); - - // remove headers that MUST NOT be included with 304 Not Modified responses - foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) { - $this->headers->remove($header); - } - - return $this; - } - - /** - * Returns true if the response includes a Vary header. - * - * @return Boolean true if the response includes a Vary header, false otherwise - * - * @api - */ - public function hasVary() - { - return (Boolean) $this->headers->get('Vary'); - } - - /** - * Returns an array of header names given in the Vary header. - * - * @return array An array of Vary names - * - * @api - */ - public function getVary() - { - if (!$vary = $this->headers->get('Vary')) { - return array(); - } - - return is_array($vary) ? $vary : preg_split('/[\s,]+/', $vary); - } - - /** - * Sets the Vary header. - * - * @param string|array $headers - * @param Boolean $replace Whether to replace the actual value of not (true by default) - * - * @return Response - * - * @api - */ - public function setVary($headers, $replace = true) - { - $this->headers->set('Vary', $headers, $replace); - - return $this; - } - - /** - * Determines if the Response validators (ETag, Last-Modified) match - * a conditional value specified in the Request. - * - * If the Response is not modified, it sets the status code to 304 and - * removes the actual content by calling the setNotModified() method. - * - * @param Request $request A Request instance - * - * @return Boolean true if the Response validators match the Request, false otherwise - * - * @api - */ - public function isNotModified(Request $request) - { - $lastModified = $request->headers->get('If-Modified-Since'); - $notModified = false; - if ($etags = $request->getEtags()) { - $notModified = (in_array($this->getEtag(), $etags) || in_array('*', $etags)) && (!$lastModified || $this->headers->get('Last-Modified') == $lastModified); - } elseif ($lastModified) { - $notModified = $lastModified == $this->headers->get('Last-Modified'); - } - - if ($notModified) { - $this->setNotModified(); - } - - return $notModified; - } - - // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - /** - * Is response invalid? - * - * @return Boolean - * - * @api - */ - public function isInvalid() - { - return $this->statusCode < 100 || $this->statusCode >= 600; - } - - /** - * Is response informative? - * - * @return Boolean - * - * @api - */ - public function isInformational() - { - return $this->statusCode >= 100 && $this->statusCode < 200; - } - - /** - * Is response successful? - * - * @return Boolean - * - * @api - */ - public function isSuccessful() - { - return $this->statusCode >= 200 && $this->statusCode < 300; - } - - /** - * Is the response a redirect? - * - * @return Boolean - * - * @api - */ - public function isRedirection() - { - return $this->statusCode >= 300 && $this->statusCode < 400; - } - - /** - * Is there a client error? - * - * @return Boolean - * - * @api - */ - public function isClientError() - { - return $this->statusCode >= 400 && $this->statusCode < 500; - } - - /** - * Was there a server side error? - * - * @return Boolean - * - * @api - */ - public function isServerError() - { - return $this->statusCode >= 500 && $this->statusCode < 600; - } - - /** - * Is the response OK? - * - * @return Boolean - * - * @api - */ - public function isOk() - { - return 200 === $this->statusCode; - } - - /** - * Is the reponse forbidden? - * - * @return Boolean - * - * @api - */ - public function isForbidden() - { - return 403 === $this->statusCode; - } - - /** - * Is the response a not found error? - * - * @return Boolean - * - * @api - */ - public function isNotFound() - { - return 404 === $this->statusCode; - } - - /** - * Is the response a redirect of some form? - * - * @param string $location - * - * @return Boolean - * - * @api - */ - public function isRedirect($location = null) - { - return in_array($this->statusCode, array(201, 301, 302, 303, 307)) && (null === $location ?: $location == $this->headers->get('Location')); - } - - /** - * Is the response empty? - * - * @return Boolean - * - * @api - */ - public function isEmpty() - { - return in_array($this->statusCode, array(201, 204, 304)); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/ServerBag.php b/core/vendor/Symfony/Component/HttpFoundation/ServerBag.php deleted file mode 100644 index 6a077f4b8d2691d645b2e901589dc182277cb986..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/ServerBag.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ServerBag is a container for HTTP headers from the $_SERVER variable. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - */ -class ServerBag extends ParameterBag -{ - /** - * Gets the HTTP headers. - * - * @return string - */ - public function getHeaders() - { - $headers = array(); - foreach ($this->parameters as $key => $value) { - if (0 === strpos($key, 'HTTP_')) { - $headers[substr($key, 5)] = $value; - } - // CONTENT_* are not prefixed with HTTP_ - elseif (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) { - $headers[$key] = $value; - } - } - - // PHP_AUTH_USER/PHP_AUTH_PW - if (isset($this->parameters['PHP_AUTH_USER'])) { - $pass = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : ''; - $headers['AUTHORIZATION'] = 'Basic '.base64_encode($this->parameters['PHP_AUTH_USER'].':'.$pass); - } - - return $headers; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php deleted file mode 100644 index 7da1227096019e46c44123061a6ab1ce40f9e911..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * FlashBagInterface. - * - * @author Drak - */ -interface FlashBagInterface extends SessionBagInterface -{ - /** - * Adds a flash message for type. - * - * @param string $type - * @param string $message - */ - public function add($type, $message); - - /** - * Registers a message for a given type. - * - * @param string $type - * @param string $message - */ - function set($type, $message); - - /** - * Gets flash message for a given type. - * - * @param string $type Message category type. - * @param array $default Default value if $type doee not exist. - * - * @return string - */ - function peek($type, array $default = array()); - - /** - * Gets all flash messages. - * - * @return array - */ - function peekAll(); - - /** - * Gets and clears flash from the stack. - * - * @param string $type - * @param array $default Default value if $type doee not exist. - * - * @return string - */ - function get($type, array $default = array()); - - /** - * Gets and clears flashes from the stack. - * - * @return array - */ - function all(); - - /** - * Sets all flash messages. - */ - function setAll(array $messages); - - /** - * Has flash messages for a given type? - * - * @param string $type - * - * @return boolean - */ - function has($type); - - /** - * Returns a list of all defined types. - * - * @return array - */ - function keys(); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Session.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Session.php deleted file mode 100644 index 0c40c1c32f89c9b800eea819d614f01016a03482..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Session.php +++ /dev/null @@ -1,335 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Session. - * - * @author Fabien Potencier - * @author Drak - * - * @api - */ -class Session implements SessionInterface, \IteratorAggregate, \Countable -{ - /** - * Storage driver. - * - * @var SessionStorageInterface - */ - protected $storage; - - /** - * @var string - */ - private $flashName; - - /** - * @var string - */ - private $attributeName; - - /** - * Constructor. - * - * @param SessionStorageInterface $storage A SessionStorageInterface instance. - * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) - * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) - */ - public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) - { - $this->storage = $storage ?: new NativeSessionStorage(); - - $attributes = $attributes ?: new AttributeBag(); - $this->attributeName = $attributes->getName(); - $this->registerBag($attributes); - - $flashes = $flashes ?: new FlashBag(); - $this->flashName = $flashes->getName(); - $this->registerBag($flashes); - } - - /** - * {@inheritdoc} - */ - public function start() - { - return $this->storage->start(); - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - return $this->storage->getBag($this->attributeName)->has($name); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - return $this->storage->getBag($this->attributeName)->get($name, $default); - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $this->storage->getBag($this->attributeName)->set($name, $value); - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->storage->getBag($this->attributeName)->all(); - } - - /** - * {@inheritdoc} - */ - public function replace(array $attributes) - { - $this->storage->getBag($this->attributeName)->replace($attributes); - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - return $this->storage->getBag($this->attributeName)->remove($name); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $this->storage->getBag($this->attributeName)->clear(); - } - - /** - * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->storage->getBag($this->attributeName)->all()); - } - - /** - * Returns the number of attributes. - * - * @return int The number of attributes - */ - public function count() - { - return count($this->storage->getBag($this->attributeName)->all()); - } - - /** - * {@inheritdoc} - */ - public function invalidate($lifetime = null) - { - $this->storage->clear(); - - return $this->migrate(true, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function migrate($destroy = false, $lifetime = null) - { - return $this->storage->regenerate($destroy, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function save() - { - $this->storage->save(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->storage->getId(); - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - $this->storage->setId($id); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->storage->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->storage->setName($name); - } - - /** - * {@iheritdoc} - */ - public function getMetadataBag() - { - return $this->storage->getMetadataBag(); - } - - /** - * {@iheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->storage->registerBag($bag); - } - - /** - * {@iheritdoc} - */ - public function getBag($name) - { - return $this->storage->getBag($name); - } - - /** - * Gets the flashbag interface. - * - * @return FlashBagInterface - */ - public function getFlashBag() - { - return $this->getBag($this->flashName); - } - - // the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3) - - /** - * @return array - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function getFlashes() - { - $all = $this->getBag($this->flashName)->all(); - - $return = array(); - if ($all) { - foreach ($all as $name => $array) { - $return[$name] = reset($array); - } - } - - return $return; - } - - /** - * @param array $values - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function setFlashes($values) - { - foreach ($values as $name => $value) { - $this->getBag($this->flashName)->set($name, $value); - } - } - - /** - * @param string $name - * @param string $default - * - * @return string - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function getFlash($name, $default = null) - { - $return = $this->getBag($this->flashName)->get($name); - - return empty($return) ? $default : reset($return); - } - - /** - * @param string $name - * @param string $value - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function setFlash($name, $value) - { - $this->getBag($this->flashName)->set($name, $value); - } - - /** - * @param string $name - * - * @return Boolean - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function hasFlash($name) - { - return $this->getBag($this->flashName)->has($name); - } - - /** - * @param string $name - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function removeFlash($name) - { - $this->getBag($this->flashName)->get($name); - } - - /** - * @return array - * - * @deprecated since 2.1, will be removed from 2.3 - */ - public function clearFlashes() - { - return $this->getBag($this->flashName)->clear(); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/SessionInterface.php b/core/vendor/Symfony/Component/HttpFoundation/Session/SessionInterface.php deleted file mode 100644 index 15b4c2924c74b63d8748876c1ee2cae384a17d98..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/SessionInterface.php +++ /dev/null @@ -1,199 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -/** - * Interface for the session. - * - * @author Drak - */ -interface SessionInterface -{ - /** - * Starts the session storage. - * - * @return Boolean True if session started. - * - * @throws \RuntimeException If session fails to start. - * - * @api - */ - function start(); - - /** - * Returns the session ID. - * - * @return string The session ID. - * - * @api - */ - function getId(); - - /** - * Sets the session ID - * - * @param string $id - * - * @api - */ - function setId($id); - - /** - * Returns the session name. - * - * @return mixed The session name. - * - * @api - */ - function getName(); - - /** - * Sets the session name. - * - * @param string $name - * - * @api - */ - function setName($name); - - /** - * Invalidates the current session. - * - * Clears all session attributes and flashes and regenerates the - * session and deletes the old session from persistence. - * - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return Boolean True if session invalidated, false if error. - * - * @api - */ - function invalidate($lifetime = null); - - /** - * Migrates the current session to a new session id while maintaining all - * session attributes. - * - * @param Boolean $destroy Whether to delete the old session or leave it to garbage collection. - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return Boolean True if session migrated, false if error. - * - * @api - */ - function migrate($destroy = false, $lifetime = null); - - /** - * Force the session to be saved and closed. - * - * This method is generally not required for real sessions as - * the session will be automatically saved at the end of - * code execution. - */ - function save(); - - /** - * Checks if an attribute is defined. - * - * @param string $name The attribute name - * - * @return Boolean true if the attribute is defined, false otherwise - * - * @api - */ - function has($name); - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value if not found. - * - * @return mixed - * - * @api - */ - function get($name, $default = null); - - /** - * Sets an attribute. - * - * @param string $name - * @param mixed $value - * - * @api - */ - function set($name, $value); - - /** - * Returns attributes. - * - * @return array Attributes - * - * @api - */ - function all(); - - /** - * Sets attributes. - * - * @param array $attributes Attributes - */ - function replace(array $attributes); - - /** - * Removes an attribute. - * - * @param string $name - * - * @return mixed The removed value - * - * @api - */ - function remove($name); - - /** - * Clears all attributes. - * - * @api - */ - function clear(); - - /** - * Registers a SessionBagInterface with the session. - * - * @param SessionBagInterface $bag - */ - public function registerBag(SessionBagInterface $bag); - - /** - * Gets a bag instance by name. - * - * @param string $name - * - * @return SessionBagInterface - */ - public function getBag($name); - - /** - * Gets session meta. - * - * @return MetadataBag - */ - public function getMetadataBag(); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php deleted file mode 100644 index fe29832f70c54262013938c3179d5d33ce63f902..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * MemcacheSessionHandler. - * - * @author Drak - */ -class MemcacheSessionHandler implements \SessionHandlerInterface -{ - /** - * Memcache driver. - * - * @var \Memcache - */ - private $memcache; - - /** - * Configuration options. - * - * @var array - */ - private $memcacheOptions; - - /** - * Key prefix for shared environments. - * - * @var string - */ - private $prefix; - - /** - * Constructor. - * - * @param \Memcache $memcache A \Memcache instance - * @param array $memcacheOptions An associative array of Memcache options - * @param array $options Session configuration options. - */ - public function __construct(\Memcache $memcache, array $memcacheOptions = array(), array $options = array()) - { - $this->memcache = $memcache; - - // defaults - if (!isset($memcacheOptions['serverpool'])) { - $memcacheOptions['serverpool'] = array(array( - 'host' => '127.0.0.1', - 'port' => 11211, - 'timeout' => 1, - 'persistent' => false, - 'weight' => 1, - 'retry_interval' => 15, - )); - } - - $memcacheOptions['expiretime'] = isset($memcacheOptions['expiretime']) ? (int)$memcacheOptions['expiretime'] : 86400; - $this->prefix = isset($memcacheOptions['prefix']) ? $memcacheOptions['prefix'] : 'sf2s'; - - $this->memcacheOptions = $memcacheOptions; - } - - protected function addServer(array $server) - { - if (!array_key_exists('host', $server)) { - throw new \InvalidArgumentException('host key must be set'); - } - - $server['port'] = isset($server['port']) ? (int)$server['port'] : 11211; - $server['timeout'] = isset($server['timeout']) ? (int)$server['timeout'] : 1; - $server['persistent'] = isset($server['persistent']) ? (bool)$server['persistent'] : false; - $server['weight'] = isset($server['weight']) ? (int)$server['weight'] : 1; - $server['retry_interval'] = isset($server['retry_interval']) ? (int)$server['retry_interval'] : 15; - - $this->memcache->addserver($server['host'], $server['port'], $server['persistent'],$server['weight'],$server['timeout'],$server['retry_interval']); - - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - foreach ($this->memcacheOptions['serverpool'] as $server) { - $this->addServer($server); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return $this->memcache->close(); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return $this->memcache->get($this->prefix.$sessionId) ?: ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - if (!$this->memcache->replace($this->prefix.$sessionId, $data, 0, $this->memcacheOptions['expiretime'])) { - return $this->memcache->set($this->prefix.$sessionId, $data, 0, $this->memcacheOptions['expiretime']); - } - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return $this->memcache->delete($this->prefix.$sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($lifetime) - { - // not required here because memcache will auto expire the records anyhow. - return true; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php deleted file mode 100644 index 71770dda83d732352c3466df8543bff782934b25..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * MemcachedSessionHandler. - * - * Memcached based session storage handler based on the Memcached class - * provided by the PHP memcached extension. - * - * @see http://php.net/memcached - * - * @author Drak - */ -class MemcachedSessionHandler implements \SessionHandlerInterface -{ - /** - * Memcached driver. - * - * @var \Memcached - */ - private $memcached; - - /** - * Configuration options. - * - * @var array - */ - private $memcachedOptions; - - /** - * Constructor. - * - * @param \Memcached $memcached A \Memcached instance - * @param array $memcachedOptions An associative array of Memcached options - * @param array $options Session configuration options. - */ - public function __construct(\Memcached $memcached, array $memcachedOptions = array(), array $options = array()) - { - $this->memcached = $memcached; - - // defaults - if (!isset($memcachedOptions['serverpool'])) { - $memcachedOptions['serverpool'][] = array( - 'host' => '127.0.0.1', - 'port' => 11211, - 'weight' => 1); - } - - $memcachedOptions['expiretime'] = isset($memcachedOptions['expiretime']) ? (int)$memcachedOptions['expiretime'] : 86400; - - $this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s'); - - $this->memcachedOptions = $memcachedOptions; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return $this->memcached->addServers($this->memcachedOptions['serverpool']); - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return $this->memcached->get($sessionId) ?: ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return $this->memcached->set($sessionId, $data, $this->memcachedOptions['expiretime']); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return $this->memcached->delete($sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($lifetime) - { - // not required here because memcached will auto expire the records anyhow. - return true; - } - - /** - * Adds a server to the memcached handler. - * - * @param array $server - */ - protected function addServer(array $server) - { - if (array_key_exists('host', $server)) { - throw new \InvalidArgumentException('host key must be set'); - } - $server['port'] = isset($server['port']) ? (int)$server['port'] : 11211; - $server['timeout'] = isset($server['timeout']) ? (int)$server['timeout'] : 1; - $server['presistent'] = isset($server['presistent']) ? (bool)$server['presistent'] : false; - $server['weight'] = isset($server['weight']) ? (bool)$server['weight'] : 1; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php deleted file mode 100644 index 422e3a79a6ddde3af8c3d5300a359b9d07142180..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeFileSessionHandler. - * - * Native session handler using PHP's built in file storage. - * - * @author Drak - */ -class NativeFileSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP. - */ - public function __construct($savePath = null) - { - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - if ($savePath && !is_dir($savePath)) { - mkdir($savePath, 0777, true); - } - - ini_set('session.save_handler', 'files'); - ini_set('session.save_path', $savePath); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php deleted file mode 100644 index 4fea88b71baa2cb09f5df2164f72eafb0a8548e9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeMemcacheSessionHandler. - * - * Driver for the memcache session save hadlers provided by the memcache PHP extension. - * - * @see http://php.net/memcache - * - * @author Drak - */ -class NativeMemcacheSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of memcache server. - * @param array $options Session configuration options. - */ - public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', array $options = array()) - { - if (!extension_loaded('memcache')) { - throw new \RuntimeException('PHP does not have "memcache" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'memcache'); - ini_set('session.save_path', $savePath); - - $this->setOptions($options); - } - - /** - * Set any memcached ini values. - * - * @see http://php.net/memcache.ini - */ - protected function setOptions(array $options) - { - $validOptions = array_flip(array( - 'memcache.allow_failover', 'memcache.max_failover_attempts', - 'memcache.chunk_size', 'memcache.default_port', 'memcache.hash_strategy', - 'memcache.hash_function', 'memcache.protocol', 'memcache.redundancy', - 'memcache.session_redundancy', 'memcache.compress_threshold', - 'memcache.lock_timeout', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set($key, $value); - } - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php deleted file mode 100644 index 8f646605d2b3bf037f1406077aec98ff208e6b58..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeMemcachedSessionHandler. - * - * Driver for the memcached session save hadlers provided by the memcached PHP extension. - * - * @see http://php.net/memcached.sessions - * - * @author Drak - */ -class NativeMemcachedSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Comma separated list of servers: e.g. memcache1.example.com:11211,memcache2.example.com:11211 - * @param array $options Session configuration options. - */ - public function __construct($savePath = '127.0.0.1:11211', array $options = array()) - { - if (!extension_loaded('memcached')) { - throw new \RuntimeException('PHP does not have "memcached" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'memcached'); - ini_set('session.save_path', $savePath); - - $this->setOptions($options); - } - - /** - * Set any memcached ini values. - * - * @see https://github.com/php-memcached-dev/php-memcached/blob/master/memcached.ini - */ - protected function setOptions(array $options) - { - $validOptions = array_flip(array( - 'memcached.sess_locking', 'memcached.sess_lock_wait', - 'memcached.sess_prefix', 'memcached.compression_type', - 'memcached.compression_factor', 'memcached.compression_threshold', - 'memcached.serializer', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set($key, $value); - } - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php deleted file mode 100644 index d155052a97b3642fba6edb31a828714017842ad1..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeRedisSessionStorage. - * - * Driver for the redis session save hadlers provided by the redis PHP extension. - * - * @see https://github.com/nicolasff/phpredis - * - * @author Andrej Hudec - */ -class NativeRedisSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of redis server. - */ - public function __construct($savePath = 'tcp://127.0.0.1:6379?persistent=0') - { - if (!extension_loaded('redis')) { - throw new \RuntimeException('PHP does not have "redis" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'redis'); - ini_set('session.save_path', $savePath); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php deleted file mode 100644 index 1260ad0d295a9f16bc4d201ee0a8bef265770df4..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Adds SessionHandler functionality if available. - * - * @see http://php.net/sessionhandler - */ - -if (version_compare(phpversion(), '5.4.0', '>=')) { - class NativeSessionHandler extends \SessionHandler {} -} else { - class NativeSessionHandler {} -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php deleted file mode 100644 index 098cc8a68a8dfae5f715df8a94cc1f78ac6f1e52..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeSqliteSessionHandler. - * - * Driver for the sqlite session save hadlers provided by the SQLite PHP extension. - * - * @author Drak - */ -class NativeSqliteSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path to SQLite database file itself. - * @param array $options Session configuration options. - */ - public function __construct($savePath, array $options = array()) - { - if (!extension_loaded('sqlite')) { - throw new \RuntimeException('PHP does not have "sqlite" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'sqlite'); - ini_set('session.save_path', $savePath); - - $this->setOptions($options); - } - - /** - * Set any sqlite ini values. - * - * @see http://php.net/sqlite.configuration - */ - protected function setOptions(array $options) - { - foreach ($options as $key => $value) { - if (in_array($key, array('sqlite.assoc_case'))) { - ini_set($key, $value); - } - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php deleted file mode 100644 index dd9f0c79aebe9c5365453cca6cc89639623d2b01..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NullSessionHandler. - * - * Can be used in unit testing or in a sitation where persisted sessions are not desired. - * - * @author Drak - * - * @api - */ -class NullSessionHandler implements \SessionHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($lifetime) - { - return true; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php deleted file mode 100644 index 28dccba801574ee8c6d5b3a19df0e6de11b8cb20..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ /dev/null @@ -1,221 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * PdoSessionHandler. - * - * @author Fabien Potencier - * @author Michael Williams - */ -class PdoSessionHandler implements \SessionHandlerInterface -{ - /** - * PDO instance. - * - * @var \PDO - */ - private $pdo; - - /** - * Database options. - * - * - * @var array - */ - private $dbOptions; - - /** - * Constructor. - * - * @param \PDO $pdo A \PDO instance - * @param array $dbOptions An associative array of DB options - * @param array $options Session configuration options - * - * @throws \InvalidArgumentException When "db_table" option is not provided - */ - public function __construct(\PDO $pdo, array $dbOptions = array(), array $options = array()) - { - if (!array_key_exists('db_table', $dbOptions)) { - throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); - } - - $this->pdo = $pdo; - $this->dbOptions = array_merge(array( - 'db_id_col' => 'sess_id', - 'db_data_col' => 'sess_data', - 'db_time_col' => 'sess_time', - ), $dbOptions); - } - - /** - * {@inheritdoc} - */ - public function open($path, $name) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($id) - { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbIdCol = $this->dbOptions['db_id_col']; - - // delete the record associated with this id - $sql = "DELETE FROM $dbTable WHERE $dbIdCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($lifetime) - { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbTimeCol = $this->dbOptions['db_time_col']; - - // delete the session records that have expired - $sql = "DELETE FROM $dbTable WHERE $dbTimeCol < (:time - $lifetime)"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function read($id) - { - // get table/columns - $dbTable = $this->dbOptions['db_table']; - $dbDataCol = $this->dbOptions['db_data_col']; - $dbIdCol = $this->dbOptions['db_id_col']; - - try { - $sql = "SELECT $dbDataCol FROM $dbTable WHERE $dbIdCol = :id"; - - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - - $stmt->execute(); - // it is recommended to use fetchAll so that PDO can close the DB cursor - // we anyway expect either no rows, or one row with one column. fetchColumn, seems to be buggy #4777 - $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); - - if (count($sessionRows) == 1) { - return base64_decode($sessionRows[0][0]); - } - - // session does not exist, create it - $this->createNewSession($id); - - return ''; - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); - } - } - - /** - * {@inheritdoc} - */ - public function write($id, $data) - { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbDataCol = $this->dbOptions['db_data_col']; - $dbIdCol = $this->dbOptions['db_id_col']; - $dbTimeCol = $this->dbOptions['db_time_col']; - - $sql = ('mysql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) - ? "INSERT INTO $dbTable ($dbIdCol, $dbDataCol, $dbTimeCol) VALUES (:id, :data, :time) " - ."ON DUPLICATE KEY UPDATE $dbDataCol = VALUES($dbDataCol), $dbTimeCol = CASE WHEN $dbTimeCol = :time THEN (VALUES($dbTimeCol) + 1) ELSE VALUES($dbTimeCol) END" - : "UPDATE $dbTable SET $dbDataCol = :data, $dbTimeCol = :time WHERE $dbIdCol = :id"; - - try { - //session data can contain non binary safe characters so we need to encode it - $encoded = base64_encode($data); - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - - if (!$stmt->rowCount()) { - // No session exists in the database to update. This happens when we have called - // session_regenerate_id() - $this->createNewSession($id, $data); - } - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * Creates a new session with the given $id and $data - * - * @param string $id - * @param string $data - * - * @return boolean True. - */ - private function createNewSession($id, $data = '') - { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbDataCol = $this->dbOptions['db_data_col']; - $dbIdCol = $this->dbOptions['db_id_col']; - $dbTimeCol = $this->dbOptions['db_time_col']; - - $sql = "INSERT INTO $dbTable ($dbIdCol, $dbDataCol, $dbTimeCol) VALUES (:id, :data, :time)"; - - //session data can contain non binary safe characters so we need to encode it - $encoded = base64_encode($data); - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - - return true; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php deleted file mode 100644 index 5500a03419912219f21bbf91026dd4ac7d5fa9e9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php +++ /dev/null @@ -1,252 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; - -/** - * MockArraySessionStorage mocks the session for unit tests. - * - * No PHP session is actually started since a session can be initialized - * and shutdown only once per PHP execution cycle. - * - * When doing functional testing, you should use MockFileSessionStorage instead. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * @author Drak - */ -class MockArraySessionStorage implements SessionStorageInterface -{ - /** - * @var string - */ - protected $id = ''; - - /** - * @var string - */ - protected $name; - - /** - * @var boolean - */ - protected $started = false; - - /** - * @var boolean - */ - protected $closed = false; - - /** - * @var array - */ - protected $data = array(); - - /** - * @var MetadataBag - */ - protected $metadataBag; - - /** - * Constructor. - * - * @param string $name Session name - * @param MetadataBag $metaBag MetadataBag instance. - */ - public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null) - { - $this->name = $name; - $this->setMetadataBag($metaBag); - } - - /** - * Sets the session data. - * - * @param array $array - */ - public function setSessionData(array $array) - { - $this->data = $array; - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started && !$this->closed) { - return true; - } - - if (empty($this->id)) { - $this->id = $this->generateId(); - } - - $this->loadSession(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (!$this->started) { - $this->start(); - } - - $this->metadataBag->stampNew($lifetime); - $this->id = $this->generateId(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - if ($this->started) { - throw new \LogicException('Cannot set session ID after the session has started.'); - } - - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function save() - { - // nothing to do since we don't persist the session data - $this->closed = false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // clear out the session - $this->data = array(); - - // reconnect the bags to the session - $this->loadSession(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->bags[$bag->getName()] = $bag; - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); - } - - if (!$this->started) { - $this->start(); - } - - return $this->bags[$name]; - } - - /** - * Sets the MetadataBag. - * - * @param MetadataBag $bag - */ - public function setMetadataBag(MetadataBag $bag = null) - { - if (null === $bag) { - $bag = new MetadataBag(); - } - - $this->metadataBag = $bag; - } - - /** - * Gets the MetadataBag. - * - * @return MetadataBag - */ - public function getMetadataBag() - { - return $this->metadataBag; - } - - /** - * Generates a session ID. - * - * This doesn't need to be particularly cryptographically secure since this is just - * a mock. - * - * @return string - */ - protected function generateId() - { - return sha1(uniqid(mt_rand())); - } - - protected function loadSession() - { - $bags = array_merge($this->bags, array($this->metadataBag)); - - foreach ($bags as $bag) { - $key = $bag->getStorageKey(); - $this->data[$key] = isset($this->data[$key]) ? $this->data[$key] : array(); - $bag->initialize($this->data[$key]); - } - - $this->started = true; - $this->closed = false; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php deleted file mode 100644 index 5bf2962ae65f1474d76696a8a5f6bd39ed0aa602..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -/** - * MockFileSessionStorage is used to mock sessions for - * functional testing when done in a single PHP process. - * - * No PHP session is actually started since a session can be initialized - * and shutdown only once per PHP execution cycle and this class does - * not pollute any session related globals, including session_*() functions - * or session.* PHP ini directives. - * - * @author Drak - */ -class MockFileSessionStorage extends MockArraySessionStorage -{ - /** - * @var string - */ - private $savePath; - - private $sessionData; - - /** - * Constructor. - * - * @param string $savePath Path of directory to save session files. - * @param string $name Session name. - */ - public function __construct($savePath = null, $name = 'MOCKSESSID') - { - if (null === $savePath) { - $savePath = sys_get_temp_dir(); - } - - if (!is_dir($savePath)) { - mkdir($savePath, 0777, true); - } - - $this->savePath = $savePath; - - parent::__construct($name); - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (!$this->id) { - $this->id = $this->generateId(); - } - - $this->read(); - - $this->started = true; - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (!$this->started) { - $this->start(); - } - - if ($destroy) { - $this->destroy(); - } - - return parent::regenerate($destroy, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function save() - { - file_put_contents($this->getFilePath(), serialize($this->data)); - } - - /** - * Deletes a session from persistent storage. - * Deliberately leaves session data in memory intact. - */ - private function destroy() - { - if (is_file($this->getFilePath())) { - unlink($this->getFilePath()); - } - } - - /** - * Calculate path to file. - * - * @return string File path - */ - private function getFilePath() - { - return $this->savePath.'/'.$this->id.'.mocksess'; - } - - /** - * Reads session from storage and loads session. - */ - private function read() - { - $filePath = $this->getFilePath(); - $this->data = is_readable($filePath) && is_file($filePath) ? unserialize(file_get_contents($filePath)) : array(); - - $this->loadSession(); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php deleted file mode 100644 index 215ed26ab0ff26f178c44f6f3d904db61525803c..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ /dev/null @@ -1,392 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * This provides a base class for session attribute storage. - * - * @author Drak - */ -class NativeSessionStorage implements SessionStorageInterface -{ - /** - * Array of SessionBagInterface - * - * @var array - */ - protected $bags; - - /** - * @var boolean - */ - protected $started = false; - - /** - * @var boolean - */ - protected $closed = false; - - /** - * @var AbstractProxy - */ - protected $saveHandler; - - /** - * @var MetadataBag - */ - protected $metadataBag; - - /** - * Constructor. - * - * Depending on how you want the storage driver to behave you probably - * want top override this constructor entirely. - * - * List of options for $options array with their defaults. - * @see http://php.net/session.configuration for options - * but we omit 'session.' from the beginning of the keys for convenience. - * - * auto_start, "0" - * cache_limiter, "nocache" (use "0" to prevent headers from being sent entirely). - * cookie_domain, "" - * cookie_httponly, "" - * cookie_lifetime, "0" - * cookie_path, "/" - * cookie_secure, "" - * entropy_file, "" - * entropy_length, "0" - * gc_divisor, "100" - * gc_maxlifetime, "1440" - * gc_probability, "1" - * hash_bits_per_character, "4" - * hash_function, "0" - * name, "PHPSESSID" - * referer_check, "" - * serialize_handler, "php" - * use_cookies, "1" - * use_only_cookies, "1" - * use_trans_sid, "0" - * upload_progress.enabled, "1" - * upload_progress.cleanup, "1" - * upload_progress.prefix, "upload_progress_" - * upload_progress.name, "PHP_SESSION_UPLOAD_PROGRESS" - * upload_progress.freq, "1%" - * upload_progress.min-freq, "1" - * url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset=" - * - * @param array $options Session configuration options. - * @param object $handler SessionHandlerInterface. - * @param MetadataBag $handler MetadataBag. - */ - public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null) - { - // sensible defaults - ini_set('session.auto_start', 0); // by default we prefer to explicitly start the session using the class. - ini_set('session.cache_limiter', ''); // disable by default because it's managed by HeaderBag (if used) - ini_set('session.use_cookies', 1); - - if (version_compare(phpversion(), '5.4.0', '>=')) { - session_register_shutdown(); - } else { - register_shutdown_function('session_write_close'); - } - - $this->setMetadataBag($metaBag); - $this->setOptions($options); - $this->setSaveHandler($handler); - } - - /** - * Gets the save handler instance. - * - * @return AbstractProxy - */ - public function getSaveHandler() - { - return $this->saveHandler; - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started && !$this->closed) { - return true; - } - - // catch condition where session was started automatically by PHP - if (!$this->started && !$this->closed && $this->saveHandler->isActive() - && $this->saveHandler->isSessionHandlerInterface()) { - $this->loadSession(); - - return true; - } - - if (ini_get('session.use_cookies') && headers_sent()) { - throw new \RuntimeException('Failed to start the session because headers have already been sent.'); - } - - // start the session - if (!session_start()) { - throw new \RuntimeException('Failed to start the session'); - } - - $this->loadSession(); - - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - $this->saveHandler->setActive(false); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - if (!$this->started) { - return ''; // returning empty is consistent with session_id() behaviour - } - - return $this->saveHandler->getId(); - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - return $this->saveHandler->setId($id); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->saveHandler->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->saveHandler->setName($name); - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (null !== $lifetime) { - ini_set('session.cookie_lifetime', $lifetime); - } - - if ($destroy) { - $this->metadataBag->stampNew(); - } - - return session_regenerate_id($destroy); - } - - /** - * {@inheritdoc} - */ - public function save() - { - session_write_close(); - - if (!$this->saveHandler->isWrapper() && !$this->getSaveHandler()->isSessionHandlerInterface()) { - $this->saveHandler->setActive(false); - } - - $this->closed = true; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // clear out the session - $_SESSION = array(); - - // reconnect the bags to the session - $this->loadSession(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->bags[$bag->getName()] = $bag; - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); - } - - if (ini_get('session.auto_start') && !$this->started) { - $this->start(); - } elseif ($this->saveHandler->isActive() && !$this->started) { - $this->loadSession(); - } - - return $this->bags[$name]; - } - - /** - * Sets the MetadataBag. - * - * @param MetadataBag $metaBag - */ - public function setMetadataBag(MetadataBag $metaBag = null) - { - if (null === $metaBag) { - $metaBag = new MetadataBag(); - } - - $this->metadataBag = $metaBag; - } - - /** - * Gets the MetadataBag. - * - * @return MetadataBag - */ - public function getMetadataBag() - { - return $this->metadataBag; - } - - /** - * Sets session.* ini variables. - * - * For convenience we omit 'session.' from the beginning of the keys. - * Explicitly ignores other ini keys. - * - * @param array $options Session ini directives array(key => value). - * - * @see http://php.net/session.configuration - */ - public function setOptions(array $options) - { - $validOptions = array_flip(array( - 'auto_start', 'cache_limiter', 'cookie_domain', 'cookie_httponly', - 'cookie_lifetime', 'cookie_path', 'cookie_secure', - 'entropy_file', 'entropy_length', 'gc_divisor', - 'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character', - 'hash_function', 'name', 'referer_check', - 'serialize_handler', 'use_cookies', - 'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled', - 'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name', - 'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set('session.'.$key, $value); - } - } - } - - /** - * Registers save handler as a PHP session handler. - * - * To use internal PHP session save handlers, override this method using ini_set with - * session.save_handlers and session.save_path e.g. - * - * ini_set('session.save_handlers', 'files'); - * ini_set('session.save_path', /tmp'); - * - * @see http://php.net/session-set-save-handler - * @see http://php.net/sessionhandlerinterface - * @see http://php.net/sessionhandler - * - * @param object $saveHandler Default null means NativeProxy. - */ - public function setSaveHandler($saveHandler = null) - { - // Wrap $saveHandler in proxy - if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { - $saveHandler = new SessionHandlerProxy($saveHandler); - } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = new NativeProxy($saveHandler); - } - - $this->saveHandler = $saveHandler; - - if ($this->saveHandler instanceof \SessionHandlerInterface) { - if (version_compare(phpversion(), '5.4.0', '>=')) { - session_set_save_handler($this->saveHandler, false); - } else { - session_set_save_handler( - array($this->saveHandler, 'open'), - array($this->saveHandler, 'close'), - array($this->saveHandler, 'read'), - array($this->saveHandler, 'write'), - array($this->saveHandler, 'destroy'), - array($this->saveHandler, 'gc') - ); - } - } - } - - /** - * Load the session with attributes. - * - * After starting the session, PHP retrieves the session from whatever handlers - * are set to (either PHP's internal, or a custom save handler set with session_set_save_handler()). - * PHP takes the return value from the read() handler, unserializes it - * and populates $_SESSION with the result automatically. - * - * @param array|null $session - */ - protected function loadSession(array &$session = null) - { - if (null === $session) { - $session = &$_SESSION; - } - - $bags = array_merge($this->bags, array($this->metadataBag)); - - foreach ($bags as $bag) { - $key = $bag->getStorageKey(); - $session[$key] = isset($session[$key]) ? $session[$key] : array(); - $bag->initialize($session[$key]); - } - - $this->started = true; - $this->closed = false; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php b/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php deleted file mode 100644 index 20c533c2eb19db657842e68537be272a2b5bca3d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; - -/** - * StorageInterface. - * - * @author Fabien Potencier - * @author Drak - * - * @api - */ -interface SessionStorageInterface -{ - /** - * Starts the session. - * - * @throws \RuntimeException If something goes wrong starting the session. - * - * @return boolean True if started. - * - * @api - */ - function start(); - - /** - * Returns the session ID - * - * @return string The session ID or empty. - * - * @api - */ - function getId(); - - /** - * Sets the session ID - * - * @param string $id - * - * @api - */ - function setId($id); - - /** - * Returns the session name - * - * @return mixed The session name. - * - * @api - */ - function getName(); - - /** - * Sets the session name - * - * @param string $name - * - * @api - */ - function setName($name); - - /** - * Regenerates id that represents this storage. - * - * This method must invoke session_regenerate_id($destroy) unless - * this interface is used for a storage object designed for unit - * or functional testing where a real PHP session would interfere - * with testing. - * - * Note regenerate+destroy should not clear the session data in memory - * only delete the session data from persistent storage. - * - * @param Boolean $destroy Destroy session when regenerating? - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return Boolean True if session regenerated, false if error - * - * @throws \RuntimeException If an error occurs while regenerating this storage - * - * @api - */ - function regenerate($destroy = false, $lifetime = null); - - /** - * Force the session to be saved and closed. - * - * This method must invoke session_write_close() unless this interface is - * used for a storage object design for unit or functional testing where - * a real PHP session would interfere with testing, in which case it - * it should actually persist the session data if required. - */ - function save(); - - /** - * Clear all session data in memory. - */ - function clear(); - - /** - * Gets a SessionBagInterface by name. - * - * @param string $name - * - * @return SessionBagInterface - * - * @throws \InvalidArgumentException If the bag does not exist - */ - function getBag($name); - - /** - * Registers a SessionBagInterface for use. - * - * @param SessionBagInterface $bag - */ - function registerBag(SessionBagInterface $bag); - - /** - * @return MetadataBag - */ - function getMetadataBag(); -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php deleted file mode 100644 index 2990c210ff748231fcb615ebf4bbe3a8ee6ba2c7..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -class MimeTypeTest extends \PHPUnit_Framework_TestCase -{ - protected $path; - - public function testGuessImageWithoutExtension() - { - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } - } - - public function testGuessImageWithDirectory() - { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory'); - } - - public function testGuessImageWithFileBinaryMimeTypeGuesser() - { - $guesser = MimeTypeGuesser::getInstance(); - $guesser->register(new FileBinaryMimeTypeGuesser()); - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } - } - - public function testGuessImageWithKnownExtension() - { - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif')); - } - } - - public function testGuessFileWithUnknownExtension() - { - if (extension_loaded('fileinfo')) { - $this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension')); - } - } - - public function testGuessWithIncorrectPath() - { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here'); - } - - public function testGuessWithNonReadablePath() - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Can not verify chmod operations on Windows'); - } - - if (in_array(get_current_user(), array('root'))) { - $this->markTestSkipped('This test will fail if run under superuser'); - } - - $path = __DIR__.'/../Fixtures/to_delete'; - touch($path); - chmod($path, 0333); - - if (get_current_user() != 'root' && substr(sprintf('%o', fileperms($path)), -4) == '0333') { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException'); - MimeTypeGuesser::getInstance()->guess($path); - } else { - $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed'); - } - } - - public static function tearDownAfterClass() - { - $path = __DIR__.'/../Fixtures/to_delete'; - if (file_exists($path)) { - chmod($path, 0666); - @unlink($path); - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/FileBagTest.php deleted file mode 100644 index 5042506bc6d3818f71003f580362fefe879711a8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests; - -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\FileBag; - -/** - * FileBagTest. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - */ -class FileBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \InvalidArgumentException - */ - public function testFileMustBeAnArrayOrUploadedFile() - { - new FileBag(array('file' => 'foo')); - } - - public function testShouldConvertsUploadedFiles() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array('file' => array( - 'name' => basename($tmpFile), - 'type' => 'text/plain', - 'tmp_name' => $tmpFile, - 'error' => 0, - 'size' => 100 - ))); - - $this->assertEquals($file, $bag->get('file')); - } - - public function testShouldSetEmptyUploadedFilesToNull() - { - $bag = new FileBag(array('file' => array( - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0 - ))); - - $this->assertNull($bag->get('file')); - } - - public function testShouldConvertUploadedFilesWithPhpBug() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array( - 'child' => array( - 'name' => array( - 'file' => basename($tmpFile), - ), - 'type' => array( - 'file' => 'text/plain', - ), - 'tmp_name' => array( - 'file' => $tmpFile, - ), - 'error' => array( - 'file' => 0, - ), - 'size' => array( - 'file' => 100, - ), - ) - )); - - $files = $bag->all(); - $this->assertEquals($file, $files['child']['file']); - } - - public function testShouldConvertNestedUploadedFilesWithPhpBug() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array( - 'child' => array( - 'name' => array( - 'sub' => array('file' => basename($tmpFile)) - ), - 'type' => array( - 'sub' => array('file' => 'text/plain') - ), - 'tmp_name' => array( - 'sub' => array('file' => $tmpFile) - ), - 'error' => array( - 'sub' => array('file' => 0) - ), - 'size' => array( - 'sub' => array('file' => 100) - ), - ) - )); - - $files = $bag->all(); - $this->assertEquals($file, $files['child']['sub']['file']); - } - - public function testShouldNotConvertNestedUploadedFiles() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - $bag = new FileBag(array('image' => array('file' => $file))); - - $files = $bag->all(); - $this->assertEquals($file, $files['image']['file']); - } - - protected function createTempFile() - { - return tempnam(sys_get_temp_dir(), 'FormTest'); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php deleted file mode 100644 index 16ad0d614ee31a9d23016a2a6805b8b6e316fa30..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests; - -use Symfony\Component\HttpFoundation\JsonResponse; - -/** - * @covers Symfony\Component\HttpFoundation\JsonResponse::__construct - * @covers Symfony\Component\HttpFoundation\JsonResponse::setData - * @covers Symfony\Component\HttpFoundation\JsonResponse::setCallback - */ -class JsonResponseTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructorEmptyCreatesJsonObject() - { - $response = new JsonResponse(); - $this->assertSame('{}', $response->getContent()); - } - - public function testConstructorWithArrayCreatesJsonArray() - { - $response = new JsonResponse(array(0, 1, 2, 3)); - $this->assertSame('[0,1,2,3]', $response->getContent()); - } - - public function testConstructorWithAssocArrayCreatesJsonObject() - { - $response = new JsonResponse(array('foo' => 'bar')); - $this->assertSame('{"foo":"bar"}', $response->getContent()); - } - - public function testConstructorWithSimpleTypes() - { - $response = new JsonResponse('foo'); - $this->assertSame('"foo"', $response->getContent()); - - $response = new JsonResponse(0); - $this->assertSame('0', $response->getContent()); - - $response = new JsonResponse(0.1); - $this->assertSame('0.1', $response->getContent()); - - $response = new JsonResponse(true); - $this->assertSame('true', $response->getContent()); - } - - public function testConstructorWithCustomStatus() - { - $response = new JsonResponse(array(), 202); - $this->assertSame(202, $response->getStatusCode()); - } - - public function testConstructorAddsContentTypeHeader() - { - $response = new JsonResponse(); - $this->assertSame('application/json', $response->headers->get('Content-Type')); - } - - public function testConstructorWithCustomHeaders() - { - $response = new JsonResponse(array(), 200, array('ETag' => 'foo')); - $this->assertSame('application/json', $response->headers->get('Content-Type')); - $this->assertSame('foo', $response->headers->get('ETag')); - } - - public function testConstructorWithCustomContentType() - { - $headers = array('Content-Type' => 'application/vnd.acme.blog-v1+json'); - - $response = new JsonResponse(array(), 200, $headers); - $this->assertSame('application/vnd.acme.blog-v1+json', $response->headers->get('Content-Type')); - } - - public function testCreate() - { - $response = JsonResponse::create(array('foo' => 'bar'), 204); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); - $this->assertEquals('{"foo":"bar"}', $response->getContent()); - $this->assertEquals(204, $response->getStatusCode()); - } - - public function testSetCallback() - { - $response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback'); - - $this->assertEquals('callback({"foo":"bar"});', $response->getContent()); - $this->assertEquals('text/javascript', $response->headers->get('Content-Type')); - } - - public function testSetCallbackInvalidIdentifier() - { - $response = new JsonResponse('foo'); - - $this->setExpectedException('InvalidArgumentException'); - $response->setCallback('+invalid'); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/RequestTest.php deleted file mode 100644 index 84f19a26c9761ad13e5a448c0c2573413bd28b48..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ /dev/null @@ -1,1072 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests; - - -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Request; - -class RequestTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Symfony\Component\HttpFoundation\Request::__construct - */ - public function testConstructor() - { - $this->testInitialize(); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::initialize - */ - public function testInitialize() - { - $request = new Request(); - - $request->initialize(array('foo' => 'bar')); - $this->assertEquals('bar', $request->query->get('foo'), '->initialize() takes an array of query parameters as its first argument'); - - $request->initialize(array(), array('foo' => 'bar')); - $this->assertEquals('bar', $request->request->get('foo'), '->initialize() takes an array of request parameters as its second argument'); - - $request->initialize(array(), array(), array('foo' => 'bar')); - $this->assertEquals('bar', $request->attributes->get('foo'), '->initialize() takes an array of attributes as its third argument'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_FOO' => 'bar')); - $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its fourth argument'); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::create - */ - public function testCreate() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/foo', 'GET', array('bar' => 'baz')); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/foo?bar=foo', 'GET', array('bar' => 'baz')); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('https://test.com/foo?bar=baz'); - $this->assertEquals('https://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(443, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('test.com:90/foo'); - $this->assertEquals('http://test.com:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('test.com', $request->getHost()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('https://test.com:90/foo'); - $this->assertEquals('https://test.com:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('test.com', $request->getHost()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://127.0.0.1:90/foo'); - $this->assertEquals('https://127.0.0.1:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('127.0.0.1', $request->getHost()); - $this->assertEquals('127.0.0.1:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://[::1]:90/foo'); - $this->assertEquals('https://[::1]:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('[::1]', $request->getHost()); - $this->assertEquals('[::1]:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; - $request = Request::create('http://example.com/jsonrpc', 'POST', array(), array(), array(), array(), $json); - $this->assertEquals($json, $request->getContent()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com:90/?test=1'); - $this->assertEquals('http://test.com:90/?test=1', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('test=1', $request->getQueryString()); - $this->assertEquals(90, $request->getPort()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test:test@test.com'); - $this->assertEquals('http://test:test@test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('test', $request->getUser()); - $this->assertEquals('test', $request->getPassword()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://testnopass@test.com'); - $this->assertEquals('http://testnopass@test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('testnopass', $request->getUser()); - $this->assertNull($request->getPassword()); - $this->assertFalse($request->isSecure()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::duplicate - */ - public function testDuplicate() - { - $request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar')); - $dup = $request->duplicate(); - - $this->assertEquals($request->query->all(), $dup->query->all(), '->duplicate() duplicates a request an copy the current query parameters'); - $this->assertEquals($request->request->all(), $dup->request->all(), '->duplicate() duplicates a request an copy the current request parameters'); - $this->assertEquals($request->attributes->all(), $dup->attributes->all(), '->duplicate() duplicates a request an copy the current attributes'); - $this->assertEquals($request->headers->all(), $dup->headers->all(), '->duplicate() duplicates a request an copy the current HTTP headers'); - - $dup = $request->duplicate(array('foo' => 'foobar'), array('foo' => 'foobar'), array('foo' => 'foobar'), array(), array(), array('HTTP_FOO' => 'foobar')); - - $this->assertEquals(array('foo' => 'foobar'), $dup->query->all(), '->duplicate() overrides the query parameters if provided'); - $this->assertEquals(array('foo' => 'foobar'), $dup->request->all(), '->duplicate() overrides the request parameters if provided'); - $this->assertEquals(array('foo' => 'foobar'), $dup->attributes->all(), '->duplicate() overrides the attributes if provided'); - $this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided'); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getFormat - * @covers Symfony\Component\HttpFoundation\Request::setFormat - * @dataProvider getFormatToMimeTypeMapProvider - */ - public function testGetFormatFromMimeType($format, $mimeTypes) - { - $request = new Request(); - foreach ($mimeTypes as $mime) { - $this->assertEquals($format, $request->getFormat($mime)); - } - $request->setFormat($format, $mimeTypes); - foreach ($mimeTypes as $mime) { - $this->assertEquals($format, $request->getFormat($mime)); - } - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getFormat - */ - public function testGetFormatFromMimeTypeWithParameters() - { - $request = new Request(); - $this->assertEquals('json', $request->getFormat('application/json; charset=utf-8')); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getMimeType - * @dataProvider getFormatToMimeTypeMapProvider - */ - public function testGetMimeTypeFromFormat($format, $mimeTypes) - { - if (null !== $format) { - $request = new Request(); - $this->assertEquals($mimeTypes[0], $request->getMimeType($format)); - } - } - - public function getFormatToMimeTypeMapProvider() - { - return array( - array(null, array(null, 'unexistent-mime-type')), - array('txt', array('text/plain')), - array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')), - array('css', array('text/css')), - array('json', array('application/json', 'application/x-json')), - array('xml', array('text/xml', 'application/xml', 'application/x-xml')), - array('rdf', array('application/rdf+xml')), - array('atom',array('application/atom+xml')), - ); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getUri - */ - public function testGetUri() - { - $server = array(); - - // Standard Request on non default PORT - // http://hostname:8080/index.php/path/info?query=string - - $server['HTTP_HOST'] = 'hostname:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/index.php/path/info?query=string'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PATH_INFO'] = '/path/info'; - $server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info'; - $server['PHP_SELF'] = '/index_dev.php/path/info'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request = new Request(); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://hostname:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port'); - - // Use std port number - $server['HTTP_HOST'] = 'hostname'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://hostname/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port without HOST_HEADER'); - - // Request with URL REWRITING (hide index.php) - // RewriteCond %{REQUEST_FILENAME} !-f - // RewriteRule ^(.*)$ index.php [QSA,L] - // http://hostname:8080/path/info?query=string - $server = array(); - $server['HTTP_HOST'] = 'hostname:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['REDIRECT_QUERY_STRING'] = 'query=string'; - $server['REDIRECT_URL'] = '/path/info'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/path/info?toto=test&1=1'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PHP_SELF'] = '/index.php'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://hostname:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite'); - - // Use std port number - // http://hostname/path/info?query=string - $server['HTTP_HOST'] = 'hostname'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://hostname/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/path/info?query=string', $request->getUri(), '->getUri() with rewrite, default port without HOST_HEADER'); - - // With encoded characters - - $server = array( - 'HTTP_HOST' => 'hostname:8080', - 'SERVER_NAME' => 'servername', - 'SERVER_PORT' => '8080', - 'QUERY_STRING' => 'query=string', - 'REQUEST_URI' => '/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', - 'SCRIPT_NAME' => '/ba se/index_dev.php', - 'PATH_TRANSLATED' => 'redirect:/index.php/foo bar/in+fo', - 'PHP_SELF' => '/ba se/index_dev.php/path/info', - 'SCRIPT_FILENAME' => '/some/where/ba se/index_dev.php', - ); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals( - 'http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', - $request->getUri() - ); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getUriForPath - */ - public function testGetUriForPath() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $this->assertEquals('http://test.com/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('http://test.com:90/foo?bar=baz'); - $this->assertEquals('http://test.com:90/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('https://test.com/foo?bar=baz'); - $this->assertEquals('https://test.com/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('https://test.com:90/foo?bar=baz'); - $this->assertEquals('https://test.com:90/some/path', $request->getUriForPath('/some/path')); - - $server = array(); - - // Standard Request on non default PORT - // http://hostname:8080/index.php/path/info?query=string - - $server['HTTP_HOST'] = 'hostname:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/index.php/path/info?query=string'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PATH_INFO'] = '/path/info'; - $server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info'; - $server['PHP_SELF'] = '/index_dev.php/path/info'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request = new Request(); - - $request->initialize(array(), array(), array(), array(), array(),$server); - - $this->assertEquals('http://hostname:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port'); - - // Use std port number - $server['HTTP_HOST'] = 'hostname'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://hostname/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port without HOST_HEADER'); - - // Request with URL REWRITING (hide index.php) - // RewriteCond %{REQUEST_FILENAME} !-f - // RewriteRule ^(.*)$ index.php [QSA,L] - // http://hostname:8080/path/info?query=string - $server = array(); - $server['HTTP_HOST'] = 'hostname:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['REDIRECT_QUERY_STRING'] = 'query=string'; - $server['REDIRECT_URL'] = '/path/info'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/path/info?toto=test&1=1'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PHP_SELF'] = '/index.php'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://hostname:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite'); - - // Use std port number - // http://hostname/path/info?query=string - $server['HTTP_HOST'] = 'hostname'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://hostname/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite, default port without HOST_HEADER'); - $this->assertEquals('servername', $request->getHttpHost()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getQueryString - */ - public function testGetQueryString() - { - $request = new Request(); - - $request->server->set('QUERY_STRING', 'foo'); - $this->assertEquals('foo', $request->getQueryString(), '->getQueryString() works with valueless parameters'); - - $request->server->set('QUERY_STRING', 'foo='); - $this->assertEquals('foo=', $request->getQueryString(), '->getQueryString() includes a dangling equal sign'); - - $request->server->set('QUERY_STRING', 'bar=&foo=bar'); - $this->assertEquals('bar=&foo=bar', $request->getQueryString(), '->getQueryString() works when empty parameters'); - - $request->server->set('QUERY_STRING', 'foo=bar&bar='); - $this->assertEquals('bar=&foo=bar', $request->getQueryString(), '->getQueryString() sorts keys alphabetically'); - - $request->server->set('QUERY_STRING', 'him=John%20Doe&her=Jane+Doe'); - $this->assertEquals('her=Jane%2BDoe&him=John%20Doe', $request->getQueryString(), '->getQueryString() normalizes encoding'); - - $request->server->set('QUERY_STRING', 'foo[]=1&foo[]=2'); - $this->assertEquals('foo%5B%5D=1&foo%5B%5D=2', $request->getQueryString(), '->getQueryString() allows array notation'); - - $request->server->set('QUERY_STRING', 'foo=1&foo=2'); - $this->assertEquals('foo=1&foo=2', $request->getQueryString(), '->getQueryString() allows repeated parameters'); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getHost - */ - public function testGetHost() - { - $request = new Request(); - - $request->initialize(array('foo' => 'bar')); - $this->assertEquals('', $request->getHost(), '->getHost() return empty string if not initialized'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from Host Header'); - - // Host header with port number. - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com:8080')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from Host Header with port number'); - - // Server values. - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from server name'); - - $this->startTrustingProxyData(); - // X_FORWARDED_HOST. - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_X_FORWARDED_HOST' => 'www.exemple.com')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from X_FORWARDED_HOST'); - - // X_FORWARDED_HOST - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_X_FORWARDED_HOST' => 'www.exemple.com, www.second.com')); - $this->assertEquals('www.second.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST use last value'); - - // X_FORWARDED_HOST with port number - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_X_FORWARDED_HOST' => 'www.exemple.com, www.second.com:8080')); - $this->assertEquals('www.second.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST with port number'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com', 'HTTP_X_FORWARDED_HOST' => 'www.forward.com')); - $this->assertEquals('www.forward.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST has priority over Host'); - - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_X_FORWARDED_HOST' => 'www.forward.com')); - $this->assertEquals('www.forward.com', $request->getHost(), '->getHost() value from X_FORWARDED_HOST has priority over SERVER_NAME '); - - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_HOST' => 'www.host.com')); - $this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME '); - $this->stopTrustingProxyData(); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::setMethod - * @covers Symfony\Component\HttpFoundation\Request::getMethod - */ - public function testGetSetMethod() - { - $request = new Request(); - - $this->assertEquals('GET', $request->getMethod(), '->getMethod() returns GET if no method is defined'); - - $request->setMethod('get'); - $this->assertEquals('GET', $request->getMethod(), '->getMethod() returns an uppercased string'); - - $request->setMethod('PURGE'); - $this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method even if it is not a standard one'); - - $request->setMethod('POST'); - $this->assertEquals('POST', $request->getMethod(), '->getMethod() returns the method POST if no _method is defined'); - - $request->setMethod('POST'); - $request->request->set('_method', 'purge'); - $this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method from _method if defined and POST'); - - $request->setMethod('POST'); - $request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete'); - $this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override even though _method is set if defined and POST'); - - $request = new Request(); - $request->setMethod('POST'); - $request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete'); - $this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override if defined and POST'); - } - - /** - * @dataProvider testGetClientIpProvider - */ - public function testGetClientIp($expected, $proxy, $remoteAddr, $httpClientIp, $httpForwardedFor) - { - $request = new Request(); - $this->assertEquals('', $request->getClientIp()); - $this->assertEquals('', $request->getClientIp(true)); - - $server = array('REMOTE_ADDR' => $remoteAddr); - if (null !== $httpClientIp) { - $server['HTTP_CLIENT_IP'] = $httpClientIp; - } - if (null !== $httpForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $httpForwardedFor; - } - - $request->initialize(array(), array(), array(), array(), array(), $server); - if ($proxy) { - $this->startTrustingProxyData(); - } - $this->assertEquals($expected, $request->getClientIp($proxy)); - if ($proxy) { - $this->stopTrustingProxyData(); - } - } - - public function testGetClientIpProvider() - { - return array( - array('88.88.88.88', false, '88.88.88.88', null, null), - array('127.0.0.1', false, '127.0.0.1', '88.88.88.88', null), - array('88.88.88.88', true, '127.0.0.1', '88.88.88.88', null), - array('127.0.0.1', false, '127.0.0.1', null, '88.88.88.88'), - array('88.88.88.88', true, '127.0.0.1', null, '88.88.88.88'), - array('::1', false, '::1', null, null), - array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null), - array('2620:0:1cfe:face:b00c::3', true, '::1', null, '2620:0:1cfe:face:b00c::3, ::1'), - array('88.88.88.88', true, '123.45.67.89', null, '88.88.88.88, 87.65.43.21, 127.0.0.1'), - ); - } - - public function testGetContentWorksTwiceInDefaultMode() - { - $req = new Request; - $this->assertEquals('', $req->getContent()); - $this->assertEquals('', $req->getContent()); - } - - public function testGetContentReturnsResource() - { - $req = new Request; - $retval = $req->getContent(true); - $this->assertInternalType('resource', $retval); - $this->assertEquals("", fread($retval, 1)); - $this->assertTrue(feof($retval)); - } - - /** - * @expectedException LogicException - * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider - */ - public function testGetContentCantBeCalledTwiceWithResources($first, $second) - { - $req = new Request; - $req->getContent($first); - $req->getContent($second); - } - - public function getContentCantBeCalledTwiceWithResourcesProvider() - { - return array( - 'Resource then fetch' => array(true, false), - 'Resource then resource' => array(true, true), - 'Fetch then resource' => array(false, true), - ); - } - - public function provideOverloadedMethods() - { - return array( - array('PUT'), - array('DELETE'), - array('PATCH'), - ); - } - - /** - * @dataProvider provideOverloadedMethods - */ - public function testCreateFromGlobals($method) - { - $_GET['foo1'] = 'bar1'; - $_POST['foo2'] = 'bar2'; - $_COOKIE['foo3'] = 'bar3'; - $_FILES['foo4'] = array('bar4'); - $_SERVER['foo5'] = 'bar5'; - - $request = Request::createFromGlobals(); - $this->assertEquals('bar1', $request->query->get('foo1'), '::fromGlobals() uses values from $_GET'); - $this->assertEquals('bar2', $request->request->get('foo2'), '::fromGlobals() uses values from $_POST'); - $this->assertEquals('bar3', $request->cookies->get('foo3'), '::fromGlobals() uses values from $_COOKIE'); - $this->assertEquals(array('bar4'), $request->files->get('foo4'), '::fromGlobals() uses values from $_FILES'); - $this->assertEquals('bar5', $request->server->get('foo5'), '::fromGlobals() uses values from $_SERVER'); - - unset($_GET['foo1'], $_POST['foo2'], $_COOKIE['foo3'], $_FILES['foo4'], $_SERVER['foo5']); - - $_SERVER['REQUEST_METHOD'] = $method; - $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - $request = RequestContentProxy::createFromGlobals(); - $this->assertEquals($method, $request->getMethod()); - $this->assertEquals('mycontent', $request->request->get('content')); - - unset($_SERVER['REQUEST_METHOD'], $_SERVER['CONTENT_TYPE']); - - $_POST['_method'] = $method; - $_POST['foo6'] = 'bar6'; - $_SERVER['REQUEST_METHOD'] = 'POST'; - $request = Request::createFromGlobals(); - $this->assertEquals($method, $request->getMethod()); - $this->assertEquals('bar6', $request->request->get('foo6')); - - unset($_POST['_method'], $_POST['foo6'], $_SERVER['REQUEST_METHOD']); - } - - public function testOverrideGlobals() - { - $request = new Request(); - $request->initialize(array('foo' => 'bar')); - - // as the Request::overrideGlobals really work, it erase $_SERVER, so we must backup it - $server = $_SERVER; - - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_GET); - - $request->initialize(array(), array('foo' => 'bar')); - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_POST); - - $this->assertArrayNotHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - - $this->startTrustingProxyData(); - $request->headers->set('X_FORWARDED_PROTO', 'https'); - - $this->assertTrue($request->isSecure()); - $this->stopTrustingProxyData(); - - $request->overrideGlobals(); - - $this->assertArrayHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - - // restore initial $_SERVER array - $_SERVER = $server; - } - - public function testGetScriptName() - { - $request = new Request(); - $this->assertEquals('', $request->getScriptName()); - - $server = array(); - $server['SCRIPT_NAME'] = '/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/index.php', $request->getScriptName()); - - $server = array(); - $server['ORIG_SCRIPT_NAME'] = '/frontend.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/frontend.php', $request->getScriptName()); - - $server = array(); - $server['SCRIPT_NAME'] = '/index.php'; - $server['ORIG_SCRIPT_NAME'] = '/frontend.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/index.php', $request->getScriptName()); - } - - public function testGetBasePath() - { - $request = new Request(); - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['SCRIPT_NAME'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['PHP_SELF'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['ORIG_SCRIPT_NAME'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - } - - public function testGetPathInfo() - { - $request = new Request(); - $this->assertEquals('/', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '/path/info'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/path/info', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '/path%20test/info'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/path%20test/info', $request->getPathInfo()); - } - - public function testGetPreferredLanguage() - { - $request = new Request(); - $this->assertNull($request->getPreferredLanguage()); - $this->assertNull($request->getPreferredLanguage(array())); - $this->assertEquals('fr', $request->getPreferredLanguage(array('fr'))); - $this->assertEquals('fr', $request->getPreferredLanguage(array('fr', 'en'))); - $this->assertEquals('en', $request->getPreferredLanguage(array('en', 'fr'))); - $this->assertEquals('fr-ch', $request->getPreferredLanguage(array('fr-ch', 'fr-fr'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals('en', $request->getPreferredLanguage(array('en', 'en-us'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - } - - public function testIsXmlHttpRequest() - { - $request = new Request(); - $this->assertFalse($request->isXmlHttpRequest()); - - $request->headers->set('X-Requested-With', 'XMLHttpRequest'); - $this->assertTrue($request->isXmlHttpRequest()); - - $request->headers->remove('X-Requested-With'); - $this->assertFalse($request->isXmlHttpRequest()); - } - - public function testGetCharsets() - { - $request = new Request(); - $this->assertEquals(array(), $request->getCharsets()); - $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6'); - $this->assertEquals(array(), $request->getCharsets()); // testing caching - - $request = new Request(); - $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6'); - $this->assertEquals(array('ISO-8859-1', 'US-ASCII', 'UTF-8', 'ISO-10646-UCS-2'), $request->getCharsets()); - - $request = new Request(); - $request->headers->set('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); - $this->assertEquals(array('ISO-8859-1', '*', 'utf-8'), $request->getCharsets()); - } - - public function testGetAcceptableContentTypes() - { - $request = new Request(); - $this->assertEquals(array(), $request->getAcceptableContentTypes()); - $request->headers->set('Accept', 'application/vnd.wap.wmlscriptc, text/vnd.wap.wml, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html, multipart/mixed, */*'); - $this->assertEquals(array(), $request->getAcceptableContentTypes()); // testing caching - - $request = new Request(); - $request->headers->set('Accept', 'application/vnd.wap.wmlscriptc, text/vnd.wap.wml, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html, multipart/mixed, */*'); - $this->assertEquals(array('multipart/mixed', '*/*', 'text/html', 'application/xhtml+xml', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/vnd.wap.wmlscriptc'), $request->getAcceptableContentTypes()); - } - - public function testGetLanguages() - { - $request = new Request(); - $this->assertEquals(array(), $request->getLanguages()); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages()); - $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages()); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, i-cherokee; q=0.6'); - $this->assertEquals(array('zh', 'cherokee'), $request->getLanguages()); - } - - public function testGetRequestFormat() - { - $request = new Request(); - $this->assertEquals('html', $request->getRequestFormat()); - - $request = new Request(); - $this->assertNull($request->getRequestFormat(null)); - - $request = new Request(); - $this->assertNull($request->setRequestFormat('foo')); - $this->assertEquals('foo', $request->getRequestFormat(null)); - } - - public function testForwardedSecure() - { - $request = new Request(); - $request->headers->set('X-Forwarded-Proto', 'https'); - $request->headers->set('X-Forwarded-Port', 443); - - $this->startTrustingProxyData(); - $this->assertTrue($request->isSecure()); - $this->assertEquals(443, $request->getPort()); - $this->stopTrustingProxyData(); - } - - public function testHasSession() - { - $request = new Request(); - - $this->assertFalse($request->hasSession()); - $request->setSession(new Session(new MockArraySessionStorage())); - $this->assertTrue($request->hasSession()); - } - - public function testHasPreviousSession() - { - $request = new Request(); - - $this->assertFalse($request->hasPreviousSession()); - $request->cookies->set('MOCKSESSID', 'foo'); - $this->assertFalse($request->hasPreviousSession()); - $request->setSession(new Session(new MockArraySessionStorage())); - $this->assertTrue($request->hasPreviousSession()); - } - - public function testToString() - { - $request = new Request(); - - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - - $this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString()); - } - - /** - * @dataProvider splitHttpAcceptHeaderData - */ - public function testSplitHttpAcceptHeader($acceptHeader, $expected) - { - $request = new Request(); - - $this->assertEquals($expected, $request->splitHttpAcceptHeader($acceptHeader)); - } - - public function splitHttpAcceptHeaderData() - { - return array( - array(null, array()), - array('text/html;q=0.8', array('text/html' => 0.8)), - array('text/html;foo=bar;q=0.8 ', array('text/html;foo=bar' => 0.8)), - array('text/html;charset=utf-8; q=0.8', array('text/html;charset=utf-8' => 0.8)), - array('text/html,application/xml;q=0.9,*/*;charset=utf-8; q=0.8', array('text/html' => 1, 'application/xml' => 0.9, '*/*;charset=utf-8' => 0.8)), - array('text/html,application/xhtml+xml;q=0.9,*/*;q=0.8; foo=bar', array('text/html' => 1, 'application/xhtml+xml' => 0.9, '*/*' => 0.8)), - array('text/html,application/xhtml+xml;charset=utf-8;q=0.9; foo=bar,*/*', array('text/html' => 1, '*/*' => 1, 'application/xhtml+xml;charset=utf-8' => 0.9)), - array('text/html,application/xhtml+xml', array('application/xhtml+xml' => 1, 'text/html' => 1)), - ); - } - - public function testIsProxyTrusted() - { - $this->startTrustingProxyData(); - $this->assertTrue(Request::isProxyTrusted()); - $this->stopTrustingProxyData(); - $this->assertFalse(Request::isProxyTrusted()); - } - - public function testIsMethod() - { - $request = new Request(); - $request->setMethod('POST'); - $this->assertTrue($request->isMethod('POST')); - $this->assertTrue($request->isMethod('post')); - $this->assertFalse($request->isMethod('GET')); - $this->assertFalse($request->isMethod('get')); - - $request->setMethod('GET'); - $this->assertTrue($request->isMethod('GET')); - $this->assertTrue($request->isMethod('get')); - $this->assertFalse($request->isMethod('POST')); - $this->assertFalse($request->isMethod('post')); - } - - private function startTrustingProxyData() - { - Request::trustProxyData(); - } - - /** - * @dataProvider getBaseUrlData - */ - public function testGetBaseUrl($uri, $server, $expectedBaseUrl, $expectedPathInfo) - { - $request = Request::create($uri, 'GET', array(), array(), array(), $server); - - $this->assertSame($expectedBaseUrl, $request->getBaseUrl(), 'baseUrl'); - $this->assertSame($expectedPathInfo, $request->getPathInfo(), 'pathInfo'); - } - - public function getBaseUrlData() - { - return array( - array( - '/foo%20bar', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar', - '/', - ), - array( - '/foo%20bar/home', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar', - '/home', - ), - array( - '/foo%20bar/app.php/home', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar/app.php', - '/home', - ), - array( - '/foo%20bar/app.php/home%3Dbaz', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar/app.php', - '/home%3Dbaz', - ), - array( - '/foo/bar+baz', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php', - 'SCRIPT_NAME' => '/foo/app.php', - 'PHP_SELF' => '/foo/app.php', - ), - '/foo', - '/bar+baz', - ), - ); - } - - /** - * @dataProvider urlencodedStringPrefixData - */ - public function testUrlencodedStringPrefix($string, $prefix, $expect) - { - $request = new Request; - - $me = new \ReflectionMethod($request, 'getUrlencodedPrefix'); - $me->setAccessible(true); - - $this->assertSame($expect, $me->invoke($request, $string, $prefix)); - } - - public function urlencodedStringPrefixData() - { - return array( - array('foo', 'foo', 'foo'), - array('fo%6f', 'foo', 'fo%6f'), - array('foo/bar', 'foo', 'foo'), - array('fo%6f/bar', 'foo', 'fo%6f'), - array('f%6f%6f/bar', 'foo', 'f%6f%6f'), - array('%66%6F%6F/bar', 'foo', '%66%6F%6F'), - array('fo+o/bar', 'fo+o', 'fo+o'), - array('fo%2Bo/bar', 'fo+o', 'fo%2Bo'), - ); - } - - private function stopTrustingProxyData() - { - $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); - $property = $class->getProperty('trustProxy'); - $property->setAccessible(true); - $property->setValue(false); - } -} - -class RequestContentProxy extends Request -{ - public function getContent($asResource = false) - { - return http_build_query(array('_method' => 'PUT', 'content' => 'mycontent')); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/ResponseTest.php deleted file mode 100644 index 6e76cd2fe81e1a04d951b57b8845b906a05e5bd5..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ /dev/null @@ -1,558 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ResponseTest extends \PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $response = Response::create('foo', 301, array('Foo' => 'bar')); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - $this->assertEquals(301, $response->getStatusCode()); - $this->assertEquals('bar', $response->headers->get('foo')); - } - - public function testIsValidateable() - { - $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if Last-Modified is present'); - - $response = new Response('', 200, array('ETag' => '"12345"')); - $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if ETag is present'); - - $response = new Response(); - $this->assertFalse($response->isValidateable(), '->isValidateable() returns false when no validator is present'); - } - - public function testGetDate() - { - $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $this->assertEquals(0, $this->createDateTimeOneHourAgo()->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present'); - - $response = new Response(); - $date = $response->getDate(); - $this->assertLessThan(1, $date->diff(new \DateTime(), true)->format('%s'), '->getDate() returns the current Date if no Date header present'); - - $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $now = $this->createDateTimeNow(); - $response->headers->set('Date', $now->format(DATE_RFC2822)); - $this->assertEquals(0, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified'); - } - - public function testGetMaxAge() - { - $response = new Response(); - $response->headers->set('Cache-Control', 's-maxage=600, max-age=0'); - $this->assertEquals(600, $response->getMaxAge(), '->getMaxAge() uses s-maxage cache control directive when present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=600'); - $this->assertEquals(600, $response->getMaxAge(), '->getMaxAge() falls back to max-age when no s-maxage directive present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'must-revalidate'); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); - - $response = new Response(); - $this->assertNull($response->getMaxAge(), '->getMaxAge() returns null if no freshness information available'); - } - - public function testSetSharedMaxAge() - { - $response = new Response(); - $response->setSharedMaxAge(20); - - $cacheControl = $response->headers->get('Cache-Control'); - $this->assertEquals('public, s-maxage=20', $cacheControl); - } - - public function testIsPrivate() - { - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100'); - $response->setPrivate(); - $this->assertEquals(100, $response->headers->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertTrue($response->headers->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'public, max-age=100'); - $response->setPrivate(); - $this->assertEquals(100, $response->headers->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertTrue($response->headers->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertFalse($response->headers->hasCacheControlDirective('public'), '->isPrivate() removes the public Cache-Control directive'); - } - - public function testExpire() - { - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100'); - $response->expire(); - $this->assertEquals(100, $response->headers->get('Age'), '->expire() sets the Age to max-age when present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100, s-maxage=500'); - $response->expire(); - $this->assertEquals(500, $response->headers->get('Age'), '->expire() sets the Age to s-maxage when both max-age and s-maxage are present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=5, s-maxage=500'); - $response->headers->set('Age', '1000'); - $response->expire(); - $this->assertEquals(1000, $response->headers->get('Age'), '->expire() does nothing when the response is already stale/expired'); - - $response = new Response(); - $response->expire(); - $this->assertFalse($response->headers->has('Age'), '->expire() does nothing when the response does not include freshness information'); - } - - public function testGetTtl() - { - $response = new Response(); - $this->assertNull($response->getTtl(), '->getTtl() returns null when no Expires or Cache-Control headers are present'); - - $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertLessThan(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); - - $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)); - $this->assertLessThan(0, $response->getTtl(), '->getTtl() returns negative values when Expires is in part'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=60'); - $this->assertLessThan(1, 60 - $response->getTtl(), '->getTtl() uses Cache-Control max-age when present'); - } - - public function testSetClientTtl() - { - $response = new Response(); - $response->setClientTtl(10); - - $this->assertEquals($response->getMaxAge(), $response->getAge() + 10); - } - - public function testGetSetProtocolVersion() - { - $response = new Response(); - - $this->assertEquals('1.0', $response->getProtocolVersion()); - - $response->setProtocolVersion('1.1'); - - $this->assertEquals('1.1', $response->getProtocolVersion()); - } - - public function testGetVary() - { - $response = new Response(); - $this->assertEquals(array(), $response->getVary(), '->getVary() returns an empty array if no Vary header is present'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language'); - $this->assertEquals(array('Accept-Language'), $response->getVary(), '->getVary() parses a single header name value'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language User-Agent X-Foo'); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by spaces'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo'); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas'); - } - - public function testSetVary() - { - $response = new Response(); - $response->setVary('Accept-Language'); - $this->assertEquals(array('Accept-Language'), $response->getVary()); - - $response->setVary('Accept-Language, User-Agent'); - $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default'); - - $response->setVary('X-Foo', false); - $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() doesn\'t change the Vary header if replace is set to false'); - } - - public function testDefaultContentType() - { - $headerMock = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag', array('set')); - $headerMock->expects($this->at(0)) - ->method('set') - ->with('Content-Type', 'text/html'); - $headerMock->expects($this->at(1)) - ->method('set') - ->with('Content-Type', 'text/html; charset=UTF-8'); - - $response = new Response('foo'); - $response->headers = $headerMock; - - $response->prepare(new Request()); - } - - public function testContentTypeCharset() - { - $response = new Response(); - $response->headers->set('Content-Type', 'text/css'); - - // force fixContentType() to be called - $response->prepare(new Request()); - - $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type')); - } - - public function testPrepareDoesNothingIfContentTypeIsSet() - { - $response = new Response('foo'); - $response->headers->set('Content-Type', 'text/plain'); - - $response->prepare(new Request()); - - $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('content-type')); - } - - public function testPrepareDoesNothingIfRequestFormatIsNotDefined() - { - $response = new Response('foo'); - - $response->prepare(new Request()); - - $this->assertEquals('text/html; charset=UTF-8', $response->headers->get('content-type')); - } - - public function testPrepareSetContentType() - { - $response = new Response('foo'); - $request = Request::create('/'); - $request->setRequestFormat('json'); - - $response->prepare($request); - - $this->assertEquals('application/json', $response->headers->get('content-type')); - } - - public function testPrepareRemovesContentForHeadRequests() - { - $response = new Response('foo'); - $request = Request::create('/', 'HEAD'); - - $response->prepare($request); - - $this->assertEquals('', $response->getContent()); - } - - public function testSetCache() - { - $response = new Response(); - //array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public') - try { - $response->setCache(array("wrong option" => "value")); - $this->fail('->setCache() throws an InvalidArgumentException if an option is not supported'); - } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported'); - $this->assertContains('"wrong option"', $e->getMessage()); - } - - $options = array('etag' => '"whatever"'); - $response->setCache($options); - $this->assertEquals($response->getEtag(), '"whatever"'); - - $now = new \DateTime(); - $options = array('last_modified' => $now); - $response->setCache($options); - $this->assertEquals($response->getLastModified()->getTimestamp(), $now->getTimestamp()); - - $options = array('max_age' => 100); - $response->setCache($options); - $this->assertEquals($response->getMaxAge(), 100); - - $options = array('s_maxage' => 200); - $response->setCache($options); - $this->assertEquals($response->getMaxAge(), 200); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('public' => true)); - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('public' => false)); - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('private' => true)); - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('private' => false)); - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - } - - public function testSendContent() - { - $response = new Response('test response rendering', 200); - - ob_start(); - $response->sendContent(); - $string = ob_get_clean(); - $this->assertContains('test response rendering', $string); - } - - public function testSetPublic() - { - $response = new Response(); - $response->setPublic(); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - } - - public function testSetExpires() - { - $response = new Response(); - $response->setExpires(null); - - $this->assertNull($response->getExpires(), '->setExpires() remove the header when passed null'); - - $now = new \DateTime(); - $response->setExpires($now); - - $this->assertEquals($response->getExpires()->getTimestamp(), $now->getTimestamp()); - } - - public function testSetLastModified() - { - $response = new Response(); - $response->setLastModified(new \DateTime()); - $this->assertNotNull($response->getLastModified()); - - $response->setLastModified(null); - $this->assertNull($response->getLastModified()); - } - - public function testIsInvalid() - { - $response = new Response(); - - try { - $response->setStatusCode(99); - $this->fail(); - } catch(\InvalidArgumentException $e) { - $this->assertTrue($response->isInvalid()); - } - - try { - $response->setStatusCode(650); - $this->fail(); - } catch(\InvalidArgumentException $e) { - $this->assertTrue($response->isInvalid()); - } - - $response = new Response('', 200); - $this->assertFalse($response->isInvalid()); - } - - public function testIsInformational() - { - $response = new Response('', 100); - $this->assertTrue($response->isInformational()); - - $response = new Response('', 200); - $this->assertFalse($response->isInformational()); - } - - public function testIsRedirectRedirection() - { - foreach (array(301, 302, 303, 307) as $code) - { - $response = new Response('', $code); - $this->assertTrue($response->isRedirection()); - $this->assertTrue($response->isRedirect()); - } - - $response = new Response('', 304); - $this->assertTrue($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 200); - $this->assertFalse($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 404); - $this->assertFalse($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 301, array('Location' => '/good-uri')); - $this->assertFalse($response->isRedirect('/bad-uri')); - $this->assertTrue($response->isRedirect('/good-uri')); - } - - public function testIsNotFound() - { - $response = new Response('', 404); - $this->assertTrue($response->isNotFound()); - - $response = new Response('', 200); - $this->assertFalse($response->isNotFound()); - } - - public function testIsEmpty() - { - foreach (array(201, 204, 304) as $code) - { - $response = new Response('', $code); - $this->assertTrue($response->isEmpty()); - } - - $response = new Response('', 200); - $this->assertFalse($response->isEmpty()); - } - - public function testIsForbidden() - { - $response = new Response('', 403); - $this->assertTrue($response->isForbidden()); - - $response = new Response('', 200); - $this->assertFalse($response->isForbidden()); - } - - public function testIsOk() - { - $response = new Response('', 200); - $this->assertTrue($response->isOk()); - - $response = new Response('', 404); - $this->assertFalse($response->isOk()); - } - - public function testIsServerOrClientError() - { - $response = new Response('', 404); - $this->assertTrue($response->isClientError()); - $this->assertFalse($response->isServerError()); - - $response = new Response('', 500); - $this->assertFalse($response->isClientError()); - $this->assertTrue($response->isServerError()); - } - - public function testHasVary() - { - $response = new Response(); - $this->assertFalse($response->hasVary()); - - $response->setVary('User-Agent'); - $this->assertTrue($response->hasVary()); - } - - public function testSetEtag() - { - $response = new Response('', 200, array('ETag' => '"12345"')); - $response->setEtag(); - - $this->assertNull($response->headers->get('Etag'), '->setEtag() removes Etags when call with null'); - } - - /** - * @dataProvider validContentProvider - */ - public function testSetContent($content) - { - $response = new Response(); - $response->setContent($content); - $this->assertEquals((string) $content, $response->getContent()); - } - - /** - * @expectedException UnexpectedValueException - * @dataProvider invalidContentProvider - */ - public function testSetContentInvalid($content) - { - $response = new Response(); - $response->setContent($content); - } - - public function testSettersAreChainable() - { - $response = new Response(); - - $setters = array( - 'setProtocolVersion' => '1.0', - 'setCharset' => 'UTF-8', - 'setPublic' => null, - 'setPrivate' => null, - 'setDate' => new \DateTime, - 'expire' => null, - 'setMaxAge' => 1, - 'setSharedMaxAge' => 1, - 'setTtl' => 1, - 'setClientTtl' => 1, - ); - - foreach ($setters as $setter => $arg) { - $this->assertEquals($response, $response->{$setter}($arg)); - } - } - - public function validContentProvider() - { - return array( - 'obj' => array(new StringableObject), - 'string' => array('Foo'), - 'int' => array(2), - ); - } - - public function invalidContentProvider() - { - return array( - 'obj' => array(new \stdClass), - 'array' => array(array()), - 'bool' => array(true, '1'), - ); - } - - protected function createDateTimeOneHourAgo() - { - $date = new \DateTime(); - - return $date->sub(new \DateInterval('PT1H')); - } - - protected function createDateTimeOneHourLater() - { - $date = new \DateTime(); - - return $date->add(new \DateInterval('PT1H')); - } - - protected function createDateTimeNow() - { - return new \DateTime(); - } -} - -class StringableObject -{ - public function __toString() - { - return 'Foo'; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php deleted file mode 100644 index b99ad1ce8d8bcedeec8ee9c82883d3e3c8623226..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests; - -use Symfony\Component\HttpFoundation\ServerBag; - -/** - * ServerBagTest - * - * @author Bulat Shakirzyanov - */ -class ServerBagTest extends \PHPUnit_Framework_TestCase -{ - public function testShouldExtractHeadersFromServerArray() - { - $server = array( - 'SOME_SERVER_VARIABLE' => 'value', - 'SOME_SERVER_VARIABLE2' => 'value', - 'ROOT' => 'value', - 'HTTP_CONTENT_TYPE' => 'text/html', - 'HTTP_CONTENT_LENGTH' => '0', - 'HTTP_ETAG' => 'asdf', - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ); - - $bag = new ServerBag($server); - - $this->assertEquals(array( - 'CONTENT_TYPE' => 'text/html', - 'CONTENT_LENGTH' => '0', - 'ETAG' => 'asdf', - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - ), $bag->getHeaders()); - } - - public function testHttpPasswordIsOptional() - { - $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo')); - - $this->assertEquals(array('AUTHORIZATION' => 'Basic '.base64_encode('foo:')), $bag->getHeaders()); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php deleted file mode 100644 index bd45b2fbe6f46da10287f67168119fee7727baed..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ /dev/null @@ -1,262 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session; - -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\MetadataBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; - -/** - * SessionTest - * - * @author Fabien Potencier - * @author Robert Schönthal - * @author Drak - */ -class SessionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface - */ - protected $storage; - - /** - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - - protected function setUp() - { - $this->storage = new MockArraySessionStorage(); - $this->session = new Session($this->storage, new AttributeBag(), new FlashBag()); - } - - protected function tearDown() - { - $this->storage = null; - $this->session = null; - } - - public function testStart() - { - $this->assertEquals('', $this->session->getId()); - $this->assertTrue($this->session->start()); - $this->assertNotEquals('', $this->session->getId()); - } - - public function testGet() - { - // tests defaults - $this->assertNull($this->session->get('foo')); - $this->assertEquals(1, $this->session->get('foo', 1)); - } - - /** - * @dataProvider setProvider - */ - public function testSet($key, $value) - { - $this->session->set($key, $value); - $this->assertEquals($value, $this->session->get($key)); - } - - /** - * @dataProvider setProvider - */ - public function testHas($key, $value) - { - $this->session->set($key, $value); - $this->assertTrue($this->session->has($key)); - $this->assertFalse($this->session->has($key.'non_value')); - } - - public function testReplace() - { - $this->session->replace(array('happiness' => 'be good', 'symfony' => 'awesome')); - $this->assertEquals(array('happiness' => 'be good', 'symfony' => 'awesome'), $this->session->all()); - $this->session->replace(array()); - $this->assertEquals(array(), $this->session->all()); - } - - /** - * @dataProvider setProvider - */ - public function testAll($key, $value, $result) - { - $this->session->set($key, $value); - $this->assertEquals($result, $this->session->all()); - } - - /** - * @dataProvider setProvider - */ - public function testClear($key, $value) - { - $this->session->set('hi', 'fabien'); - $this->session->set($key, $value); - $this->session->clear(); - $this->assertEquals(array(), $this->session->all()); - } - - public function setProvider() - { - return array( - array('foo', 'bar', array('foo' => 'bar')), - array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')), - array('great', 'symfony2 is great', array('great' => 'symfony2 is great')), - ); - } - - /** - * @dataProvider setProvider - */ - public function testRemove($key, $value) - { - $this->session->set('hi.world', 'have a nice day'); - $this->session->set($key, $value); - $this->session->remove($key); - $this->assertEquals(array('hi.world' => 'have a nice day'), $this->session->all()); - } - - public function testInvalidate() - { - $this->session->set('invalidate', 123); - $this->session->invalidate(); - $this->assertEquals(array(), $this->session->all()); - } - - public function testMigrate() - { - $this->session->set('migrate', 321); - $this->session->migrate(); - $this->assertEquals(321, $this->session->get('migrate')); - } - - public function testMigrateDestroy() - { - $this->session->set('migrate', 333); - $this->session->migrate(true); - $this->assertEquals(333, $this->session->get('migrate')); - } - - public function testSave() - { - $this->session->save(); - } - - public function testGetId() - { - $this->assertEquals('', $this->session->getId()); - $this->session->start(); - $this->assertNotEquals('', $this->session->getId()); - } - - public function testGetFlashBag() - { - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag()); - } - - // deprecated since 2.1, will be removed from 2.3 - - public function testGetSetFlashes() - { - $array = array('notice' => 'hello', 'error' => 'none'); - $this->assertEquals(array(), $this->session->getFlashes()); - $this->session->setFlashes($array); - $this->assertEquals($array, $this->session->getFlashes()); - $this->assertEquals(array(), $this->session->getFlashes()); - $this->session->getFlashBag()->add('notice', 'foo'); - - // test that BC works by only retrieving the first added. - $this->session->getFlashBag()->add('notice', 'foo2'); - $this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes()); - } - - public function testGetSetFlash() - { - $this->assertNull($this->session->getFlash('notice')); - $this->assertEquals('default', $this->session->getFlash('notice', 'default')); - $this->session->getFlashBag()->add('notice', 'foo'); - $this->session->getFlashBag()->add('notice', 'foo2'); - - // test that BC works by only retrieving the first added. - $this->assertEquals('foo', $this->session->getFlash('notice')); - $this->assertNull($this->session->getFlash('notice')); - } - - public function testHasFlash() - { - $this->assertFalse($this->session->hasFlash('notice')); - $this->session->setFlash('notice', 'foo'); - $this->assertTrue($this->session->hasFlash('notice')); - } - - public function testRemoveFlash() - { - $this->session->setFlash('notice', 'foo'); - $this->session->setFlash('error', 'bar'); - $this->assertTrue($this->session->hasFlash('notice')); - $this->session->removeFlash('error'); - $this->assertTrue($this->session->hasFlash('notice')); - $this->assertFalse($this->session->hasFlash('error')); - } - - public function testClearFlashes() - { - $this->assertFalse($this->session->hasFlash('notice')); - $this->assertFalse($this->session->hasFlash('error')); - $this->session->setFlash('notice', 'foo'); - $this->session->setFlash('error', 'bar'); - $this->assertTrue($this->session->hasFlash('notice')); - $this->assertTrue($this->session->hasFlash('error')); - $this->session->clearFlashes(); - $this->assertFalse($this->session->hasFlash('notice')); - $this->assertFalse($this->session->hasFlash('error')); - } - - /** - * @covers Symfony\Component\HttpFoundation\Session\Session::getIterator - */ - public function testGetIterator() - { - $attributes = array('hello' => 'world', 'symfony2' => 'rocks'); - foreach ($attributes as $key => $val) { - $this->session->set($key, $val); - } - - $i = 0; - foreach ($this->session as $key => $val) { - $this->assertEquals($attributes[$key], $val); - $i++; - } - - $this->assertEquals(count($attributes), $i); - } - - /** - * @covers Symfony\Component\HttpFoundation\Session\Session::count - */ - public function testGetCount() - { - $this->session->set('hello', 'world'); - $this->session->set('symfony2', 'rocks'); - - $this->assertEquals(2, count($this->session)); - } - - public function testGetMeta() - { - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\MetadataBag', $this->session->getMetadataBag()); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php deleted file mode 100644 index 49e1568a09820915d590717910eefebf0387dd2e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler; - -class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var MemcacheSessionHandler - */ - protected $storage; - - protected $memcache; - - protected function setUp() - { - if (!class_exists('Memcache')) { - $this->markTestSkipped('Skipped tests Memcache class is not present'); - } - - $this->memcache = $this->getMock('Memcache'); - $this->storage = new MemcacheSessionHandler($this->memcache); - } - - protected function tearDown() - { - $this->memcache = null; - $this->storage = null; - } - - public function testOpenSession() - { - $this->memcache->expects($this->atLeastOnce()) - ->method('addServer') - ->with('127.0.0.1', 11211, false, 1, 1, 15); - - $this->assertTrue($this->storage->open('', '')); - } - - public function testConstructingWithServerPool() - { - $mock = $this->getMock('Memcache'); - - $storage = new MemcacheSessionHandler($mock, array( - 'serverpool' => array( - array('host' => '127.0.0.2'), - array('host' => '127.0.0.3', - 'port' => 11212, - 'timeout' => 10, - 'persistent' => true, - 'weight' => 5, - 'retry_interval' => 39, - ), - array('host' => '127.0.0.4', - 'port' => 11211, - 'weight' => 2 - ), - ), - )); - - $matcher = $mock - ->expects($this->at(0)) - ->method('addServer') - ->with('127.0.0.2', 11211, false, 1, 1, 15); - $matcher = $mock - ->expects($this->at(1)) - ->method('addServer') - ->with('127.0.0.3', 11212, true, 5, 10, 39); - $matcher = $mock - ->expects($this->at(2)) - ->method('addServer') - ->with('127.0.0.4', 11211, false, 2, 1, 15); - $this->assertTrue($storage->open('', '')); - } - - public function testCloseSession() - { - $this->memcache->expects($this->once()) - ->method('close') - ->will($this->returnValue(true)); - - $this->assertTrue($this->storage->close()); - } - - public function testReadSession() - { - $this->memcache->expects($this->once()) - ->method('get'); - - $this->assertEquals('', $this->storage->read('')); - } - - public function testWriteSession() - { - $this->memcache->expects($this->once()) - ->method('set') - ->will($this->returnValue(true)); - - $this->assertTrue($this->storage->write('', '')); - } - - public function testDestroySession() - { - $this->memcache->expects($this->once()) - ->method('delete') - ->will($this->returnValue(true)); - - $this->assertTrue($this->storage->destroy('')); - } - - public function testGcSession() - { - $this->assertTrue($this->storage->gc(123)); - } - -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php deleted file mode 100644 index 5731d92c22dd5ea47f7958ffa44c9b714eebc822..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler; - -class MemcacheddSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var MemcachedSessionHandler - */ - protected $storage; - - protected $memcached; - - protected function setUp() - { - if (!class_exists('Memcached')) { - $this->markTestSkipped('Skipped tests Memcache class is not present'); - } - - $this->memcached = $this->getMock('Memcached'); - $this->storage = new MemcachedSessionHandler($this->memcached); - } - - protected function tearDown() - { - $this->memcached = null; - $this->storage = null; - } - - public function testOpenSession() - { - $this->memcached->expects($this->atLeastOnce()) - ->method('addServers') - ->will($this->returnValue(true)); - - $this->assertTrue($this->storage->open('', '')); - } - - public function testCloseSession() - { - $this->assertTrue($this->storage->close()); - } - - public function testReadSession() - { - $this->memcached->expects($this->once()) - ->method('get'); - - $this->assertEquals('', $this->storage->read('')); - } - - public function testWriteSession() - { - $this->memcached->expects($this->once()) - ->method('set') - ->will($this->returnValue(true)); - - $this->assertTrue($this->storage->write('', '')); - } - - public function testDestroySession() - { - $this->memcached->expects($this->once()) - ->method('delete') - ->will($this->returnValue(true)); - - $this->assertTrue($this->storage->destroy('')); - } - - public function testGcSession() - { - $this->assertTrue($this->storage->gc(123)); - } - - -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php deleted file mode 100644 index 7bdf3a1e3ff0d75afab58a58eef439541f53386f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeFileSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testConstruct() - { - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('files', ini_get('session.save_handler')); - } else { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } - - public function testConstructDefault() - { - $path = ini_get('session.save_path'); - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler()); - - $this->assertEquals($path, ini_get('session.save_path')); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php deleted file mode 100644 index b915e59ca0916bbe35f1f99bafa42e46b556c032..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcacheSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeMemcacheSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeMemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('memcache')) { - $this->markTestSkipped('Skipped tests memcache extension is not present'); - } - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcacheSessionHandler('tcp://127.0.0.1:11211?persistent=0')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('memcache', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('memcache', ini_get('session.save_handler')); - } else { - $this->assertEquals('memcache', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals('tcp://127.0.0.1:11211?persistent=0', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php deleted file mode 100644 index 5f65e9a0fefa6c8fb13ff19f9720b85dcec58ac8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcachedSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeMemcachedSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeMemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('memcached')) { - $this->markTestSkipped('Skipped tests memcached extension is not present'); - } - - // test takes too long if memcached server is not running - ini_set('memcached.sess_locking', '0'); - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcachedSessionHandler('127.0.0.1:11211')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('memcached', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('memcached', ini_get('session.save_handler')); - } else { - $this->assertEquals('memcached', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals('127.0.0.1:11211', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} - diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php deleted file mode 100644 index 8a5777659d88fd213981461174d55f416b091a63..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeRedisSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeRedisSessionHandlerTest. - * - * @runTestsInSeparateProcesses - */ -class NativeRedisSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('redis')) { - $this->markTestSkipped('Skipped tests Redis extension is not present'); - } - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeRedisSessionHandler('tcp://127.0.0.1:6379?persistent=0')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('redis', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('redis', ini_get('session.save_handler')); - } else { - $this->assertEquals('redis', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals('tcp://127.0.0.1:6379?persistent=0', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php deleted file mode 100644 index 983148e2795026a058d4525fbafe3a1f67dec1d4..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSqliteSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeSqliteSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeSqliteSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('sqlite')) { - $this->markTestSkipped('Skipped tests SQLite extension is not present'); - } - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeSqliteSessionHandler(sys_get_temp_dir().'/sqlite.db')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('sqlite', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('sqlite', ini_get('session.save_handler')); - } else { - $this->assertEquals('sqlite', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - - $this->assertEquals(sys_get_temp_dir().'/sqlite.db', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} - diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php deleted file mode 100644 index 9578ec98a81193cd28d1288e86483b6add3230f1..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Test class for MockFileSessionStorage. - * - * @author Drak - */ -class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - private $sessionDir; - - /** - * @var FileMockSessionStorage - */ - protected $storage; - - protected function setUp() - { - $this->sessionDir = sys_get_temp_dir().'/sf2test'; - $this->storage = $this->getStorage(); - } - - protected function tearDown() - { - $this->sessionDir = null; - $this->storage = null; - array_map('unlink', glob($this->sessionDir.'/*.session')); - if (is_dir($this->sessionDir)) { - rmdir($this->sessionDir); - } - } - - public function testStart() - { - $this->assertEquals('', $this->storage->getId()); - $this->assertTrue($this->storage->start()); - $id = $this->storage->getId(); - $this->assertNotEquals('', $this->storage->getId()); - $this->assertTrue($this->storage->start()); - $this->assertEquals($id, $this->storage->getId()); - } - - public function testRegenerate() - { - $this->storage->start(); - $this->storage->getBag('attributes')->set('regenerate', 1234); - $this->storage->regenerate(); - $this->assertEquals(1234, $this->storage->getBag('attributes')->get('regenerate')); - $this->storage->regenerate(true); - $this->assertEquals(1234, $this->storage->getBag('attributes')->get('regenerate')); - } - - public function testGetId() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $this->assertNotEquals('', $this->storage->getId()); - } - - public function testSave() - { - $this->storage->start(); - $id = $this->storage->getId(); - $this->assertNotEquals('108', $this->storage->getBag('attributes')->get('new')); - $this->assertFalse($this->storage->getBag('flashes')->has('newkey')); - $this->storage->getBag('attributes')->set('new', '108'); - $this->storage->getBag('flashes')->set('newkey', 'test'); - $this->storage->save(); - - $storage = $this->getStorage(); - $storage->setId($id); - $storage->start(); - $this->assertEquals('108', $storage->getBag('attributes')->get('new')); - $this->assertTrue($storage->getBag('flashes')->has('newkey')); - $this->assertEquals(array('test'), $storage->getBag('flashes')->peek('newkey')); - } - - public function testMultipleInstances() - { - $storage1 = $this->getStorage(); - $storage1->start(); - $storage1->getBag('attributes')->set('foo', 'bar'); - $storage1->save(); - - $storage2 = $this->getStorage(); - $storage2->setId($storage1->getId()); - $storage2->start(); - $this->assertEquals('bar', $storage2->getBag('attributes')->get('foo'), 'values persist between instances'); - } - - private function getStorage() - { - $storage = new MockFileSessionStorage($this->sessionDir); - $storage->registerBag(new FlashBag); - $storage->registerBag(new AttributeBag); - - return $storage; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php deleted file mode 100644 index 4b88a237a007ed9acb925f425f7d1473a5a4e2e8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ /dev/null @@ -1,155 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Test class for NativeSessionStorage. - * - * @author Drak - * - * These tests require separate processes. - * - * @runTestsInSeparateProcesses - */ -class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase -{ - /** - * @return NativeSessionStorage - */ - protected function getStorage(array $options = array()) - { - $storage = new NativeSessionStorage($options); - $storage->registerBag(new AttributeBag); - - return $storage; - } - - public function testBag() - { - $storage = $this->getStorage(); - $bag = new FlashBag(); - $storage->registerBag($bag); - $this->assertSame($bag, $storage->getBag($bag->getName())); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRegisterBagException() - { - $storage = $this->getStorage(); - $storage->getBag('non_existing'); - } - - public function testGetId() - { - $storage = $this->getStorage(); - $this->assertEquals('', $storage->getId()); - $storage->start(); - $this->assertNotEquals('', $storage->getId()); - } - - public function testRegenerate() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->regenerate(); - $this->assertNotEquals($id, $storage->getId()); - $this->assertEquals(7, $storage->getBag('attributes')->get('lucky')); - - } - - public function testRegenerateDestroy() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('legs', 11); - $storage->regenerate(true); - $this->assertNotEquals($id, $storage->getId()); - $this->assertEquals(11, $storage->getBag('attributes')->get('legs')); - } - - public function testDefaultSessionCacheLimiter() - { - ini_set('session.cache_limiter', 'nocache'); - - $storage = new NativeSessionStorage(); - $this->assertEquals('', ini_get('session.cache_limiter')); - } - - public function testExplicitSessionCacheLimiter() - { - ini_set('session.cache_limiter', 'nocache'); - - $storage = new NativeSessionStorage(array('cache_limiter' => 'public')); - $this->assertEquals('public', ini_get('session.cache_limiter')); - } - - public function testCookieOptions() - { - $options = array( - 'cookie_lifetime' => 123456, - 'cookie_path' => '/my/cookie/path', - 'cookie_domain' => 'symfony2.example.com', - 'cookie_secure' => true, - 'cookie_httponly' => false, - ); - - $this->getStorage($options); - $temp = session_get_cookie_params(); - $gco = array(); - - foreach ($temp as $key => $value) { - $gco['cookie_'.$key] = $value; - } - - $this->assertEquals($options, $gco); - } - - public function testSetSaveHandler() - { - $storage = $this->getStorage(); - $storage->setSaveHandler(new \StdClass()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - } - - public function testSetSaveHandlerPHP53() - { - if (version_compare(phpversion(), '5.4.0', '>=')) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $storage = $this->getStorage(); - $storage->setSaveHandler(new NativeFileSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - } - - public function testSetSaveHandlerPHP54() - { - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->markTestSkipped('Test skipped, for PHP 5.4+ only.'); - } - - $storage = $this->getStorage(); - $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/core/vendor/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php deleted file mode 100644 index d95c93730ad3681e137e46af01da506e96fa93dd..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\StreamedResponse; - -class StreamedResponseTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $response = new StreamedResponse(function () { echo 'foo'; }, 404, array('Content-Type' => 'text/plain')); - - $this->assertEquals(404, $response->getStatusCode()); - $this->assertEquals('text/plain', $response->headers->get('Content-Type')); - } - - public function testPrepareWith11Protocol() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/'); - $request->server->set('SERVER_PROTOCOL', '1.1'); - - $response->prepare($request); - - $this->assertEquals('1.1', $response->getProtocolVersion()); - $this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.'); - $this->assertEquals('no-cache, private', $response->headers->get('Cache-Control')); - } - - public function testPrepareWith10Protocol() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/'); - $request->server->set('SERVER_PROTOCOL', '1.0'); - - $response->prepare($request); - - $this->assertEquals('1.0', $response->getProtocolVersion()); - $this->assertNull($response->headers->get('Transfer-Encoding')); - $this->assertEquals('no-cache, private', $response->headers->get('Cache-Control')); - } - - public function testSendContent() - { - $called = 0; - - $response = new StreamedResponse(function () use (&$called) { ++$called; }); - - $response->sendContent(); - $this->assertEquals(1, $called); - - $response->sendContent(); - $this->assertEquals(1, $called); - } - - /** - * @expectedException \LogicException - */ - public function testSendContentWithNonCallable() - { - $response = new StreamedResponse('foobar'); - $response->sendContent(); - } - - /** - * @expectedException \LogicException - */ - public function testSetContent() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $response->setContent('foo'); - } - - public function testGetContent() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $this->assertFalse($response->getContent()); - } - - public function testCreate() - { - $response = StreamedResponse::create(function () {}, 204); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); - $this->assertEquals(204, $response->getStatusCode()); - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/composer.json b/core/vendor/Symfony/Component/HttpFoundation/composer.json deleted file mode 100644 index d0f1015c096343805bbfdf171d919ddb331fa2b8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "symfony/http-foundation", - "type": "library", - "description": "Symfony HttpFoundation Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2" - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\HttpFoundation": "", - "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" - } - }, - "target-dir": "Symfony/Component/HttpFoundation", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/phpunit.xml.dist b/core/vendor/Symfony/Component/HttpFoundation/phpunit.xml.dist deleted file mode 100644 index 95e0f03d82350bc777212cfeee731de5ca68dce9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - - - - diff --git a/core/vendor/Symfony/Component/HttpKernel/Bundle/BundleInterface.php b/core/vendor/Symfony/Component/HttpKernel/Bundle/BundleInterface.php deleted file mode 100644 index 99d591f9e36bcae53e04e02da4de18b2d673d0ca..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Bundle/BundleInterface.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Bundle; - -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * BundleInterface. - * - * @author Fabien Potencier - * - * @api - */ -interface BundleInterface -{ - /** - * Boots the Bundle. - * - * @api - */ - function boot(); - - /** - * Shutdowns the Bundle. - * - * @api - */ - function shutdown(); - - /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. - * - * @param ContainerBuilder $container A ContainerBuilder instance - * - * @api - */ - function build(ContainerBuilder $container); - - /** - * Returns the container extension that should be implicitly loaded. - * - * @return ExtensionInterface|null The default extension or null if there is none - * - * @api - */ - function getContainerExtension(); - - /** - * Returns the bundle parent name. - * - * @return string The Bundle parent name it overrides or null if no parent - * - * @api - */ - function getParent(); - - /** - * Returns the bundle name (the class short name). - * - * @return string The Bundle name - * - * @api - */ - function getName(); - - /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace - * - * @api - */ - function getNamespace(); - - /** - * Gets the Bundle directory path. - * - * The path should always be returned as a Unix path (with /). - * - * @return string The Bundle absolute path - * - * @api - */ - function getPath(); -} diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php b/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php deleted file mode 100644 index 2406c65a6d4ed252c3375d407ea6267bf498bf31..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Abstract cache warmer that knows how to write a file to the cache. - * - * @author Fabien Potencier - */ -abstract class CacheWarmer implements CacheWarmerInterface -{ - protected function writeCacheFile($file, $content) - { - $tmpFile = tempnam(dirname($file), basename($file)); - if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { - chmod($file, 0666 & ~umask()); - - return; - } - - throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Client.php b/core/vendor/Symfony/Component/HttpKernel/Client.php deleted file mode 100644 index ff93bf7950710e0d9865b17c253fe9184a24b56b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Client.php +++ /dev/null @@ -1,184 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\BrowserKit\Client as BaseClient; -use Symfony\Component\BrowserKit\Request as DomRequest; -use Symfony\Component\BrowserKit\Response as DomResponse; -use Symfony\Component\BrowserKit\Cookie as DomCookie; -use Symfony\Component\BrowserKit\History; -use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\HttpKernel\TerminableInterface; - -/** - * Client simulates a browser and makes requests to a Kernel object. - * - * @author Fabien Potencier - * - * @api - */ -class Client extends BaseClient -{ - protected $kernel; - - /** - * Constructor. - * - * @param HttpKernelInterface $kernel An HttpKernel instance - * @param array $server The server parameters (equivalent of $_SERVER) - * @param History $history A History instance to store the browser history - * @param CookieJar $cookieJar A CookieJar instance to store the cookies - */ - public function __construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) - { - $this->kernel = $kernel; - - parent::__construct($server, $history, $cookieJar); - - $this->followRedirects = false; - } - - /** - * Makes a request. - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - protected function doRequest($request) - { - $response = $this->kernel->handle($request); - - if ($this->kernel instanceof TerminableInterface) { - $this->kernel->terminate($request, $response); - } - - return $response; - } - - /** - * Returns the script to execute when the request must be insulated. - * - * @param Request $request A Request instance - */ - protected function getScript($request) - { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); - - $r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\UniversalClassLoader'); - $requirePath = str_replace("'", "\\'", $r->getFileName()); - - $symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..')); - - return <<registerNamespaces(array('Symfony' => '$symfonyPath')); -\$loader->register(); - -\$kernel = unserialize('$kernel'); -echo serialize(\$kernel->handle(unserialize('$request'))); -EOF; - } - - /** - * Converts the BrowserKit request to a HttpKernel request. - * - * @param DomRequest $request A Request instance - * - * @return Request A Request instance - */ - protected function filterRequest(DomRequest $request) - { - $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); - - $httpRequest->files->replace($this->filterFiles($httpRequest->files->all())); - - return $httpRequest; - } - - /** - * Filters an array of files. - * - * This method created test instances of UploadedFile so that the move() - * method can be called on those instances. - * - * If the size of a file is greater than the allowed size (from php.ini) then - * an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE. - * - * @see Symfony\Component\HttpFoundation\File\UploadedFile - * - * @param array $files An array of files - * - * @return array An array with all uploaded files marked as already moved - */ - protected function filterFiles(array $files) - { - $filtered = array(); - foreach ($files as $key => $value) { - if (is_array($value)) { - $filtered[$key] = $this->filterFiles($value); - } elseif ($value instanceof UploadedFile) { - if ($value->isValid() && $value->getSize() > UploadedFile::getMaxFilesize()) { - $filtered[$key] = new UploadedFile( - '', - $value->getClientOriginalName(), - $value->getClientMimeType(), - 0, - UPLOAD_ERR_INI_SIZE, - true - ); - } else { - $filtered[$key] = new UploadedFile( - $value->getPathname(), - $value->getClientOriginalName(), - $value->getClientMimeType(), - $value->getClientSize(), - $value->getError(), - true - ); - } - } else { - $filtered[$key] = $value; - } - } - - return $filtered; - } - - /** - * Converts the HttpKernel response to a BrowserKit response. - * - * @param Response $response A Response instance - * - * @return Response A Response instance - */ - protected function filterResponse($response) - { - $headers = $response->headers->all(); - if ($response->headers->getCookies()) { - $cookies = array(); - foreach ($response->headers->getCookies() as $cookie) { - $cookies[] = new DomCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - $headers['Set-Cookie'] = $cookies; - } - - return new DomResponse($response->getContent(), $response->getStatusCode(), $headers); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Config/FileLocator.php b/core/vendor/Symfony/Component/HttpKernel/Config/FileLocator.php deleted file mode 100644 index 6cc615ca948dde3fb5e84dd98a1217e27e568c65..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Config/FileLocator.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Config; - -use Symfony\Component\Config\FileLocator as BaseFileLocator; -use Symfony\Component\HttpKernel\KernelInterface; - -/** - * FileLocator uses the KernelInterface to locate resources in bundles. - * - * @author Fabien Potencier - */ -class FileLocator extends BaseFileLocator -{ - private $kernel; - private $path; - - /** - * Constructor. - * - * @param KernelInterface $kernel A KernelInterface instance - * @param string $path The path the global resource directory - * @param string|array $paths A path or an array of paths where to look for resources - */ - public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) - { - $this->kernel = $kernel; - $this->path = $path; - $paths[] = $path; - - parent::__construct($paths); - } - - /** - * {@inheritdoc} - */ - public function locate($file, $currentPath = null, $first = true) - { - if ('@' === $file[0]) { - return $this->kernel->locateResource($file, $this->path, $first); - } - - return parent::locate($file, $currentPath, $first); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolver.php deleted file mode 100644 index d535c55e4b17f8ea873c90df7a716a2ad91bb8e8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ /dev/null @@ -1,160 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller; - -use Symfony\Component\HttpKernel\Log\LoggerInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * ControllerResolver. - * - * This implementation uses the '_controller' request attribute to determine - * the controller to execute and uses the request attributes to determine - * the controller method arguments. - * - * @author Fabien Potencier - * - * @api - */ -class ControllerResolver implements ControllerResolverInterface -{ - private $logger; - - /** - * Constructor. - * - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(LoggerInterface $logger = null) - { - $this->logger = $logger; - } - - /** - * Returns the Controller instance associated with a Request. - * - * This method looks for a '_controller' request attribute that represents - * the controller name (a string like ClassName::MethodName). - * - * @param Request $request A Request instance - * - * @return mixed|Boolean A PHP callable representing the Controller, - * or false if this resolver is not able to determine the controller - * - * @throws \InvalidArgumentException|\LogicException If the controller can't be found - * - * @api - */ - public function getController(Request $request) - { - if (!$controller = $request->attributes->get('_controller')) { - if (null !== $this->logger) { - $this->logger->warn('Unable to look for the controller as the "_controller" parameter is missing'); - } - - return false; - } - - if (is_array($controller) || (is_object($controller) && method_exists($controller, '__invoke'))) { - return $controller; - } - - if (false === strpos($controller, ':')) { - if (method_exists($controller, '__invoke')) { - return new $controller; - } elseif (function_exists($controller)) { - return $controller; - } - } - - list($controller, $method) = $this->createController($controller); - - if (!method_exists($controller, $method)) { - throw new \InvalidArgumentException(sprintf('Method "%s::%s" does not exist.', get_class($controller), $method)); - } - - return array($controller, $method); - } - - /** - * Returns the arguments to pass to the controller. - * - * @param Request $request A Request instance - * @param mixed $controller A PHP callable - * - * @throws \RuntimeException When value for argument given is not provided - * - * @api - */ - public function getArguments(Request $request, $controller) - { - if (is_array($controller)) { - $r = new \ReflectionMethod($controller[0], $controller[1]); - } elseif (is_object($controller) && !$controller instanceof \Closure) { - $r = new \ReflectionObject($controller); - $r = $r->getMethod('__invoke'); - } else { - $r = new \ReflectionFunction($controller); - } - - return $this->doGetArguments($request, $controller, $r->getParameters()); - } - - protected function doGetArguments(Request $request, $controller, array $parameters) - { - $attributes = $request->attributes->all(); - $arguments = array(); - foreach ($parameters as $param) { - if (array_key_exists($param->getName(), $attributes)) { - $arguments[] = $attributes[$param->getName()]; - } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { - $arguments[] = $request; - } elseif ($param->isDefaultValueAvailable()) { - $arguments[] = $param->getDefaultValue(); - } else { - if (is_array($controller)) { - $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); - } elseif (is_object($controller)) { - $repr = get_class($controller); - } else { - $repr = $controller; - } - - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->getName())); - } - } - - return $arguments; - } - - /** - * Returns a callable for the given controller. - * - * @param string $controller A Controller string - * - * @return mixed A PHP callable - */ - protected function createController($controller) - { - if (false === strpos($controller, '::')) { - throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); - } - - list($class, $method) = explode('::', $controller, 2); - - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } - - return array(new $class(), $method); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollector.php deleted file mode 100644 index f1002fbb838bf0909b62d91b64baab0110adf13f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpKernel\Profiler\Profiler; - -/** - * DataCollector. - * - * Children of this class must store the collected data in the data property. - * - * @author Fabien Potencier - */ -abstract class DataCollector implements DataCollectorInterface, \Serializable -{ - protected $data; - - public function serialize() - { - return serialize($this->data); - } - - public function unserialize($data) - { - $this->data = unserialize($data); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php b/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php deleted file mode 100644 index 5e0ff7a0dc6170f03743ffe1e96305d0e766a9e7..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * DataCollectorInterface. - * - * @author Fabien Potencier - * - * @api - */ -interface DataCollectorInterface -{ - /** - * Collects data for the given Request and Response. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * @param \Exception $exception An Exception instance - * - * @api - */ - function collect(Request $request, Response $response, \Exception $exception = null); - - /** - * Returns the name of the collector. - * - * @return string The collector name - * - * @api - */ - function getName(); -} diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/core/vendor/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php deleted file mode 100644 index 4029d7cf4a59029656d6178c13dd6f601908abc9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ /dev/null @@ -1,193 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\HttpFoundation\HeaderBag; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; - -/** - * RequestDataCollector. - * - * @author Fabien Potencier - */ -class RequestDataCollector extends DataCollector -{ - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $responseHeaders = $response->headers->all(); - $cookies = array(); - foreach ($response->headers->getCookies() as $cookie) { - $cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - if (count($cookies) > 0) { - $responseHeaders['Set-Cookie'] = $cookies; - } - - $attributes = array(); - foreach ($request->attributes->all() as $key => $value) { - if (is_object($value)) { - $attributes[$key] = sprintf('Object(%s)', get_class($value)); - if (is_callable(array($value, '__toString'))) { - $attributes[$key] .= sprintf(' = %s', (string) $value); - } - } else { - $attributes[$key] = $value; - } - } - - $content = null; - try { - $content = $request->getContent(); - } catch (\LogicException $e) { - // the user already got the request content as a resource - $content = false; - } - - $this->data = array( - 'format' => $request->getRequestFormat(), - 'content' => $content, - 'content_type' => $response->headers->get('Content-Type') ? $response->headers->get('Content-Type') : 'text/html', - 'status_code' => $response->getStatusCode(), - 'request_query' => $request->query->all(), - 'request_request' => $request->request->all(), - 'request_headers' => $request->headers->all(), - 'request_server' => $request->server->all(), - 'request_cookies' => $request->cookies->all(), - 'request_attributes' => $attributes, - 'response_headers' => $responseHeaders, - 'session_attributes' => $request->hasSession() ? $request->getSession()->all() : array(), - 'flashes' => $request->hasSession() ? $request->getSession()->getFlashBag()->peekAll() : array(), - 'path_info' => $request->getPathInfo(), - ); - } - - public function getPathInfo() - { - return $this->data['path_info']; - } - - public function getRequestRequest() - { - return new ParameterBag($this->data['request_request']); - } - - public function getRequestQuery() - { - return new ParameterBag($this->data['request_query']); - } - - public function getRequestHeaders() - { - return new HeaderBag($this->data['request_headers']); - } - - public function getRequestServer() - { - return new ParameterBag($this->data['request_server']); - } - - public function getRequestCookies() - { - return new ParameterBag($this->data['request_cookies']); - } - - public function getRequestAttributes() - { - return new ParameterBag($this->data['request_attributes']); - } - - public function getResponseHeaders() - { - return new ResponseHeaderBag($this->data['response_headers']); - } - - public function getSessionAttributes() - { - return $this->data['session_attributes']; - } - - public function getFlashes() - { - return $this->data['flashes']; - } - - public function getContent() - { - return $this->data['content']; - } - - public function getContentType() - { - return $this->data['content_type']; - } - - public function getStatusCode() - { - return $this->data['status_code']; - } - - public function getFormat() - { - return $this->data['format']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'request'; - } - - private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly) - { - $cookie = sprintf('%s=%s', $name, urlencode($value)); - - if (0 !== $expires) { - if (is_numeric($expires)) { - $expires = (int) $expires; - } elseif ($expires instanceof \DateTime) { - $expires = $expires->getTimestamp(); - } else { - $expires = strtotime($expires); - if (false === $expires || -1 == $expires) { - throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires)); - } - } - - $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5); - } - - if ($domain) { - $cookie .= '; domain='.$domain; - } - - $cookie .= '; path='.$path; - - if ($secure) { - $cookie .= '; secure'; - } - - if ($httponly) { - $cookie .= '; httponly'; - } - - return $cookie; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/ErrorHandler.php b/core/vendor/Symfony/Component/HttpKernel/Debug/ErrorHandler.php deleted file mode 100644 index 942e82bec1c25ef8359bdf7bc800546e89c9f5db..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Debug/ErrorHandler.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -/** - * ErrorHandler. - * - * @author Fabien Potencier - */ -class ErrorHandler -{ - private $levels = array( - E_WARNING => 'Warning', - E_NOTICE => 'Notice', - E_USER_ERROR => 'User Error', - E_USER_WARNING => 'User Warning', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice', - E_RECOVERABLE_ERROR => 'Catchable Fatal Error', - ); - - private $level; - - /** - * Register the error handler. - * - * @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) - * - * @return The registered error handler - */ - static public function register($level = null) - { - $handler = new static(); - $handler->setLevel($level); - - set_error_handler(array($handler, 'handle')); - - return $handler; - } - - public function setLevel($level) - { - $this->level = null === $level ? error_reporting() : $level; - } - - /** - * @throws \ErrorException When error_reporting returns error - */ - public function handle($level, $message, $file, $line, $context) - { - if (0 === $this->level) { - return false; - } - - if (error_reporting() & $level && $this->level & $level) { - throw new \ErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line)); - } - - return false; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php b/core/vendor/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php deleted file mode 100644 index 36e65419085e878e3b581e93337a4924ca00ca20..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -/** - * Represents an Event managed by Stopwatch. - * - * @author Fabien Potencier - */ -class StopwatchEvent -{ - private $periods; - private $origin; - private $category; - private $started; - - /** - * Constructor. - * - * @param float $origin The origin time in milliseconds - * @param string $category The event category - * - * @throws \InvalidArgumentException When the raw time is not valid - */ - public function __construct($origin, $category = null) - { - $this->origin = $this->formatTime($origin); - $this->category = is_string($category) ? $category : 'default'; - $this->started = array(); - $this->periods = array(); - } - - /** - * Gets the category. - * - * @return string The category - */ - public function getCategory() - { - return $this->category; - } - - /** - * Gets the origin. - * - * @return integer The origin in milliseconds - */ - public function getOrigin() - { - return $this->origin; - } - - /** - * Starts a new event period. - * - * @return StopwatchEvent The event - */ - public function start() - { - $this->started[] = $this->getNow(); - - return $this; - } - - /** - * Stops the last started event period. - * - * @return StopwatchEvent The event - */ - public function stop() - { - if (!count($this->started)) { - throw new \LogicException('stop() called but start() has not been called before.'); - } - - $this->periods[] = array(array_pop($this->started), $this->getNow()); - - return $this; - } - - /** - * Stops the current period and then starts a new one. - * - * @return StopwatchEvent The event - */ - public function lap() - { - return $this->stop()->start(); - } - - /** - * Stops all non already stopped periods. - */ - public function ensureStopped() - { - while (count($this->started)) { - $this->stop(); - } - } - - /** - * Gets all event periods. - * - * @return array An array of periods - */ - public function getPeriods() - { - return $this->periods; - } - - /** - * Gets the relative time of the start of the first period. - * - * @return integer The time (in milliseconds) - */ - public function getStartTime() - { - return isset($this->periods[0]) ? $this->periods[0][0] : 0; - } - - /** - * Gets the relative time of the end of the last period. - * - * @return integer The time (in milliseconds) - */ - public function getEndTime() - { - return ($count = count($this->periods)) ? $this->periods[$count - 1][1] : 0; - } - - /** - * Gets the total time of all periods. - * - * @return integer The time (in milliseconds) - */ - public function getTotalTime() - { - $total = 0; - foreach ($this->periods as $period) { - $total += $period[1] - $period[0]; - } - - return $this->formatTime($total); - } - - /** - * Return the current time relative to origin. - * - * @return float Time in ms - */ - protected function getNow() - { - return $this->formatTime(microtime(true) * 1000 - $this->origin); - } - - /** - * Formats a time. - * - * @param numerical $time A raw time - * - * @return float The formatted time - * - * @throws \InvalidArgumentException When the raw time is not valid - */ - private function formatTime($time) - { - if (!is_numeric($time)) { - throw new \InvalidArgumentException('The time must be a numerical value'); - } - - return round($time, 1); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php b/core/vendor/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php deleted file mode 100755 index 4f6f6a3dd5097181a57e04d5925febe2111630a9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * This extension sub-class provides first-class integration with the - * Config/Definition Component. - * - * You can use this as base class if you - * - * a) use the Config/Definition component for configuration - * b) your configuration class is named "Configuration" and - * c) the configuration class resides in the DependencyInjection sub-folder - * - * @author Johannes M. Schmitt - */ -abstract class ConfigurableExtension extends Extension -{ - /** - * {@inheritDoc} - */ - public final function load(array $configs, ContainerBuilder $container) - { - $this->loadInternal($this->processConfiguration($this->getConfiguration(array(), $container), $configs), $container); - } - - /** - * Configures the passed container according to the merged configuration. - * - * @param array $mergedConfig - * @param ContainerBuilder $container - */ - abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container); -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/core/vendor/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php deleted file mode 100644 index fbac347fae6a1a1f8f9b6c8b5d82437829131a28..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows filtering of a controller callable - * - * You can call getController() to retrieve the current controller. With - * setController() you can set a new controller that is used in the processing - * of the request. - * - * Controllers should be callables. - * - * @author Bernhard Schussek - * - * @api - */ -class FilterControllerEvent extends KernelEvent -{ - /** - * The current controller - * @var callable - */ - private $controller; - - public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType) - { - parent::__construct($kernel, $request, $requestType); - - $this->setController($controller); - } - - /** - * Returns the current controller - * - * @return callable - * - * @api - */ - public function getController() - { - return $this->controller; - } - - /** - * Sets a new controller - * - * @param callable $controller - * - * @api - */ - public function setController($controller) - { - // controller must be a callable - if (!is_callable($controller)) { - throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller))); - } - - $this->controller = $controller; - } - - private function varToString($var) - { - if (is_object($var)) { - return sprintf('Object(%s)', get_class($var)); - } - - if (is_array($var)) { - $a = array(); - foreach ($var as $k => $v) { - $a[] = sprintf('%s => %s', $k, $this->varToString($v)); - } - - return sprintf("Array(%s)", implode(', ', $a)); - } - - if (is_resource($var)) { - return sprintf('Resource(%s)', get_resource_type($var)); - } - - if (null === $var) { - return 'null'; - } - - if (false === $var) { - return 'false'; - } - - if (true === $var) { - return 'true'; - } - - return (string) $var; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php b/core/vendor/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php deleted file mode 100644 index 7e1f4a209fe32b1feb90fb8aea0c92e8c7adb34a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to filter a Response object - * - * You can call getResponse() to retrieve the current response. With - * setResponse() you can set a new response that will be returned to the - * browser. - * - * @author Bernhard Schussek - * - * @api - */ -class FilterResponseEvent extends KernelEvent -{ - /** - * The current response object - * @var Symfony\Component\HttpFoundation\Response - */ - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, Response $response) - { - parent::__construct($kernel, $request, $requestType); - - $this->setResponse($response); - } - - /** - * Returns the current response object - * - * @return Symfony\Component\HttpFoundation\Response - * - * @api - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a new response object - * - * @param Symfony\Component\HttpFoundation\Response $response - * - * @api - */ - public function setResponse(Response $response) - { - $this->response = $response; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseEvent.php b/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseEvent.php deleted file mode 100644 index eb726c046261c99c2cc566b0dcc3de8d437b4b30..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseEvent.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to create a response for a request - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * @author Bernhard Schussek - * - * @api - */ -class GetResponseEvent extends KernelEvent -{ - /** - * The response object - * @var Symfony\Component\HttpFoundation\Response - */ - private $response; - - /** - * Returns the response object - * - * @return Symfony\Component\HttpFoundation\Response - * - * @api - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a response and stops event propagation - * - * @param Symfony\Component\HttpFoundation\Response $response - * - * @api - */ - public function setResponse(Response $response) - { - $this->response = $response; - - $this->stopPropagation(); - } - - /** - * Returns whether a response was set - * - * @return Boolean Whether a response was set - * - * @api - */ - public function hasResponse() - { - return null !== $this->response; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php deleted file mode 100644 index 25ceca8b85b22069421c7af2ed916375c0447bfc..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows to create a response for the return value of a controller - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * @author Bernhard Schussek - * - * @api - */ -class GetResponseForControllerResultEvent extends GetResponseEvent -{ - /** - * The return value of the controller - * @var mixed - */ - private $controllerResult; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, $controllerResult) - { - parent::__construct($kernel, $request, $requestType); - - $this->controllerResult = $controllerResult; - } - - /** - * Returns the return value of the controller - * - * @return mixed The controller return value - * - * @api - */ - public function getControllerResult() - { - return $this->controllerResult; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php b/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php deleted file mode 100644 index f7cf28d95114a692de4196a8d068f7ddffb4c72e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows to create a response for a thrown exception - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * You can also call setException() to replace the thrown exception. This - * exception will be thrown if no response is set during processing of this - * event. - * - * @author Bernhard Schussek - * - * @api - */ -class GetResponseForExceptionEvent extends GetResponseEvent -{ - /** - * The exception object - * @var \Exception - */ - private $exception; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e) - { - parent::__construct($kernel, $request, $requestType); - - $this->setException($e); - } - - /** - * Returns the thrown exception - * - * @return \Exception The thrown exception - * - * @api - */ - public function getException() - { - return $this->exception; - } - - /** - * Replaces the thrown exception - * - * This exception will be thrown if no response is set in the event. - * - * @param \Exception $exception The thrown exception - * - * @api - */ - public function setException(\Exception $exception) - { - $this->exception = $exception; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/KernelEvent.php b/core/vendor/Symfony/Component/HttpKernel/Event/KernelEvent.php deleted file mode 100644 index 4dcfd11819ed99dfdc70cb8fe188fefacc937a17..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\Event; - -/** - * Base class for events thrown in the HttpKernel component - * - * @author Bernhard Schussek - * - * @api - */ -class KernelEvent extends Event -{ - /** - * The kernel in which this event was thrown - * @var Symfony\Component\HttpKernel\HttpKernelInterface - */ - private $kernel; - - /** - * The request the kernel is currently processing - * @var Symfony\Component\HttpFoundation\Request - */ - private $request; - - /** - * The request type the kernel is currently processing. One of - * HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST - * @var integer - */ - private $requestType; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType) - { - $this->kernel = $kernel; - $this->request = $request; - $this->requestType = $requestType; - } - - /** - * Returns the kernel in which this event was thrown - * - * @return Symfony\Component\HttpKernel\HttpKernelInterface - * - * @api - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Returns the request the kernel is currently processing - * - * @return Symfony\Component\HttpFoundation\Request - * - * @api - */ - public function getRequest() - { - return $this->request; - } - - /** - * Returns the request type the kernel is currently processing - * - * @return integer One of HttpKernelInterface::MASTER_REQUEST and - * HttpKernelInterface::SUB_REQUEST - * - * @api - */ - public function getRequestType() - { - return $this->requestType; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/core/vendor/Symfony/Component/HttpKernel/EventListener/LocaleListener.php deleted file mode 100644 index 8adefc55307876b9ebd1a104dea3b63d1e7ce1e8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/EventListener/LocaleListener.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Initializes the locale based on the current request. - * - * @author Fabien Potencier - */ -class LocaleListener implements EventSubscriberInterface -{ - private $router; - private $defaultLocale; - - public function __construct($defaultLocale = 'en', RouterInterface $router = null) - { - $this->defaultLocale = $defaultLocale; - $this->router = $router; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - - if ($request->hasPreviousSession()) { - $request->setDefaultLocale($request->getSession()->get('_locale', $this->defaultLocale)); - } else { - $request->setDefaultLocale($this->defaultLocale); - } - - if ($locale = $request->attributes->get('_locale')) { - $request->setLocale($locale); - - if ($request->hasPreviousSession()) { - $request->getSession()->set('_locale', $request->getLocale()); - } - } - - if (null !== $this->router) { - $this->router->getContext()->setParameter('_locale', $request->getLocale()); - } - } - - static public function getSubscribedEvents() - { - return array( - // must be registered after the Router to have access to the _locale - KernelEvents::REQUEST => array(array('onKernelRequest', 16)), - ); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/core/vendor/Symfony/Component/HttpKernel/EventListener/RouterListener.php deleted file mode 100644 index 5d5a5436d393a90918df93195971a814a2bbfec0..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Log\LoggerInterface; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Initializes request attributes based on a matching route. - * - * @author Fabien Potencier - */ -class RouterListener implements EventSubscriberInterface -{ - private $urlMatcher; - private $logger; - - public function __construct(UrlMatcherInterface $urlMatcher, LoggerInterface $logger = null) - { - $this->urlMatcher = $urlMatcher; - $this->logger = $logger; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - - if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { - $this->urlMatcher->getContext()->fromRequest($request); - } - - if ($request->attributes->has('_controller')) { - // routing is already done - return; - } - - // add attributes based on the path info (routing) - try { - $parameters = $this->urlMatcher->match($request->getPathInfo()); - - if (null !== $this->logger) { - $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters))); - } - - $request->attributes->add($parameters); - unset($parameters['_route']); - unset($parameters['_controller']); - $request->attributes->set('_route_params', $parameters); - } catch (ResourceNotFoundException $e) { - $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo()); - - throw new NotFoundHttpException($message, $e); - } catch (MethodNotAllowedException $e) { - $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), strtoupper(implode(', ', $e->getAllowedMethods()))); - - throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); - } - } - - private function parametersToString(array $parameters) - { - $pieces = array(); - foreach ($parameters as $key => $val) { - $pieces[] = sprintf('"%s": "%s"', $key, (is_string($val) ? $val : json_encode($val))); - } - - return implode(', ', $pieces); - } - - static public function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 32)), - ); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/core/vendor/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php deleted file mode 100644 index 7ae7b7a85cff637112c8d91063bd2736dc7421ee..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * MethodNotAllowedHttpException. - * - * @author Kris Wallsmith - */ -class MethodNotAllowedHttpException extends HttpException -{ - /** - * Constructor. - * - * @param array $allow An array of allowed methods - * @param string $message The internal exception message - * @param Exception $previous The previous exception - * @param integer $code The internal exception code - */ - public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0) - { - $headers = array('Allow' => strtoupper(implode(', ', $allow))); - - parent::__construct(405, $message, $previous, $headers, $code); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/core/vendor/Symfony/Component/HttpKernel/HttpCache/HttpCache.php deleted file mode 100644 index ce3e005d920ec48b08753b574587613bf8cce8cd..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ /dev/null @@ -1,660 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\TerminableInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Cache provides HTTP caching. - * - * @author Fabien Potencier - * - * @api - */ -class HttpCache implements HttpKernelInterface, TerminableInterface -{ - private $kernel; - private $store; - private $request; - private $esi; - private $esiCacheStrategy; - private $traces; - - /** - * Constructor. - * - * The available options are: - * - * * debug: If true, the traces are added as a HTTP header to ease debugging - * - * * default_ttl The number of seconds that a cache entry should be considered - * fresh when no explicit freshness information is provided in - * a response. Explicit Cache-Control or Expires headers - * override this value. (default: 0) - * - * * private_headers Set of request headers that trigger "private" cache-control behavior - * on responses that don't explicitly state whether the response is - * public or private via a Cache-Control directive. (default: Authorization and Cookie) - * - * * allow_reload Specifies whether the client can force a cache reload by including a - * Cache-Control "no-cache" directive in the request. Set it to ``true`` - * for compliance with RFC 2616. (default: false) - * - * * allow_revalidate Specifies whether the client can force a cache revalidate by including - * a Cache-Control "max-age=0" directive in the request. Set it to ``true`` - * for compliance with RFC 2616. (default: false) - * - * * stale_while_revalidate Specifies the default number of seconds (the granularity is the second as the - * Response TTL precision is a second) during which the cache can immediately return - * a stale response while it revalidates it in the background (default: 2). - * This setting is overridden by the stale-while-revalidate HTTP Cache-Control - * extension (see RFC 5861). - * - * * stale_if_error Specifies the default number of seconds (the granularity is the second) during which - * the cache can serve a stale response when an error is encountered (default: 60). - * This setting is overridden by the stale-if-error HTTP Cache-Control extension - * (see RFC 5861). - * - * @param HttpKernelInterface $kernel An HttpKernelInterface instance - * @param StoreInterface $store A Store instance - * @param Esi $esi An Esi instance - * @param array $options An array of options - */ - public function __construct(HttpKernelInterface $kernel, StoreInterface $store, Esi $esi = null, array $options = array()) - { - $this->store = $store; - $this->kernel = $kernel; - - // needed in case there is a fatal error because the backend is too slow to respond - register_shutdown_function(array($this->store, 'cleanup')); - - $this->options = array_merge(array( - 'debug' => false, - 'default_ttl' => 0, - 'private_headers' => array('Authorization', 'Cookie'), - 'allow_reload' => false, - 'allow_revalidate' => false, - 'stale_while_revalidate' => 2, - 'stale_if_error' => 60, - ), $options); - $this->esi = $esi; - $this->traces = array(); - } - - /** - * Gets the current store. - * - * @return StoreInterface $store A StoreInterface instance - */ - public function getStore() - { - return $this->store; - } - - /** - * Returns an array of events that took place during processing of the last request. - * - * @return array An array of events - */ - public function getTraces() - { - return $this->traces; - } - - /** - * Returns a log message for the events of the last request processing. - * - * @return string A log message - */ - public function getLog() - { - $log = array(); - foreach ($this->traces as $request => $traces) { - $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); - } - - return implode('; ', $log); - } - - /** - * Gets the Request instance associated with the master request. - * - * @return Symfony\Component\HttpFoundation\Request A Request instance - */ - public function getRequest() - { - return $this->request; - } - - /** - * Gets the Kernel instance - * - * @return Symfony\Component\HttpKernel\HttpKernelInterface An HttpKernelInterface instance - */ - public function getKernel() - { - return $this->kernel; - } - - - /** - * Gets the Esi instance - * - * @return Symfony\Component\HttpKernel\HttpCache\Esi An Esi instance - */ - public function getEsi() - { - return $this->esi; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism - if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->traces = array(); - $this->request = $request; - if (null !== $this->esi) { - $this->esiCacheStrategy = $this->esi->createCacheStrategy(); - } - } - - $path = $request->getPathInfo(); - if ($qs = $request->getQueryString()) { - $path .= '?'.$qs; - } - $this->traces[$request->getMethod().' '.$path] = array(); - - if (!$request->isMethodSafe()) { - $response = $this->invalidate($request, $catch); - } elseif ($request->headers->has('expect')) { - $response = $this->pass($request, $catch); - } else { - $response = $this->lookup($request, $catch); - } - - $response->isNotModified($request); - - $this->restoreResponseBody($request, $response); - - $response->setDate(new \DateTime(null, new \DateTimeZone('UTC'))); - - if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) { - $response->headers->set('X-Symfony-Cache', $this->getLog()); - } - - if (null !== $this->esi) { - $this->esiCacheStrategy->add($response); - - if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->esiCacheStrategy->update($response); - } - } - - $response->prepare($request); - - return $response; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function terminate(Request $request, Response $response) - { - if ($this->getKernel() instanceof TerminableInterface) { - $this->getKernel()->terminate($request, $response); - } - } - - /** - * Forwards the Request to the backend without storing the Response in the cache. - * - * @param Request $request A Request instance - * @param Boolean $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function pass(Request $request, $catch = false) - { - $this->record($request, 'pass'); - - return $this->forward($request, $catch); - } - - /** - * Invalidates non-safe methods (like POST, PUT, and DELETE). - * - * @param Request $request A Request instance - * @param Boolean $catch Whether to process exceptions - * - * @return Response A Response instance - * - * @see RFC2616 13.10 - */ - protected function invalidate(Request $request, $catch = false) - { - $response = $this->pass($request, $catch); - - // invalidate only when the response is successful - if ($response->isSuccessful() || $response->isRedirect()) { - try { - $this->store->invalidate($request, $catch); - - $this->record($request, 'invalidate'); - } catch (\Exception $e) { - $this->record($request, 'invalidate-failed'); - - if ($this->options['debug']) { - throw $e; - } - } - } - - return $response; - } - - /** - * Lookups a Response from the cache for the given Request. - * - * When a matching cache entry is found and is fresh, it uses it as the - * response without forwarding any request to the backend. When a matching - * cache entry is found but is stale, it attempts to "validate" the entry with - * the backend using conditional GET. When no matching cache entry is found, - * it triggers "miss" processing. - * - * @param Request $request A Request instance - * @param Boolean $catch whether to process exceptions - * - * @return Response A Response instance - */ - protected function lookup(Request $request, $catch = false) - { - // if allow_reload and no-cache Cache-Control, allow a cache reload - if ($this->options['allow_reload'] && $request->isNoCache()) { - $this->record($request, 'reload'); - - return $this->fetch($request); - } - - try { - $entry = $this->store->lookup($request); - } catch (\Exception $e) { - $this->record($request, 'lookup-failed'); - - if ($this->options['debug']) { - throw $e; - } - - return $this->pass($request, $catch); - } - - if (null === $entry) { - $this->record($request, 'miss'); - - return $this->fetch($request, $catch); - } - - if (!$this->isFreshEnough($request, $entry)) { - $this->record($request, 'stale'); - - return $this->validate($request, $entry, $catch); - } - - $this->record($request, 'fresh'); - - $entry->headers->set('Age', $entry->getAge()); - - return $entry; - } - - /** - * Validates that a cache entry is fresh. - * - * The original request is used as a template for a conditional - * GET request with the backend. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance to validate - * @param Boolean $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function validate(Request $request, Response $entry, $catch = false) - { - $subRequest = clone $request; - - // send no head requests because we want content - $subRequest->setMethod('GET'); - - // add our cached last-modified validator - $subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified')); - - // Add our cached etag validator to the environment. - // We keep the etags from the client to handle the case when the client - // has a different private valid entry which is not cached here. - $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array(); - $requestEtags = $request->getEtags(); - if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) { - $subRequest->headers->set('if_none_match', implode(', ', $etags)); - } - - $response = $this->forward($subRequest, $catch, $entry); - - if (304 == $response->getStatusCode()) { - $this->record($request, 'valid'); - - // return the response and not the cache entry if the response is valid but not cached - $etag = $response->getEtag(); - if ($etag && in_array($etag, $requestEtags) && !in_array($etag, $cachedEtags)) { - return $response; - } - - $entry = clone $entry; - $entry->headers->remove('Date'); - - foreach (array('Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified') as $name) { - if ($response->headers->has($name)) { - $entry->headers->set($name, $response->headers->get($name)); - } - } - - $response = $entry; - } else { - $this->record($request, 'invalid'); - } - - if ($response->isCacheable()) { - $this->store($request, $response); - } - - return $response; - } - - /** - * Forwards the Request to the backend and determines whether the response should be stored. - * - * This methods is triggered when the cache missed or a reload is required. - * - * @param Request $request A Request instance - * @param Boolean $catch whether to process exceptions - * - * @return Response A Response instance - */ - protected function fetch(Request $request, $catch = false) - { - $subRequest = clone $request; - - // send no head requests because we want content - $subRequest->setMethod('GET'); - - // avoid that the backend sends no content - $subRequest->headers->remove('if_modified_since'); - $subRequest->headers->remove('if_none_match'); - - $response = $this->forward($subRequest, $catch); - - if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { - $response->setPrivate(true); - } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { - $response->setTtl($this->options['default_ttl']); - } - - if ($response->isCacheable()) { - $this->store($request, $response); - } - - return $response; - } - - /** - * Forwards the Request to the backend and returns the Response. - * - * @param Request $request A Request instance - * @param Boolean $catch Whether to catch exceptions or not - * @param Response $entry A Response instance (the stale entry if present, null otherwise) - * - * @return Response A Response instance - */ - protected function forward(Request $request, $catch = false, Response $entry = null) - { - if ($this->esi) { - $this->esi->addSurrogateEsiCapability($request); - } - - // always a "master" request (as the real master request can be in cache) - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); - // FIXME: we probably need to also catch exceptions if raw === true - - // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC - if (null !== $entry && in_array($response->getStatusCode(), array(500, 502, 503, 504))) { - if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { - $age = $this->options['stale_if_error']; - } - - if (abs($entry->getTtl()) < $age) { - $this->record($request, 'stale-if-error'); - - return $entry; - } - } - - $this->processResponseBody($request, $response); - - return $response; - } - - /** - * Checks whether the cache entry is "fresh enough" to satisfy the Request. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance - * - * @return Boolean true if the cache entry if fresh enough, false otherwise - */ - protected function isFreshEnough(Request $request, Response $entry) - { - if (!$entry->isFresh()) { - return $this->lock($request, $entry); - } - - if ($this->options['allow_revalidate'] && null !== $maxAge = $request->headers->getCacheControlDirective('max-age')) { - return $maxAge > 0 && $maxAge >= $entry->getAge(); - } - - return true; - } - - /** - * Locks a Request during the call to the backend. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance - * - * @return Boolean true if the cache entry can be returned even if it is staled, false otherwise - */ - protected function lock(Request $request, Response $entry) - { - // try to acquire a lock to call the backend - $lock = $this->store->lock($request, $entry); - - // there is already another process calling the backend - if (true !== $lock) { - // check if we can serve the stale entry - if (null === $age = $entry->headers->getCacheControlDirective('stale-while-revalidate')) { - $age = $this->options['stale_while_revalidate']; - } - - if (abs($entry->getTtl()) < $age) { - $this->record($request, 'stale-while-revalidate'); - - // server the stale response while there is a revalidation - return true; - } - - // wait for the lock to be released - $wait = 0; - while (is_file($lock) && $wait < 5000000) { - usleep(50000); - $wait += 50000; - } - - if ($wait < 2000000) { - // replace the current entry with the fresh one - $new = $this->lookup($request); - $entry->headers = $new->headers; - $entry->setContent($new->getContent()); - $entry->setStatusCode($new->getStatusCode()); - $entry->setProtocolVersion($new->getProtocolVersion()); - foreach ($new->headers->getCookies() as $cookie) { - $entry->headers->setCookie($cookie); - } - } else { - // backend is slow as hell, send a 503 response (to avoid the dog pile effect) - $entry->setStatusCode(503); - $entry->setContent('503 Service Unavailable'); - $entry->headers->set('Retry-After', 10); - } - - return true; - } - - // we have the lock, call the backend - return false; - } - - /** - * Writes the Response to the cache. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - */ - protected function store(Request $request, Response $response) - { - try { - $this->store->write($request, $response); - - $this->record($request, 'store'); - - $response->headers->set('Age', $response->getAge()); - } catch (\Exception $e) { - $this->record($request, 'store-failed'); - - if ($this->options['debug']) { - throw $e; - } - } - - // now that the response is cached, release the lock - $this->store->unlock($request); - } - - /** - * Restores the Response body. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @return Response A Response instance - */ - private function restoreResponseBody(Request $request, Response $response) - { - if ('HEAD' === $request->getMethod() || 304 === $response->getStatusCode()) { - $response->setContent(''); - $response->headers->remove('X-Body-Eval'); - $response->headers->remove('X-Body-File'); - - return; - } - - if ($response->headers->has('X-Body-Eval')) { - ob_start(); - - if ($response->headers->has('X-Body-File')) { - include $response->headers->get('X-Body-File'); - } else { - eval('; ?>'.$response->getContent().'setContent(ob_get_clean()); - $response->headers->remove('X-Body-Eval'); - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); - } - } elseif ($response->headers->has('X-Body-File')) { - $response->setContent(file_get_contents($response->headers->get('X-Body-File'))); - } else { - return; - } - - $response->headers->remove('X-Body-File'); - } - - protected function processResponseBody(Request $request, Response $response) - { - if (null !== $this->esi && $this->esi->needsEsiParsing($response)) { - $this->esi->process($request, $response); - } - } - - /** - * Checks if the Request includes authorization or other sensitive information - * that should cause the Response to be considered private by default. - * - * @param Request $request A Request instance - * - * @return Boolean true if the Request is private, false otherwise - */ - private function isPrivateRequest(Request $request) - { - foreach ($this->options['private_headers'] as $key) { - $key = strtolower(str_replace('HTTP_', '', $key)); - - if ('cookie' === $key) { - if (count($request->cookies->all())) { - return true; - } - } elseif ($request->headers->has($key)) { - return true; - } - } - - return false; - } - - /** - * Records that an event took place. - * - * @param Request $request A Request instance - * @param string $event The event name - */ - private function record(Request $request, $event) - { - $path = $request->getPathInfo(); - if ($qs = $request->getQueryString()) { - $path .= '?'.$qs; - } - $this->traces[$request->getMethod().' '.$path][] = $event; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/Store.php b/core/vendor/Symfony/Component/HttpKernel/HttpCache/Store.php deleted file mode 100644 index fe19f3a54db3d03777dc256b8c2d5af579b33e3f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/HttpCache/Store.php +++ /dev/null @@ -1,403 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Store implements all the logic for storing cache metadata (Request and Response headers). - * - * @author Fabien Potencier - */ -class Store implements StoreInterface -{ - private $root; - private $keyCache; - private $locks; - - /** - * Constructor. - * - * @param string $root The path to the cache directory - */ - public function __construct($root) - { - $this->root = $root; - if (!is_dir($this->root)) { - mkdir($this->root, 0777, true); - } - $this->keyCache = new \SplObjectStorage(); - $this->locks = array(); - } - - /** - * Cleanups storage. - */ - public function cleanup() - { - // unlock everything - foreach ($this->locks as $lock) { - @unlink($lock); - } - - $error = error_get_last(); - if (1 === $error['type'] && false === headers_sent()) { - // send a 503 - header('HTTP/1.0 503 Service Unavailable'); - header('Retry-After: 10'); - echo '503 Service Unavailable'; - } - } - - /** - * Locks the cache for a given Request. - * - * @param Request $request A Request instance - * - * @return Boolean|string true if the lock is acquired, the path to the current lock otherwise - */ - public function lock(Request $request) - { - if (false !== $lock = @fopen($path = $this->getPath($this->getCacheKey($request).'.lck'), 'x')) { - fclose($lock); - - $this->locks[] = $path; - - return true; - } - - return $path; - } - - /** - * Releases the lock for the given Request. - * - * @param Request $request A Request instance - */ - public function unlock(Request $request) - { - return @unlink($this->getPath($this->getCacheKey($request).'.lck')); - } - - /** - * Locates a cached Response for the Request provided. - * - * @param Request $request A Request instance - * - * @return Response|null A Response instance, or null if no cache entry was found - */ - public function lookup(Request $request) - { - $key = $this->getCacheKey($request); - - if (!$entries = $this->getMetadata($key)) { - return null; - } - - // find a cached entry that matches the request. - $match = null; - foreach ($entries as $entry) { - if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? $entry[1]['vary'][0] : '', $request->headers->all(), $entry[0])) { - $match = $entry; - - break; - } - } - - if (null === $match) { - return null; - } - - list($req, $headers) = $match; - if (is_file($body = $this->getPath($headers['x-content-digest'][0]))) { - return $this->restoreResponse($headers, $body); - } - - // TODO the metaStore referenced an entity that doesn't exist in - // the entityStore. We definitely want to return nil but we should - // also purge the entry from the meta-store when this is detected. - return null; - } - - /** - * Writes a cache entry to the store for the given Request and Response. - * - * Existing entries are read and any that match the response are removed. This - * method calls write with the new list of cache entries. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @return string The key under which the response is stored - */ - public function write(Request $request, Response $response) - { - $key = $this->getCacheKey($request); - $storedEnv = $this->persistRequest($request); - - // write the response body to the entity store if this is the original response - if (!$response->headers->has('X-Content-Digest')) { - $digest = 'en'.sha1($response->getContent()); - - if (false === $this->save($digest, $response->getContent())) { - throw new \RuntimeException('Unable to store the entity.'); - } - - $response->headers->set('X-Content-Digest', $digest); - - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); - } - } - - // read existing cache entries, remove non-varying, and add this one to the list - $entries = array(); - $vary = $response->headers->get('vary'); - foreach ($this->getMetadata($key) as $entry) { - if (!isset($entry[1]['vary'])) { - $entry[1]['vary'] = array(''); - } - - if ($vary != $entry[1]['vary'][0] || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { - $entries[] = $entry; - } - } - - $headers = $this->persistResponse($response); - unset($headers['age']); - - array_unshift($entries, array($storedEnv, $headers)); - - if (false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } - - return $key; - } - - /** - * Invalidates all cache entries that match the request. - * - * @param Request $request A Request instance - */ - public function invalidate(Request $request) - { - $modified = false; - $key = $this->getCacheKey($request); - - $entries = array(); - foreach ($this->getMetadata($key) as $entry) { - $response = $this->restoreResponse($entry[1]); - if ($response->isFresh()) { - $response->expire(); - $modified = true; - $entries[] = array($entry[0], $this->persistResponse($response)); - } else { - $entries[] = $entry; - } - } - - if ($modified) { - if (false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } - } - - // As per the RFC, invalidate Location and Content-Location URLs if present - foreach (array('Location', 'Content-Location') as $header) { - if ($uri = $request->headers->get($header)) { - $subRequest = Request::create($uri, 'get', array(), array(), array(), $request->server->all()); - - $this->invalidate($subRequest); - } - } - } - - /** - * Determines whether two Request HTTP header sets are non-varying based on - * the vary response header value provided. - * - * @param string $vary A Response vary header - * @param array $env1 A Request HTTP header array - * @param array $env2 A Request HTTP header array - * - * @return Boolean true if the the two environments match, false otherwise - */ - private function requestsMatch($vary, $env1, $env2) - { - if (empty($vary)) { - return true; - } - - foreach (preg_split('/[\s,]+/', $vary) as $header) { - $key = strtr(strtolower($header), '_', '-'); - $v1 = isset($env1[$key]) ? $env1[$key] : null; - $v2 = isset($env2[$key]) ? $env2[$key] : null; - if ($v1 !== $v2) { - return false; - } - } - - return true; - } - - /** - * Gets all data associated with the given key. - * - * Use this method only if you know what you are doing. - * - * @param string $key The store key - * - * @return array An array of data associated with the key - */ - private function getMetadata($key) - { - if (false === $entries = $this->load($key)) { - return array(); - } - - return unserialize($entries); - } - - /** - * Purges data for the given URL. - * - * @param string $url A URL - * - * @return Boolean true if the URL exists and has been purged, false otherwise - */ - public function purge($url) - { - if (is_file($path = $this->getPath($this->getCacheKey(Request::create($url))))) { - unlink($path); - - return true; - } - - return false; - } - - /** - * Loads data for the given key. - * - * @param string $key The store key - * - * @return string The data associated with the key - */ - private function load($key) - { - $path = $this->getPath($key); - - return is_file($path) ? file_get_contents($path) : false; - } - - /** - * Save data for the given key. - * - * @param string $key The store key - * @param string $data The data to store - */ - private function save($key, $data) - { - $path = $this->getPath($key); - if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) { - return false; - } - - $tmpFile = tempnam(dirname($path), basename($path)); - if (false === $fp = @fopen($tmpFile, 'wb')) { - return false; - } - @fwrite($fp, $data); - @fclose($fp); - - if ($data != file_get_contents($tmpFile)) { - return false; - } - - if (false === @rename($tmpFile, $path)) { - return false; - } - - chmod($path, 0666 & ~umask()); - } - - public function getPath($key) - { - return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6); - } - - /** - * Returns a cache key for the given Request. - * - * @param Request $request A Request instance - * - * @return string A key for the given Request - */ - private function getCacheKey(Request $request) - { - if (isset($this->keyCache[$request])) { - return $this->keyCache[$request]; - } - - return $this->keyCache[$request] = 'md'.sha1($request->getUri()); - } - - /** - * Persists the Request HTTP headers. - * - * @param Request $request A Request instance - * - * @return array An array of HTTP headers - */ - private function persistRequest(Request $request) - { - return $request->headers->all(); - } - - /** - * Persists the Response HTTP headers. - * - * @param Response $response A Response instance - * - * @return array An array of HTTP headers - */ - private function persistResponse(Response $response) - { - $headers = $response->headers->all(); - $headers['X-Status'] = array($response->getStatusCode()); - - return $headers; - } - - /** - * Restores a Response from the HTTP headers and body. - * - * @param array $headers An array of HTTP headers for the Response - * @param string $body The Response body - */ - private function restoreResponse($headers, $body = null) - { - $status = $headers['X-Status'][0]; - unset($headers['X-Status']); - - if (null !== $body) { - $headers['X-Body-File'] = array($body); - } - - return new Response($body, $status, $headers); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpKernel.php b/core/vendor/Symfony/Component/HttpKernel/HttpKernel.php deleted file mode 100644 index 9a465d1df38b105cbcf904baae1f13d4ca821c33..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/HttpKernel.php +++ /dev/null @@ -1,231 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * HttpKernel notifies events to convert a Request object to a Response one. - * - * @author Fabien Potencier - * - * @api - */ -class HttpKernel implements HttpKernelInterface, TerminableInterface -{ - protected $dispatcher; - protected $resolver; - - /** - * Constructor - * - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance - * - * @api - */ - public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver) - { - $this->dispatcher = $dispatcher; - $this->resolver = $resolver; - } - - /** - * Handles a Request to convert it to a Response. - * - * When $catch is true, the implementation must catch all exceptions - * and do its best to convert them to a Response instance. - * - * @param Request $request A Request instance - * @param integer $type The type of the request - * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * @param Boolean $catch Whether to catch exceptions or not - * - * @return Response A Response instance - * - * @throws \Exception When an Exception occurs during processing - * - * @api - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - try { - return $this->handleRaw($request, $type); - } catch (\Exception $e) { - if (false === $catch) { - throw $e; - } - - return $this->handleException($e, $request, $type); - } - } - - /** - * {@inheritdoc} - * - * @api - */ - public function terminate(Request $request, Response $response) - { - $this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response)); - } - - /** - * Handles a request to convert it to a response. - * - * Exceptions are not caught. - * - * @param Request $request A Request instance - * @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response A Response instance - * - * @throws \LogicException If one of the listener does not behave as expected - * @throws NotFoundHttpException When controller cannot be found - */ - private function handleRaw(Request $request, $type = self::MASTER_REQUEST) - { - // request - $event = new GetResponseEvent($this, $request, $type); - $this->dispatcher->dispatch(KernelEvents::REQUEST, $event); - - if ($event->hasResponse()) { - return $this->filterResponse($event->getResponse(), $request, $type); - } - - // load controller - if (false === $controller = $this->resolver->getController($request)) { - throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". Maybe you forgot to add the matching route in your routing configuration?', $request->getPathInfo())); - } - - $event = new FilterControllerEvent($this, $controller, $request, $type); - $this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event); - $controller = $event->getController(); - - // controller arguments - $arguments = $this->resolver->getArguments($request, $controller); - - // call controller - $response = call_user_func_array($controller, $arguments); - - // view - if (!$response instanceof Response) { - $event = new GetResponseForControllerResultEvent($this, $request, $type, $response); - $this->dispatcher->dispatch(KernelEvents::VIEW, $event); - - if ($event->hasResponse()) { - $response = $event->getResponse(); - } - - if (!$response instanceof Response) { - $msg = sprintf('The controller must return a response (%s given).', $this->varToString($response)); - - // the user may have forgotten to return something - if (null === $response) { - $msg .= ' Did you forget to add a return statement somewhere in your controller?'; - } - throw new \LogicException($msg); - } - } - - return $this->filterResponse($response, $request, $type); - } - - /** - * Filters a response object. - * - * @param Response $response A Response instance - * @param Request $request A error message in case the response is not a Response object - * @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response The filtered Response instance - * - * @throws \RuntimeException if the passed object is not a Response instance - */ - private function filterResponse(Response $response, Request $request, $type) - { - $event = new FilterResponseEvent($this, $request, $type, $response); - - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - return $event->getResponse(); - } - - /** - * Handles and exception by trying to convert it to a Response. - * - * @param \Exception $e An \Exception instance - * @param Request $request A Request instance - * @param integer $type The type of the request - * - * @return Response A Response instance - */ - private function handleException(\Exception $e, $request, $type) - { - $event = new GetResponseForExceptionEvent($this, $request, $type, $e); - $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - - if (!$event->hasResponse()) { - throw $e; - } - - try { - return $this->filterResponse($event->getResponse(), $request, $type); - } catch (\Exception $e) { - return $event->getResponse(); - } - } - - private function varToString($var) - { - if (is_object($var)) { - return sprintf('Object(%s)', get_class($var)); - } - - if (is_array($var)) { - $a = array(); - foreach ($var as $k => $v) { - $a[] = sprintf('%s => %s', $k, $this->varToString($v)); - } - - return sprintf("Array(%s)", implode(', ', $a)); - } - - if (is_resource($var)) { - return sprintf('Resource(%s)', get_resource_type($var)); - } - - if (null === $var) { - return 'null'; - } - - if (false === $var) { - return 'false'; - } - - if (true === $var) { - return 'true'; - } - - return (string) $var; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpKernelInterface.php b/core/vendor/Symfony/Component/HttpKernel/HttpKernelInterface.php deleted file mode 100644 index a2a0f1c5fd597204061427644637cbd946151304..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/HttpKernelInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * HttpKernelInterface handles a Request to convert it to a Response. - * - * @author Fabien Potencier - * - * @api - */ -interface HttpKernelInterface -{ - const MASTER_REQUEST = 1; - const SUB_REQUEST = 2; - - /** - * Handles a Request to convert it to a Response. - * - * When $catch is true, the implementation must catch all exceptions - * and do its best to convert them to a Response instance. - * - * @param Request $request A Request instance - * @param integer $type The type of the request - * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * @param Boolean $catch Whether to catch exceptions or not - * - * @return Response A Response instance - * - * @throws \Exception When an Exception occurs during processing - * - * @api - */ - function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Kernel.php b/core/vendor/Symfony/Component/HttpKernel/Kernel.php deleted file mode 100644 index 7fdb5466d185a9545349edd1d400fd2bc4cca640..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Kernel.php +++ /dev/null @@ -1,766 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -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\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\Loader\IniFileLoader; -use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; -use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; -use Symfony\Component\HttpKernel\Debug\ErrorHandler; -use Symfony\Component\HttpKernel\Debug\ExceptionHandler; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\Loader\DelegatingLoader; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\ClassLoader\ClassCollectionLoader; -use Symfony\Component\ClassLoader\DebugClassLoader; - -/** - * The Kernel is the heart of the Symfony system. - * - * It manages an environment made of bundles. - * - * @author Fabien Potencier - * - * @api - */ -abstract class Kernel implements KernelInterface, TerminableInterface -{ - protected $bundles; - protected $bundleMap; - protected $container; - protected $rootDir; - protected $environment; - protected $debug; - protected $booted; - protected $name; - protected $startTime; - protected $classes; - protected $errorReportingLevel; - - const VERSION = '2.1.0-DEV'; - - /** - * Constructor. - * - * @param string $environment The environment - * @param Boolean $debug Whether to enable debugging or not - * - * @api - */ - public function __construct($environment, $debug) - { - $this->environment = $environment; - $this->debug = (Boolean) $debug; - $this->booted = false; - $this->rootDir = $this->getRootDir(); - $this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir)); - $this->classes = array(); - - if ($this->debug) { - $this->startTime = microtime(true); - } - - $this->init(); - } - - public function init() - { - if ($this->debug) { - ini_set('display_errors', 1); - error_reporting(-1); - - DebugClassLoader::enable(); - ErrorHandler::register($this->errorReportingLevel); - if ('cli' !== php_sapi_name()) { - ExceptionHandler::register(); - } - } else { - ini_set('display_errors', 0); - } - } - - public function __clone() - { - if ($this->debug) { - $this->startTime = microtime(true); - } - - $this->booted = false; - $this->container = null; - } - - /** - * Boots the current kernel. - * - * @api - */ - public function boot() - { - if (true === $this->booted) { - return; - } - - // init bundles - $this->initializeBundles(); - - // init container - $this->initializeContainer(); - - foreach ($this->getBundles() as $bundle) { - $bundle->setContainer($this->container); - $bundle->boot(); - } - - $this->booted = true; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function terminate(Request $request, Response $response) - { - if (false === $this->booted) { - return; - } - - if ($this->getHttpKernel() instanceof TerminableInterface) { - $this->getHttpKernel()->terminate($request, $response); - } - } - - /** - * Shutdowns the kernel. - * - * This method is mainly useful when doing functional testing. - * - * @api - */ - public function shutdown() - { - if (false === $this->booted) { - return; - } - - $this->booted = false; - - foreach ($this->getBundles() as $bundle) { - $bundle->shutdown(); - $bundle->setContainer(null); - } - - $this->container = null; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - if (false === $this->booted) { - $this->boot(); - } - - return $this->getHttpKernel()->handle($request, $type, $catch); - } - - /** - * Gets a http kernel from the container - * - * @return HttpKernel - */ - protected function getHttpKernel() - { - return $this->container->get('http_kernel'); - } - - /** - * Gets the registered bundle instances. - * - * @return array An array of registered bundle instances - * - * @api - */ - public function getBundles() - { - return $this->bundles; - } - - /** - * Checks if a given class name belongs to an active bundle. - * - * @param string $class A class name - * - * @return Boolean true if the class belongs to an active bundle, false otherwise - * - * @api - */ - public function isClassInActiveBundle($class) - { - foreach ($this->getBundles() as $bundle) { - if (0 === strpos($class, $bundle->getNamespace())) { - return true; - } - } - - return false; - } - - /** - * Returns a bundle and optionally its descendants by its name. - * - * @param string $name Bundle name - * @param Boolean $first Whether to return the first bundle only or together with its descendants - * - * @return BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false - * - * @throws \InvalidArgumentException when the bundle is not enabled - * - * @api - */ - public function getBundle($name, $first = true) - { - if (!isset($this->bundleMap[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your %s.php file?', $name, get_class($this))); - } - - if (true === $first) { - return $this->bundleMap[$name][0]; - } - - return $this->bundleMap[$name]; - } - - /** - * Returns the file path for a given resource. - * - * A Resource can be a file or a directory. - * - * The resource name must follow the following pattern: - * - * @/path/to/a/file.something - * - * where BundleName is the name of the bundle - * and the remaining part is the relative path in the bundle. - * - * If $dir is passed, and the first segment of the path is "Resources", - * this method will look for a file named: - * - * $dir//path/without/Resources - * - * before looking in the bundle resource folder. - * - * @param string $name A resource name to locate - * @param string $dir A directory where to look for the resource first - * @param Boolean $first Whether to return the first path or paths for all matching bundles - * - * @return string|array The absolute path of the resource or an array if $first is false - * - * @throws \InvalidArgumentException if the file cannot be found or the name is not valid - * @throws \RuntimeException if the name contains invalid/unsafe - * @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle - * - * @api - */ - public function locateResource($name, $dir = null, $first = true) - { - if ('@' !== $name[0]) { - throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); - } - - if (false !== strpos($name, '..')) { - throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); - } - - $bundleName = substr($name, 1); - $path = ''; - if (false !== strpos($bundleName, '/')) { - list($bundleName, $path) = explode('/', $bundleName, 2); - } - - $isResource = 0 === strpos($path, 'Resources') && null !== $dir; - $overridePath = substr($path, 9); - $resourceBundle = null; - $bundles = $this->getBundle($bundleName, false); - $files = array(); - - foreach ($bundles as $bundle) { - if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) { - if (null !== $resourceBundle) { - throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', - $file, - $resourceBundle, - $dir.'/'.$bundles[0]->getName().$overridePath - )); - } - - if ($first) { - return $file; - } - $files[] = $file; - } - - if (file_exists($file = $bundle->getPath().'/'.$path)) { - if ($first && !$isResource) { - return $file; - } - $files[] = $file; - $resourceBundle = $bundle->getName(); - } - } - - if (count($files) > 0) { - return $first && $isResource ? $files[0] : $files; - } - - throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name)); - } - - /** - * Gets the name of the kernel - * - * @return string The kernel name - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Gets the environment. - * - * @return string The current environment - * - * @api - */ - public function getEnvironment() - { - return $this->environment; - } - - /** - * Checks if debug mode is enabled. - * - * @return Boolean true if debug mode is enabled, false otherwise - * - * @api - */ - public function isDebug() - { - return $this->debug; - } - - /** - * Gets the application root dir. - * - * @return string The application root dir - * - * @api - */ - public function getRootDir() - { - if (null === $this->rootDir) { - $r = new \ReflectionObject($this); - $this->rootDir = dirname($r->getFileName()); - } - - return $this->rootDir; - } - - /** - * Gets the current container. - * - * @return ContainerInterface A ContainerInterface instance - * - * @api - */ - public function getContainer() - { - return $this->container; - } - - /** - * Loads the PHP class cache. - * - * @param string $name The cache name prefix - * @param string $extension File extension of the resulting file - */ - public function loadClassCache($name = 'classes', $extension = '.php') - { - if (!$this->booted && is_file($this->getCacheDir().'/classes.map')) { - ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension); - } - } - - /** - * Used internally. - */ - public function setClassCache(array $classes) - { - file_put_contents($this->getCacheDir().'/classes.map', sprintf('debug ? $this->startTime : -INF; - } - - /** - * Gets the cache directory. - * - * @return string The cache directory - * - * @api - */ - public function getCacheDir() - { - return $this->rootDir.'/cache/'.$this->environment; - } - - /** - * Gets the log directory. - * - * @return string The log directory - * - * @api - */ - public function getLogDir() - { - return $this->rootDir.'/logs'; - } - - /** - * Initializes the data structures related to the bundle management. - * - * - the bundles property maps a bundle name to the bundle instance, - * - the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first). - * - * @throws \LogicException if two bundles share a common name - * @throws \LogicException if a bundle tries to extend a non-registered bundle - * @throws \LogicException if a bundle tries to extend itself - * @throws \LogicException if two bundles extend the same ancestor - */ - protected function initializeBundles() - { - // init bundles - $this->bundles = array(); - $topMostBundles = array(); - $directChildren = array(); - - foreach ($this->registerBundles() as $bundle) { - $name = $bundle->getName(); - if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name)); - } - $this->bundles[$name] = $bundle; - - if ($parentName = $bundle->getParent()) { - if (isset($directChildren[$parentName])) { - throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName])); - } - if ($parentName == $name) { - throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name)); - } - $directChildren[$parentName] = $name; - } else { - $topMostBundles[$name] = $bundle; - } - } - - // look for orphans - if (count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) { - throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0])); - } - - // inheritance - $this->bundleMap = array(); - foreach ($topMostBundles as $name => $bundle) { - $bundleMap = array($bundle); - $hierarchy = array($name); - - while (isset($directChildren[$name])) { - $name = $directChildren[$name]; - array_unshift($bundleMap, $this->bundles[$name]); - $hierarchy[] = $name; - } - - foreach ($hierarchy as $bundle) { - $this->bundleMap[$bundle] = $bundleMap; - array_pop($bundleMap); - } - } - - } - - /** - * Gets the container class. - * - * @return string The container class - */ - protected function getContainerClass() - { - return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer'; - } - - /** - * Gets the container's base class. - * - * All names except Container must be fully qualified. - * - * @return string - */ - protected function getContainerBaseClass() - { - return 'Container'; - } - - /** - * Initializes the service container. - * - * The cached version of the service container is used when fresh, otherwise the - * container is built. - */ - protected function initializeContainer() - { - $class = $this->getContainerClass(); - $cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug); - $fresh = true; - if (!$cache->isFresh()) { - $container = $this->buildContainer(); - $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - - $fresh = false; - } - - require_once $cache; - - $this->container = new $class(); - $this->container->set('kernel', $this); - - if (!$fresh && $this->container->has('cache_warmer')) { - $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); - } - } - - /** - * Returns the kernel parameters. - * - * @return array An array of kernel parameters - */ - protected function getKernelParameters() - { - $bundles = array(); - foreach ($this->bundles as $name => $bundle) { - $bundles[$name] = get_class($bundle); - } - - return array_merge( - array( - 'kernel.root_dir' => $this->rootDir, - 'kernel.environment' => $this->environment, - 'kernel.debug' => $this->debug, - 'kernel.name' => $this->name, - 'kernel.cache_dir' => $this->getCacheDir(), - 'kernel.logs_dir' => $this->getLogDir(), - 'kernel.bundles' => $bundles, - 'kernel.charset' => 'UTF-8', - 'kernel.container_class' => $this->getContainerClass(), - ), - $this->getEnvParameters() - ); - } - - /** - * Gets the environment parameters. - * - * Only the parameters starting with "SYMFONY__" are considered. - * - * @return array An array of parameters - */ - protected function getEnvParameters() - { - $parameters = array(); - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, 'SYMFONY__')) { - $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; - } - } - - return $parameters; - } - - /** - * Builds the service container. - * - * @return ContainerBuilder The compiled service container - */ - protected function buildContainer() - { - foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) { - if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir)); - } - } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir)); - } - } - - $container = $this->getContainerBuilder(); - $extensions = array(); - foreach ($this->bundles as $bundle) { - if ($extension = $bundle->getContainerExtension()) { - $container->registerExtension($extension); - $extensions[] = $extension->getAlias(); - } - - if ($this->debug) { - $container->addObjectResource($bundle); - } - } - foreach ($this->bundles as $bundle) { - $bundle->build($container); - } - - $container->addObjectResource($this); - - // ensure these extensions are implicitly loaded - $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); - - if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { - $container->merge($cont); - } - - $container->addCompilerPass(new AddClassesToCachePass($this)); - $container->compile(); - - return $container; - } - - /** - * Gets a new ContainerBuilder instance used to build the service container. - * - * @return ContainerBuilder - */ - protected function getContainerBuilder() - { - return new ContainerBuilder(new ParameterBag($this->getKernelParameters())); - } - - /** - * Dumps the service container to PHP code in the cache. - * - * @param ConfigCache $cache The config cache - * @param ContainerBuilder $container The service container - * @param string $class The name of the class to generate - * @param string $baseClass The name of the container's base class - */ - protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass) - { - // cache the container - $dumper = new PhpDumper($container); - $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass)); - if (!$this->debug) { - $content = self::stripComments($content); - } - - $cache->write($content, $container->getResources()); - } - - /** - * Returns a loader for the container. - * - * @param ContainerInterface $container The service container - * - * @return DelegatingLoader The loader - */ - protected function getContainerLoader(ContainerInterface $container) - { - $locator = new FileLocator($this); - $resolver = new LoaderResolver(array( - new XmlFileLoader($container, $locator), - new YamlFileLoader($container, $locator), - new IniFileLoader($container, $locator), - new PhpFileLoader($container, $locator), - new ClosureLoader($container), - )); - - return new DelegatingLoader($resolver); - } - - /** - * Removes comments from a PHP source string. - * - * We don't use the PHP php_strip_whitespace() function - * as we want the content to be readable and well-formatted. - * - * @param string $source A PHP string - * - * @return string The PHP string with the comments removed - */ - static public function stripComments($source) - { - if (!function_exists('token_get_all')) { - return $source; - } - - $output = ''; - foreach (token_get_all($source) as $token) { - if (is_string($token)) { - $output .= $token; - } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { - $output .= $token[1]; - } - } - - // replace multiple new lines with a single newline - $output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output); - - return $output; - } - - public function serialize() - { - return serialize(array($this->environment, $this->debug)); - } - - public function unserialize($data) - { - list($environment, $debug) = unserialize($data); - - $this->__construct($environment, $debug); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/KernelEvents.php b/core/vendor/Symfony/Component/HttpKernel/KernelEvents.php deleted file mode 100644 index 1594d3e7a88ca69d12bb7527e24347c3e235805f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/KernelEvents.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -/** - * Contains all events thrown in the HttpKernel component - * - * @author Bernhard Schussek - * - * @api - */ -final class KernelEvents -{ - /** - * The REQUEST event occurs at the very beginning of request - * dispatching - * - * This event allows you to create a response for a request before any - * other code in the framework is executed. The event listener method - * receives a Symfony\Component\HttpKernel\Event\GetResponseEvent - * instance. - * - * @var string - * - * @api - */ - const REQUEST = 'kernel.request'; - - /** - * The EXCEPTION event occurs when an uncaught exception appears - * - * This event allows you to create a response for a thrown exception or - * to modify the thrown exception. The event listener method receives - * a Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent - * instance. - * - * @var string - * - * @api - */ - const EXCEPTION = 'kernel.exception'; - - /** - * The VIEW event occurs when the return value of a controller - * is not a Response instance - * - * This event allows you to create a response for the return value of the - * controller. The event listener method receives a - * Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent - * instance. - * - * @var string - * - * @api - */ - const VIEW = 'kernel.view'; - - /** - * The CONTROLLER event occurs once a controller was found for - * handling a request - * - * This event allows you to change the controller that will handle the - * request. The event listener method receives a - * Symfony\Component\HttpKernel\Event\FilterControllerEvent instance. - * - * @var string - * - * @api - */ - const CONTROLLER = 'kernel.controller'; - - /** - * The RESPONSE event occurs once a response was created for - * replying to a request - * - * This event allows you to modify or replace the response that will be - * replied. The event listener method receives a - * Symfony\Component\HttpKernel\Event\FilterResponseEvent instance. - * - * @var string - * - * @api - */ - const RESPONSE = 'kernel.response'; - - /** - * The TERMINATE event occurs once a reponse was sent - * - * This event allows you to run expensive post-response jobs. - * The event listener method receives a - * Symfony\Component\HttpKernel\Event\PostResponseEvent instance. - * - * @var string - */ - const TERMINATE = 'kernel.terminate'; -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/core/vendor/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php deleted file mode 100644 index 5a54d624610ebd26ac6336a3804230518f9d511b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Base Memcache storage for profiling information in a Memcache. - * - * @author Andrej Hudec - */ -abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface -{ - const TOKEN_PREFIX = 'sf_profiler_'; - - protected $dsn; - protected $lifetime; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username - * @param string $password - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method) - { - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName); - if (!$indexContent) { - return array(); - } - - $profileList = explode("\n", $indexContent); - $result = array(); - - foreach ($profileList as $item) { - - if ($limit === 0) { - break; - } - - if ($item=='') { - continue; - } - - list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = explode("\t", $item, 6); - - if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) { - continue; - } - - $result[$itemToken] = array( - 'token' => $itemToken, - 'ip' => $itemIp, - 'method' => $itemMethod, - 'url' => $itemUrl, - 'time' => $itemTime, - 'parent' => $itemParent, - ); - --$limit; - } - - usort($result, function($a, $b) { - if ($a['time'] === $b['time']) { - return 0; - } - - return $a['time'] > $b['time'] ? -1 : 1; - }); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $this->flush(); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (empty($token)) { - return false; - } - - $profile = $this->getValue($this->getItemName($token)); - - if (false !== $profile) { - $profile = $this->createProfileFromData($token, $profile); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) { - // Add to index - $indexName = $this->getIndexName(); - - $indexRow = implode("\t", array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - ))."\n"; - - return $this->appendValue($indexName, $indexRow, $this->lifetime); - } - - return false; - } - - /** - * Retrieve item from the memcache server - * - * @param string $key - * - * @return mixed - */ - abstract protected function getValue($key); - - /** - * Store an item on the memcache server under the specified key - * - * @param string $key - * @param mixed $value - * @param int $expiration - * - * @return boolean - */ - abstract protected function setValue($key, $value, $expiration = 0); - - /** - * Flush all existing items at the memcache server - * - * @return boolean - */ - abstract protected function flush(); - - /** - * Append data to an existing item on the memcache server - * @param string $key - * @param string $value - * @param int $expiration - * - * @return boolean - */ - abstract protected function appendValue($key, $value, $expiration = 0); - - private function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token) { - continue; - } - - if (!$childProfileData = $this->getValue($this->getItemName($token))) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile)); - } - - return $profile; - } - - /** - * Get item name - * - * @param string $token - * - * @return string - */ - private function getItemName($token) - { - $name = self::TOKEN_PREFIX . $token; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - /** - * Get name of index - * - * @return string - */ - private function getIndexName() - { - $name = self::TOKEN_PREFIX . 'index'; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - private function isItemNameValid($name) - { - $length = strlen($name); - - if ($length > 250) { - throw new \RuntimeException(sprintf('The memcache item key "%s" is too long (%s bytes). Allowed maximum size is 250 bytes.', $name, $length)); - } - - return true; - } - -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/core/vendor/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php deleted file mode 100644 index dfcf48705bbdba124e312e7267b3ec65f8206d65..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Memcache; - -/** - * Memcache Profiler Storage - * - * @author Andrej Hudec - */ -class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage -{ - - /** - * @var Memcache - */ - private $memcache; - - /** - * Internal convenience method that returns the instance of the Memcache - * - * @return Memcache - */ - protected function getMemcache() - { - if (null === $this->memcache) { - if (!preg_match('#^memcache://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcache with an invalid dsn "%s". The expected format is "memcache://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - $memcache = new Memcache; - $memcache->addServer($host, $port); - - $this->memcache = $memcache; - } - - return $this->memcache; - } - - /** - * {@inheritdoc} - */ - protected function getValue($key) - { - return $this->getMemcache()->get($key); - } - - /** - * {@inheritdoc} - */ - protected function setValue($key, $value, $expiration = 0) - { - return $this->getMemcache()->set($key, $value, false, time() + $expiration); - } - - /** - * {@inheritdoc} - */ - protected function flush() - { - return $this->getMemcache()->flush(); - } - - /** - * {@inheritdoc} - */ - protected function appendValue($key, $value, $expiration = 0) - { - $memcache = $this->getMemcache(); - - if (method_exists($memcache, 'append')) { - - //Memcache v3.0 - if (!$result = $memcache->append($key, $value, false, $expiration)) { - return $memcache->set($key, $value, false, $expiration); - } - - return $result; - } - - //simulate append in Memcache <3.0 - $content = $memcache->get($key); - - return $memcache->set($key, $content . $value, false, $expiration); - } - -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php b/core/vendor/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php deleted file mode 100644 index 4b45c6be8ae69ef45ee600b854cb2aa88409c221..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Memcached; - -/** - * Memcached Profiler Storage - * - * @author Andrej Hudec - */ -class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage -{ - - /** - * @var Memcached - */ - private $memcached; - - /** - * Internal convenience method that returns the instance of the Memcached - * - * @return Memcached - */ - protected function getMemcached() - { - if (null === $this->memcached) { - if (!preg_match('#^memcached://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcached with an invalid dsn "%s". The expected format is "memcached://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - $memcached = new Memcached; - - //disable compression to allow appending - $memcached->setOption(Memcached::OPT_COMPRESSION, false); - - $memcached->addServer($host, $port); - - $this->memcached = $memcached; - } - - return $this->memcached; - } - - /** - * {@inheritdoc} - */ - protected function getValue($key) - { - return $this->getMemcached()->get($key); - } - - /** - * {@inheritdoc} - */ - protected function setValue($key, $value, $expiration = 0) - { - return $this->getMemcached()->set($key, $value, time() + $expiration); - } - - /** - * {@inheritdoc} - */ - protected function flush() - { - return $this->getMemcached()->flush(); - } - - /** - * {@inheritdoc} - */ - protected function appendValue($key, $value, $expiration = 0) - { - $memcached = $this->getMemcached(); - - if (!$result = $memcached->append($key, $value)) { - return $memcached->set($key, $value, $expiration); - } - - return $result; - } - -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php b/core/vendor/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php deleted file mode 100644 index 8e2bea4a441453752605558d3cf848db989c715c..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php +++ /dev/null @@ -1,239 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - - -/** - * Base PDO storage for profiling information in a PDO database. - * - * @author Fabien Potencier - * @author Jan Schumann - */ -abstract class PdoProfilerStorage implements ProfilerStorageInterface -{ - protected $dsn; - protected $username; - protected $password; - protected $lifetime; - protected $db; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username The username for the database - * @param string $password The password for the database - * @param integer $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->username = $username; - $this->password = $password; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method) - { - list($criteria, $args) = $this->buildCriteria($ip, $url, $limit, $method); - - $criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : ''; - - $db = $this->initDb(); - $tokens = $this->fetch($db, 'SELECT token, ip, method, url, time, parent FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((integer) $limit), $args); - $this->close($db); - - return $tokens; - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - $db = $this->initDb(); - $args = array(':token' => $token); - $data = $this->fetch($db, 'SELECT data, parent, ip, method, url, time FROM sf_profiler_data WHERE token = :token LIMIT 1', $args); - $this->close($db); - if (isset($data[0]['data'])) { - return $this->createProfileFromData($token, $data[0]); - } - - return null; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $db = $this->initDb(); - $args = array( - ':token' => $profile->getToken(), - ':parent' => $profile->getParentToken(), - ':data' => base64_encode(serialize($profile->getCollectors())), - ':ip' => $profile->getIp(), - ':method' => $profile->getMethod(), - ':url' => $profile->getUrl(), - ':time' => $profile->getTime(), - ':created_at' => time(), - ); - - try { - if ($this->read($profile->getToken())) { - $this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at WHERE token = :token', $args); - } else { - $this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at)', $args); - } - $this->cleanup(); - $status = true; - } catch (\Exception $e) { - $status = false; - } - - $this->close($db); - - return $status; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $db = $this->initDb(); - $this->exec($db, 'DELETE FROM sf_profiler_data'); - $this->close($db); - } - - /** - * Build SQL criteria to fetch records by ip and url - * - * @param string $ip The IP - * @param string $url The URL - * @param string $limit The maximum number of tokens to return - * @param string $method The request method - * - * @return array An array with (criteria, args) - */ - abstract protected function buildCriteria($ip, $url, $limit, $method); - - /** - * Initializes the database - * - * @throws \RuntimeException When the requested database driver is not installed - */ - abstract protected function initDb(); - - protected function cleanup() - { - $db = $this->initDb(); - $this->exec($db, 'DELETE FROM sf_profiler_data WHERE created_at < :time', array(':time' => time() - $this->lifetime)); - $this->close($db); - } - - protected function exec($db, $query, array $args = array()) - { - $stmt = $this->prepareStatement($db, $query); - - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); - } - $success = $stmt->execute(); - if (!$success) { - throw new \RuntimeException(sprintf('Error executing query "%s"', $query)); - } - } - - protected function prepareStatement($db, $query) - { - try { - $stmt = $db->prepare($query); - } catch (\Exception $e) { - $stmt = false; - } - - if (false === $stmt) { - throw new \RuntimeException('The database cannot successfully prepare the statement'); - } - - return $stmt; - } - - protected function fetch($db, $query, array $args = array()) - { - $stmt = $this->prepareStatement($db, $query); - - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); - } - $stmt->execute(); - $return = $stmt->fetchAll(\PDO::FETCH_ASSOC); - - return $return; - } - - protected function close($db) - { - } - - protected function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors(unserialize(base64_decode($data['data']))); - - if (!$parent && !empty($data['parent'])) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - $profile->setChildren($this->readChildren($token, $profile)); - - return $profile; - } - - /** - * Reads the child profiles for the given token. - * - * @param string $token The parent token - * @param string $parent The parent instance - * - * @return array An array of Profile instance - */ - protected function readChildren($token, $parent) - { - $db = $this->initDb(); - $data = $this->fetch($db, 'SELECT token, data, ip, method, url, time FROM sf_profiler_data WHERE parent = :token', array(':token' => $token)); - $this->close($db); - - if (!$data) { - return array(); - } - - $profiles = array(); - foreach ($data as $d) { - $profiles[] = $this->createProfileFromData($d['token'], $d, $parent); - } - - return $profiles; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/core/vendor/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php deleted file mode 100644 index 67722e1c1532dc5283fe3a85edc6e1f780bc32d8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ /dev/null @@ -1,359 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Redis; - -/** - * RedisProfilerStorage stores profiling information in Redis. - * - * @author Andrej Hudec - */ -class RedisProfilerStorage implements ProfilerStorageInterface -{ - const TOKEN_PREFIX = 'sf_profiler_'; - - protected $dsn; - protected $lifetime; - - /** - * @var Redis - */ - private $redis; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username Not used - * @param string $password Not used - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method) - { - $indexName = $this->getIndexName(); - - if (!$indexContent = $this->getValue($indexName, Redis::SERIALIZER_NONE)) { - return array(); - } - - $profileList = explode("\n", $indexContent); - $result = array(); - - foreach ($profileList as $item) { - if ($limit === 0) { - break; - } - - if ($item == '') { - continue; - } - - list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = explode("\t", $item, 6); - - if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) { - continue; - } - - $result[$itemToken] = array( - 'token' => $itemToken, - 'ip' => $itemIp, - 'method' => $itemMethod, - 'url' => $itemUrl, - 'time' => $itemTime, - 'parent' => $itemParent, - ); - --$limit; - } - - usort($result, function($a, $b) { - if ($a['time'] === $b['time']) { - return 0; - } - - return $a['time'] > $b['time'] ? -1 : 1; - }); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - // delete only items from index - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName, Redis::SERIALIZER_NONE); - - if (!$indexContent) { - return false; - } - - $profileList = explode("\n", $indexContent); - - $result = array(); - - foreach ($profileList as $item) { - if ($item == '') { - continue; - } - - if (false !== $pos = strpos($item, "\t")) { - $result[] = $this->getItemName(substr($item, 0, $pos)); - } - } - - $result[] = $indexName; - - return $this->delete($result); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (empty($token)) { - return false; - } - - $profile = $this->getValue($this->getItemName($token), Redis::SERIALIZER_PHP); - - if (false !== $profile) { - $profile = $this->createProfileFromData($token, $profile); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, Redis::SERIALIZER_PHP)) { - // Add to index - $indexName = $this->getIndexName(); - - $indexRow = implode("\t", array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - ))."\n"; - - return $this->appendValue($indexName, $indexRow, $this->lifetime); - } - - return false; - } - - /** - * Internal convenience method that returns the instance of Redis. - * - * @return Redis - */ - protected function getRedis() - { - if (null === $this->redis) { - if (!preg_match('#^redis://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The expected format is "redis://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - if (!extension_loaded('redis')) { - throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.'); - } - - $redis = new Redis; - $redis->connect($host, $port); - - $redis->setOption(Redis::OPT_PREFIX, self::TOKEN_PREFIX); - - $this->redis = $redis; - } - - return $this->redis; - } - - private function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token) { - continue; - } - - if (!$childProfileData = $this->getValue($this->getItemName($token), Redis::SERIALIZER_PHP)) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile)); - } - - return $profile; - } - - /** - * Gets the item name. - * - * @param string $token - * - * @return string - */ - private function getItemName($token) - { - $name = $token; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - /** - * Gets the name of the index. - * - * @return string - */ - private function getIndexName() - { - $name = 'index'; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - private function isItemNameValid($name) - { - $length = strlen($name); - - if ($length > 2147483648) { - throw new \RuntimeException(sprintf('The Redis item key "%s" is too long (%s bytes). Allowed maximum size is 2^31 bytes.', $name, $length)); - } - - return true; - } - - /** - * Retrieves an item from the Redis server. - * - * @param string $key - * @param int $serializer - * - * @return mixed - */ - private function getValue($key, $serializer = Redis::SERIALIZER_NONE) - { - $redis = $this->getRedis(); - $redis->setOption(Redis::OPT_SERIALIZER, $serializer); - - return $redis->get($key); - } - - /** - * Stores an item on the Redis server under the specified key. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * @param int $serializer - * - * @return Boolean - */ - private function setValue($key, $value, $expiration = 0, $serializer = Redis::SERIALIZER_NONE) - { - $redis = $this->getRedis(); - $redis->setOption(Redis::OPT_SERIALIZER, $serializer); - - return $redis->setex($key, $expiration, $value); - } - - /** - * Appends data to an existing item on the Redis server. - * - * @param string $key - * @param string $value - * @param int $expiration - * - * @return Boolean - */ - private function appendValue($key, $value, $expiration = 0) - { - $redis = $this->getRedis(); - $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); - - if ($redis->exists($key)) { - $redis->append($key, $value); - - return $redis->setTimeout($key, $expiration); - } - - return $redis->setex($key, $expiration, $value); - } - - /** - * Removes the specified keys. - * - * @param array $key - * - * @return Boolean - */ - private function delete(array $keys) - { - return (bool) $this->getRedis()->delete($keys); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/README.md b/core/vendor/Symfony/Component/HttpKernel/README.md deleted file mode 100644 index 1460f0e4753239d412d41f0bc1e47dd4726f0d1f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/README.md +++ /dev/null @@ -1,101 +0,0 @@ -HttpKernel Component -==================== - -HttpKernel provides the building blocks to create flexible and fast HTTP-based -frameworks. - -``HttpKernelInterface`` is the core interface of the Symfony2 full-stack -framework: - - interface HttpKernelInterface - { - /** - * Handles a Request to convert it to a Response. - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); - } - -It takes a ``Request`` as an input and should return a ``Response`` as an -output. Using this interface makes your code compatible with all frameworks -using the Symfony2 components. And this will gives you many cool features for -free. - -Creating a framework based on the Symfony2 components is really easy. Here is -a very simple, but fully-featured framework based on the Symfony2 components: - - $routes = new RouteCollection(); - $routes->add('hello', new Route('/hello', array('_controller' => - function (Request $request) { - return new Response(sprintf("Hello %s", $request->get('name'))); - } - ))); - - $request = Request::createFromGlobals(); - - $context = new RequestContext(); - $context->fromRequest($request); - - $matcher = new UrlMatcher($routes, $context); - - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new RouterListener($matcher)); - - $resolver = new ControllerResolver(); - - $kernel = new HttpKernel($dispatcher, $resolver); - - $kernel->handle($request)->send(); - -This is all you need to create a flexible framework with the Symfony2 -components. - -Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side -Includes? - - $kernel = new HttpKernel($dispatcher, $resolver); - - $kernel = new HttpCache($kernel, new Store(__DIR__.'/cache')); - -Want to functional test this small framework? - - $client = new Client($kernel); - $crawler = $client->request('GET', '/hello/Fabien'); - - $this->assertEquals('Fabien', $crawler->filter('p > span')->text()); - -Want nice error pages instead of ugly PHP exceptions? - - $dispatcher->addSubscriber(new ExceptionListener(function (Request $request) { - $msg = 'Something went wrong! ('.$request->get('exception')->getMessage().')'; - - return new Response($msg, 500); - })); - -And that's why the simple looking ``HttpKernelInterface`` is so powerful. It -gives you access to a lot of cool features, ready to be used out of the box, -with no efforts. - -Resources ---------- - -You can run the unit tests with the following command: - - phpunit -c src/Symfony/Component/HttpKernel/ - -If you also want to run the unit tests that depend on other Symfony -Components, declare the following environment variables before running -PHPUnit: - - export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher - export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation - export SYMFONY_DEPENDENCY_INJECTION=../path/to/DependencyInjection - export SYMFONY_CONSOLE=../path/to/Console - export SYMFONY_BROWSER_KIT=../path/to/BrowserKit - export SYMFONY_FINDER=../path/to/Finder - export SYMFONY_PROCESS=../path/to/Process - export SYMFONY_ROUTING=../path/to/Routing - export SYMFONY_CONFIG=../path/to/Config diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php deleted file mode 100644 index 2b8cc79d3656d4445e29a435bea6e3cbee63fe41..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Bundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand; - -class BundleTest extends \PHPUnit_Framework_TestCase -{ - public function testRegisterCommands() - { - if (!class_exists('Symfony\Component\Console\Application')) { - $this->markTestSkipped('The "Console" component is not available'); - } - - if (!class_exists('Symfony\Component\Finder\Finder')) { - $this->markTestSkipped('The "Finder" component is not available'); - } - - $cmd = new FooCommand(); - $app = $this->getMock('Symfony\Component\Console\Application'); - $app->expects($this->once())->method('add')->with($this->equalTo($cmd)); - - $bundle = new ExtensionPresentBundle(); - $bundle->registerCommands($app); - - $bundle2 = new ExtensionAbsentBundle(); - - $this->assertNull($bundle2->registerCommands($app)); - - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php deleted file mode 100644 index f999a35ebbeac254ed645ebe1cbfd8fccde09958..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\EventListener\ExceptionListener; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Logger; - -/** - * ExceptionListenerTest - * - * @author Robert Schönthal - */ -class ExceptionListenerTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - - public function testConstruct() - { - $logger = new TestLogger(); - $l = new ExceptionListener('foo', $logger); - - $_logger = new \ReflectionProperty(get_class($l), 'logger'); - $_logger->setAccessible(true); - $_controller = new \ReflectionProperty(get_class($l), 'controller'); - $_controller->setAccessible(true); - - $this->assertSame($logger, $_logger->getValue($l)); - $this->assertSame('foo', $_controller->getValue($l)); - } - - /** - * @dataProvider provider - */ - public function testHandleWithoutLogger($event, $event2) - { - // store the current error_log, and disable it temporarily - $errorLog = ini_set('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul'); - - $l = new ExceptionListener('foo'); - $l->onKernelException($event); - - $this->assertEquals(new Response('foo'), $event->getResponse()); - - try { - $l->onKernelException($event2); - } catch(\Exception $e) { - $this->assertSame('foo', $e->getMessage()); - } - - // restore the old error_log - ini_set('error_log', $errorLog); - } - - /** - * @dataProvider provider - */ - public function testHandleWithLogger($event, $event2) - { - $logger = new TestLogger(); - - $l = new ExceptionListener('foo', $logger); - $l->onKernelException($event); - - $this->assertEquals(new Response('foo'), $event->getResponse()); - - try { - $l->onKernelException($event2); - } catch(\Exception $e) { - $this->assertSame('foo', $e->getMessage()); - } - - $this->assertEquals(3, $logger->countErrors()); - $this->assertCount(3, $logger->getLogs('crit')); - } - - public function provider() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - return array(array(null, null)); - } - - $request = new Request(); - $exception = new \Exception('foo'); - $event = new GetResponseForExceptionEvent(new TestKernel(), $request, 'foo', $exception); - $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, 'foo', $exception); - - return array( - array($event, $event2) - ); - } - -} - -class TestLogger extends Logger implements DebugLoggerInterface -{ - public function countErrors() - { - return count($this->logs['crit']); - } -} - -class TestKernel implements HttpKernelInterface -{ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - return new Response('foo'); - } -} - -class TestKernelThatThrowsException implements HttpKernelInterface -{ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - throw new \Exception('bar'); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php deleted file mode 100644 index c33b33dc560188e0ffd1c8b1845fa5621ed9b323..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\EventListener\RouterListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\Routing\RequestContext; - -class RouterListenerTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\Routing\Router')) { - $this->markTestSkipped('The "Routing" component is not available'); - } - } - - /** - * @dataProvider getPortData - */ - public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort) - { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface') - ->disableOriginalConstructor() - ->getMock(); - $context = new RequestContext(); - $context->setHttpPort($defaultHttpPort); - $context->setHttpsPort($defaultHttpsPort); - $urlMatcher->expects($this->any()) - ->method('getContext') - ->will($this->returnValue($context)); - - $listener = new RouterListener($urlMatcher); - $event = $this->createGetResponseEventForUri($uri); - $listener->onKernelRequest($event); - - $this->assertEquals($expectedHttpPort, $context->getHttpPort()); - $this->assertEquals($expectedHttpsPort, $context->getHttpsPort()); - $this->assertEquals(0 === strpos($uri, 'https') ? 'https' : 'http', $context->getScheme()); - } - - public function getPortData() - { - return array( - array(80, 443, 'http://localhost/', 80, 443), - array(80, 443, 'http://localhost:90/', 90, 443), - array(80, 443, 'https://localhost/', 80, 443), - array(80, 443, 'https://localhost:90/', 80, 90), - ); - } - - /** - * @param string $uri - * - * @return GetResponseEvent - */ - private function createGetResponseEventForUri($uri) - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $request = Request::create($uri); - $request->attributes->set('_controller', null); // Prevents going in to routing process - - return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php b/core/vendor/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php deleted file mode 100644 index ddab206a3bf2cb0f2642b2fe54ab64be5c1639a8..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Client; - -class TestClient extends Client -{ - protected function getScript($request) - { - $script = parent::getScript($request); - - $script = preg_replace('/(\->register\(\);)/', "$0\nrequire_once '".__DIR__."/../TestHttpKernel.php';", $script); - - return $script; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php deleted file mode 100644 index 2ac581df39c93221410381133196c57cf9bc9df4..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ /dev/null @@ -1,1052 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpKernel\HttpCache\StoreInterface; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class HttpCacheTest extends HttpCacheTestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - - $storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface') - ->disableOriginalConstructor() - ->getMock(); - - // does not implement TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface') - ->disableOriginalConstructor() - ->getMock(); - - $kernelMock->expects($this->never()) - ->method('terminate'); - - $kernel = new HttpCache($kernelMock, $storeMock); - $kernel->terminate(Request::create('/'), new Response()); - - // implements TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel') - ->disableOriginalConstructor() - ->setMethods(array('terminate', 'registerBundles', 'registerContainerConfiguration')) - ->getMock(); - - $kernelMock->expects($this->once()) - ->method('terminate'); - - $kernel = new HttpCache($kernelMock, $storeMock); - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testPassesOnNonGetHeadRequests() - { - $this->setNextResponse(200); - $this->request('POST', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('pass'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testInvalidatesOnPostPutDeleteRequests() - { - foreach (array('post', 'put', 'delete') as $method) { - $this->setNextResponse(200); - $this->request($method, '/'); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('invalidate'); - $this->assertTraceContains('pass'); - } - } - - public function testDoesNotCacheWithAuthorizationRequestHeaderAndNonPublicResponse() - { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesCacheWithAuthorizationRequestHeaderAndPublicResponse() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - $this->assertEquals('public', $this->response->headers->get('Cache-Control')); - } - - public function testDoesNotCacheWithCookieHeaderAndNonPublicResponse() - { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array(), array('foo' => 'bar')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesNotCacheRequestsWithACookieHeader() - { - $this->setNextResponse(200); - $this->request('GET', '/', array(), array('foo' => 'bar')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() - { - $time = new \DateTime(); - - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822), 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('text/html; charset=UTF-8', $this->response->headers->get('Content-Type')); - $this->assertEmpty($this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testRespondsWith304WhenIfNoneMatchMatchesETag() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '12345', 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345')); - - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('text/html; charset=UTF-8', $this->response->headers->get('Content-Type')); - $this->assertTrue($this->response->headers->has('ETag')); - $this->assertEmpty($this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch() - { - $time = new \DateTime(); - - $this->setNextResponse(200, array(), '', function ($request, $response) use ($time) - { - $response->setStatusCode(200); - $response->headers->set('ETag', '12345'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('Hello World'); - }); - - // only ETag matches - $t = \DateTime::createFromFormat('U', time() - 3600); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - - // only Last-Modified matches - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - - // Both matches - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - } - - public function testValidatesPrivateResponsesCachedOnTheClient() - { - $this->setNextResponse(200, array(), '', function ($request, $response) - { - $etags = preg_split('/\s*,\s*/', $request->headers->get('IF_NONE_MATCH')); - if ($request->cookies->has('authenticated')) { - $response->headers->set('Cache-Control', 'private, no-store'); - $response->setETag('"private tag"'); - if (in_array('"private tag"', $etags)) { - $response->setStatusCode(304); - } else { - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('private data'); - } - } else { - $response->headers->set('Cache-Control', 'public'); - $response->setETag('"public tag"'); - if (in_array('"public tag"', $etags)) { - $response->setStatusCode(304); - } else { - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('public data'); - } - } - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('"public tag"', $this->response->headers->get('ETag')); - $this->assertEquals('public data', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $this->request('GET', '/', array(), array('authenticated' => '')); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('"private tag"', $this->response->headers->get('ETag')); - $this->assertEquals('private data', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceNotContains('store'); - } - - public function testStoresResponsesWhenNoCacheRequestDirectivePresent() - { - $time = \DateTime::createFromFormat('U', time() + 5); - - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testReloadsResponsesWhenCacheHitsButNoCacheRequestDirectivePresentWhenAllowReloadIsSetTrue() - { - $count = 0; - - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) - { - ++$count; - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Goodbye World', $this->response->getContent()); - $this->assertTraceContains('reload'); - $this->assertTraceContains('store'); - } - - public function testDoesNotReloadResponsesWhenAllowReloadIsSetFalseDefault() - { - $count = 0; - - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) - { - ++$count; - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_reload'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('reload'); - - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('reload'); - } - - public function testRevalidatesFreshCacheEntryWhenMaxAgeRequestDirectiveIsExceededWhenAllowRevalidateOptionIsSetTrue() - { - $count = 0; - - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) - { - ++$count; - $response->headers->set('Cache-Control', 'public, max-age=10000'); - $response->setETag($count); - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_revalidate'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Goodbye World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - } - - public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIsSetFalseDefault() - { - $count = 0; - - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) - { - ++$count; - $response->headers->set('Cache-Control', 'public, max-age=10000'); - $response->setETag($count); - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_revalidate'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('stale'); - $this->assertTraceNotContains('invalid'); - $this->assertTraceContains('fresh'); - - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('stale'); - $this->assertTraceNotContains('invalid'); - $this->assertTraceContains('fresh'); - } - - public function testFetchesResponseFromBackendWhenCacheMisses() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testDoesNotCacheSomeStatusCodeResponses() - { - foreach (array_merge(range(201, 202), range(204, 206), range(303, 305), range(400, 403), range(405, 409), range(411, 417), range(500, 505)) as $code) { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse($code, array('Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals($code, $this->response->getStatusCode()); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - } - - public function testDoesNotCacheResponsesWithExplicitNoStoreDirective() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'no-store')); - - $this->request('GET', '/'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesNotCacheResponsesWithoutFreshnessInformationOrAValidator() - { - $this->setNextResponse(); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceNotContains('store'); - } - - public function testCachesResponsesWithExplicitNoCacheDirective() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, no-cache')); - - $this->request('GET', '/'); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testCachesResponsesWithAnExpirationHeader() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithAMaxAgeDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=5')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithASMaxAgeDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 's-maxage=5')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInformation() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testCachesResponsesWithAnETagValidatorButNoFreshnessInformation() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"123456"')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testHitsCachedResponsesWithExpiresHeader() - { - $time1 = \DateTime::createFromFormat('U', time() - 5); - $time2 = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Date' => $time1->format(DATE_RFC2822), 'Expires' => $time2->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2); - $this->assertTrue($this->response->headers->get('Age') > 0); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testHitsCachedResponseWithMaxAgeDirective() - { - $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, max-age=10')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2); - $this->assertTrue($this->response->headers->get('Age') > 0); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testHitsCachedResponseWithSMaxAgeDirective() - { - $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2); - $this->assertTrue($this->response->headers->get('Age') > 0); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 'must-revalidate')); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertNotRegExp('/s-maxage/', $this->response->headers->get('Cache-Control')); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertNotNull($this->response->headers->get('Age')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - # go in and play around with the cached metadata directly ... - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time()); - $tmp[0][1]['expires'] = $time->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.sha1('http://localhost/'), serialize($tmp)); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue($this->response->headers->get('Age') <= 1); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('stale'); - $this->assertTraceNotContains('fresh'); - $this->assertTraceNotContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInformation() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) - { - $response->headers->set('Cache-Control', 'public'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - if ($time->format(DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { - $response->setStatusCode(304); - $response->setContent(''); - } - }); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Last-Modified')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('stale'); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Last-Modified')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTrue($this->response->headers->get('Age') <= 1); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - } - - public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) - { - $response->headers->set('Cache-Control', 'public'); - $response->headers->set('ETag', '"12345"'); - if ($response->getETag() == $request->headers->get('IF_NONE_MATCH')) { - $response->setStatusCode(304); - $response->setContent(''); - } - }); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('ETag')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('ETag')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTrue($this->response->headers->get('Age') <= 1); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - } - - public function testReplacesCachedResponsesWhenValidationResultsInNon304Response() - { - $time = \DateTime::createFromFormat('U', time()); - $count = 0; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count) - { - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - $response->headers->set('Cache-Control', 'public'); - switch (++$count) { - case 1: - $response->setContent('first response'); - break; - case 2: - $response->setContent('second response'); - break; - case 3: - $response->setContent(''); - $response->setStatusCode(304); - break; - } - }); - - // first request should fetch from backend and store in cache - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('first response', $this->response->getContent()); - - // second request is validated, is invalid, and replaces cached entry - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('second response', $this->response->getContent()); - - // third response is validated, valid, and returns cached entry - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('second response', $this->response->getContent()); - - $this->assertEquals(3, $count); - } - - public function testPassesHeadRequestsThroughDirectlyOnPass() - { - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) - { - $response->setContent(''); - $response->setStatusCode(200); - $that->assertEquals('HEAD', $request->getMethod()); - }); - - $this->request('HEAD', '/', array('HTTP_EXPECT' => 'something ...')); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('', $this->response->getContent()); - } - - public function testUsesCacheToRespondToHeadRequestsWhenFresh() - { - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) - { - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->setContent('Hello World'); - $response->setStatusCode(200); - $that->assertNotEquals('HEAD', $request->getMethod()); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('HEAD', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->getContent()); - $this->assertEquals(strlen('Hello World'), $this->response->headers->get('Content-Length')); - } - - public function testSendsNoContentWhenFresh() - { - $time = \DateTime::createFromFormat('U', time()); - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) - { - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/', array('HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->getContent()); - } - - public function testInvalidatesCachedResponsesOnPost() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) - { - if ('GET' == $request->getMethod()) { - $response->setStatusCode(200); - $response->headers->set('Cache-Control', 'public, max-age=500'); - $response->setContent('Hello World'); - } elseif ('POST' == $request->getMethod()) { - $response->setStatusCode(303); - $response->headers->set('Location', '/'); - $response->headers->remove('Cache-Control'); - $response->setContent(''); - } - }); - - // build initial request to enter into the cache - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - // make sure it is valid - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - // now POST to same URL - $this->request('POST', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('/', $this->response->headers->get('Location')); - $this->assertTraceContains('invalidate'); - $this->assertTraceContains('pass'); - $this->assertEquals('', $this->response->getContent()); - - // now make sure it was actually invalidated - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - } - - public function testServesFromCacheWhenHeadersMatch() - { - $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) - { - $response->headers->set('Vary', 'Accept User-Agent Foo'); - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('X-Response-Count', ++$count); - $response->setContent($request->headers->get('USER_AGENT')); - }); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - } - - public function testStoresMultipleResponsesWhenHeadersDiffer() - { - $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) - { - $response->headers->set('Vary', 'Accept User-Agent Foo'); - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('X-Response-Count', ++$count); - $response->setContent($request->headers->get('USER_AGENT')); - }); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertTraceContains('fresh'); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertTraceContains('fresh'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertTraceContains('miss'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(3, $this->response->headers->get('X-Response-Count')); - } - - public function testShouldCatchExceptions() - { - $this->catchExceptions(); - - $this->setNextResponse(); - $this->request('GET', '/'); - - $this->assertExceptionsAreCaught(); - } - - public function testShouldNotCatchExceptions() - { - $this->catchExceptions(false); - - $this->setNextResponse(); - $this->request('GET', '/'); - - $this->assertExceptionsAreNotCaught(); - } - - public function testEsiCacheSendsTheLowestTtl() - { - $responses = array( - array( - 'status' => 200, - 'body' => ' ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array('Cache-Control' => 's-maxage=300'), - ), - array( - 'status' => 200, - 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals("Hello World! My name is Bobby.", $this->response->getContent()); - - // check for 100 or 99 as the test can be executed after a second change - $this->assertTrue(in_array($this->response->getTtl(), array(99, 100))); - } - - public function testEsiCacheForceValidation() - { - $responses = array( - array( - 'status' => 200, - 'body' => ' ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array('ETag' => 'foobar'), - ), - array( - 'status' => 200, - 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); - $this->assertNull($this->response->getTtl()); - $this->assertTrue($this->response->mustRevalidate()); - $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); - $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); - } - - public function testEsiRecalculateContentLengthHeader() - { - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Content-Length' => 26, - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World!', $this->response->getContent()); - $this->assertEquals(12, $this->response->headers->get('Content-Length')); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php b/core/vendor/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php deleted file mode 100644 index 6bbcdfba48e45e4e0023e883096f5c2532d12606..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpKernel\HttpCache\Store; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class HttpCacheTestCase extends \PHPUnit_Framework_TestCase -{ - protected $kernel; - protected $cache; - protected $caches; - protected $cacheConfig; - protected $request; - protected $response; - protected $responses; - protected $catch; - protected $esi; - - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - - $this->kernel = null; - - $this->cache = null; - $this->esi = null; - $this->caches = array(); - $this->cacheConfig = array(); - - $this->request = null; - $this->response = null; - $this->responses = array(); - - $this->catch = false; - - $this->clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - protected function tearDown() - { - $this->kernel = null; - $this->cache = null; - $this->caches = null; - $this->request = null; - $this->response = null; - $this->responses = null; - $this->cacheConfig = null; - $this->catch = null; - $this->esi = null; - - $this->clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - public function assertHttpKernelIsCalled() - { - $this->assertTrue($this->kernel->hasBeenCalled()); - } - - public function assertHttpKernelIsNotCalled() - { - $this->assertFalse($this->kernel->hasBeenCalled()); - } - - public function assertResponseOk() - { - $this->assertEquals(200, $this->response->getStatusCode()); - } - - public function assertTraceContains($trace) - { - $traces = $this->cache->getTraces(); - $traces = current($traces); - - $this->assertRegExp('/'.$trace.'/', implode(', ', $traces)); - } - - public function assertTraceNotContains($trace) - { - $traces = $this->cache->getTraces(); - $traces = current($traces); - - $this->assertNotRegExp('/'.$trace.'/', implode(', ', $traces)); - } - - public function assertExceptionsAreCaught() - { - $this->assertTrue($this->kernel->isCatchingExceptions()); - } - - public function assertExceptionsAreNotCaught() - { - $this->assertFalse($this->kernel->isCatchingExceptions()); - } - - public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false) - { - if (null === $this->kernel) { - throw new \LogicException('You must call setNextResponse() before calling request().'); - } - - $this->kernel->reset(); - - $this->store = new Store(sys_get_temp_dir().'/http_cache'); - - $this->cacheConfig['debug'] = true; - - $this->esi = $esi ? new Esi() : null; - $this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig); - $this->request = Request::create($uri, $method, array(), $cookies, array(), $server); - - $this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch); - - $this->responses[] = $this->response; - } - - public function getMetaStorageValues() - { - $values = array(); - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(sys_get_temp_dir().'/http_cache/md', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - $values[] = file_get_contents($file); - } - - return $values; - } - - // A basic response with 200 status code and a tiny body. - public function setNextResponse($statusCode = 200, array $headers = array(), $body = 'Hello World', \Closure $customizer = null) - { - $this->kernel = new TestHttpKernel($body, $statusCode, $headers, $customizer); - } - - public function setNextResponses($responses) - { - $this->kernel = new TestMultipleHttpKernel($responses); - } - - public function catchExceptions($catch = true) - { - $this->catch = $catch; - } - - static public function clearDirectory($directory) - { - if (!is_dir($directory)) { - return; - } - - $fp = opendir($directory); - while (false !== $file = readdir($fp)) { - if (!in_array($file, array('.', '..'))) - { - if (is_link($directory.'/'.$file)) { - unlink($directory.'/'.$file); - } elseif (is_dir($directory.'/'.$file)) { - self::clearDirectory($directory.'/'.$file); - rmdir($directory.'/'.$file); - } else { - unlink($directory.'/'.$file); - } - } - } - - closedir($fp); - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php deleted file mode 100644 index 8a184b462df8c08bdfacba6434118fe459c1bd24..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ /dev/null @@ -1,241 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class HttpKernelTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - - /** - * @expectedException RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue() - { - $kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); })); - - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - } - - /** - * @expectedException RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered() - { - $kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); })); - - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); - } - - public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) - { - $event->setResponse(new Response($event->getException()->getMessage())); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException('foo'); })); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testHandleWhenAListenerReturnsAResponse() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::REQUEST, function ($event) - { - $event->setResponse(new Response('hello')); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver()); - - $this->assertEquals('hello', $kernel->handle(new Request())->getContent()); - } - - /** - * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ - public function testHandleWhenNoControllerIsFound() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(false)); - - $kernel->handle(new Request()); - } - - /** - * @expectedException LogicException - */ - public function testHandleWhenTheControllerIsNotACallable() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver('foobar')); - - $kernel->handle(new Request()); - } - - public function testHandleWhenTheControllerIsAClosure() - { - $response = new Response('foo'); - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () use ($response) { return $response; })); - - $this->assertSame($response, $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAnObjectWithInvoke() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(new Controller())); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAFunction() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver('Symfony\Component\HttpKernel\Tests\controller_func')); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAnArray() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(array(new Controller(), 'controller'))); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAStaticArray() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(array('Symfony\Component\HttpKernel\Tests\Controller', 'staticcontroller'))); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - /** - * @expectedException LogicException - */ - public function testHandleWhenTheControllerDoesNotReturnAResponse() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; })); - - $kernel->handle(new Request()); - } - - public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::VIEW, function ($event) - { - $event->setResponse(new Response($event->getControllerResult())); - }); - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; })); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testHandleWithAResponseListener() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::RESPONSE, function ($event) - { - $event->setResponse(new Response('foo')); - }); - $kernel = new HttpKernel($dispatcher, $this->getResolver()); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testTerminate() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver()); - $dispatcher->addListener(KernelEvents::TERMINATE, function ($event) use (&$called, &$capturedKernel, &$capturedRequest, &$capturedResponse) { - $called = true; - $capturedKernel = $event->getKernel(); - $capturedRequest = $event->getRequest(); - $capturedResponse = $event->getResponse(); - }); - - $kernel->terminate($request = Request::create('/'), $response = new Response()); - $this->assertTrue($called); - $this->assertEquals($kernel, $capturedKernel); - $this->assertEquals($request, $capturedRequest); - $this->assertEquals($response, $capturedResponse); - } - - protected function getResolver($controller = null) - { - if (null === $controller) { - $controller = function() { return new Response('Hello'); }; - } - - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $resolver->expects($this->any()) - ->method('getController') - ->will($this->returnValue($controller)); - $resolver->expects($this->any()) - ->method('getArguments') - ->will($this->returnValue(array())); - - return $resolver; - } - - protected function assertResponseEquals(Response $expected, Response $actual) - { - $expected->setDate($actual->getDate()); - $this->assertEquals($expected, $actual); - } -} - -class Controller -{ - public function __invoke() - { - return new Response('foo'); - } - - public function controller() - { - return new Response('foo'); - } - - static public function staticController() - { - return new Response('foo'); - } -} - -function controller_func() -{ - return new Response('foo'); -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/KernelTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/KernelTest.php deleted file mode 100644 index a26d9d7fc1dfad16b844fae53073d93830bac5db..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ /dev/null @@ -1,782 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; -use Symfony\Component\HttpKernel\Tests\Fixtures\FooBarBundle; - -class KernelTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - } - - public function testConstructor() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $this->assertEquals($env, $kernel->getEnvironment()); - $this->assertEquals($debug, $kernel->isDebug()); - $this->assertFalse($kernel->isBooted()); - $this->assertLessThanOrEqual(microtime(true), $kernel->getStartTime()); - $this->assertNull($kernel->getContainer()); - } - - public function testClone() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $clone = clone $kernel; - - $this->assertEquals($env, $clone->getEnvironment()); - $this->assertEquals($debug, $clone->isDebug()); - $this->assertFalse($clone->isBooted()); - $this->assertLessThanOrEqual(microtime(true), $clone->getStartTime()); - $this->assertNull($clone->getContainer()); - } - - public function testBootInitializesBundlesAndContainer() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('initializeBundles'); - $kernel->expects($this->once()) - ->method('initializeContainer'); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); - - $kernel->boot(); - } - - public function testBootSetsTheContainerToTheBundles() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); - $bundle->expects($this->once()) - ->method('setContainer'); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->boot(); - } - - public function testBootSetsTheBootedFlagToTrue() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); - - $kernel->boot(); - - $this->assertTrue($kernel->isBooted()); - } - - public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); - - $kernel->boot(); - $kernel->boot(); - } - - public function testShutdownCallsShutdownOnAllBundles() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); - $bundle->expects($this->once()) - ->method('shutdown'); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->shutdown(); - } - - public function testShutdownGivesNullContainerToAllBundles() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); - $bundle->expects($this->once()) - ->method('setContainer') - ->with(null); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->shutdown(); - } - - public function testHandleCallsHandleOnHttpKernel() - { - $type = HttpKernelInterface::MASTER_REQUEST; - $catch = true; - $request = new Request(); - - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->getMock(); - $httpKernelMock - ->expects($this->once()) - ->method('handle') - ->with($request, $type, $catch); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->handle($request, $type, $catch); - } - - public function testHandleBootsTheKernel() - { - $type = HttpKernelInterface::MASTER_REQUEST; - $catch = true; - $request = new Request(); - - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->getMock(); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel', 'boot')) - ->getMock(); - - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->expects($this->once()) - ->method('boot'); - - // required as this value is initialized - // in the kernel constructor, which we don't call - $kernel->setIsBooted(false); - - $kernel->handle($request, $type, $catch); - } - - public function testStripComments() - { - if (!function_exists('token_get_all')) { - $this->markTestSkipped('The function token_get_all() is not available.'); - - return; - } - $source = <<assertEquals($expected, Kernel::stripComments($source)); - } - - public function testIsClassInActiveBundleFalse() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle')); - } - - public function testIsClassInActiveBundleFalseNoNamespace() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass')); - } - - public function testIsClassInActiveBundleTrue() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertTrue($kernel->isClassInActiveBundle(__NAMESPACE__.'\Fixtures\FooBarBundle\SomeClass')); - } - - protected function getKernelMockForIsClassInActiveBundleTest() - { - $bundle = new FooBarBundle(); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - return $kernel; - } - - public function testGetRootDir() - { - $kernel = new KernelForTest('test', true); - - $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures', $kernel->getRootDir()); - } - - public function testGetName() - { - $kernel = new KernelForTest('test', true); - - $this->assertEquals('Fixtures', $kernel->getName()); - } - - public function testSerialize() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $expected = serialize(array($env, $debug)); - $this->assertEquals($expected, $kernel->serialize()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenNameIsNotValid() - { - $this->getKernelForInvalidLocateResource()->locateResource('Foo'); - } - - /** - * @expectedException \RuntimeException - */ - public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() - { - $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/../bar'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() - { - $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/config/routing.xml'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $kernel->locateResource('@Bundle1Bundle/config/routing.xml'); - } - - public function testLocateResourceReturnsTheFirstThatMatches() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt')); - } - - public function testLocateResourceReturnsTheFirstThatMatchesWithParent() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt')); - $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/bar.txt', $kernel->locateResource('@ParentAABundle/bar.txt')); - } - - public function testLocateResourceReturnsAllMatches() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Bundle2Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), - $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)); - } - - public function testLocateResourceReturnsAllMatchesBis() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array( - $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), - $this->getBundle(__DIR__.'/Foobar') - ))) - ; - - $this->assertEquals( - array(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), - $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false) - ); - } - - public function testLocateResourceIgnoresDirOnNonResource() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', - $kernel->locateResource('@Bundle1Bundle/foo.txt', __DIR__.'/Fixtures') - ); - } - - public function testLocateResourceReturnsTheDirOneForResources() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle/foo.txt', - $kernel->locateResource('@FooBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources') - ); - } - - public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt'), - $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) - ); - } - - public function testLocateResourceOverrideBundleAndResourcesFolders() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->exactly(4)) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', - __DIR__.'/Fixtures/ChildBundle/Resources/foo.txt', - __DIR__.'/Fixtures/BaseBundle/Resources/foo.txt', - ), - $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) - ); - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', - $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources') - ); - - try { - $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', false); - $this->fail('Hidden resources should raise an exception when returning an array of matching paths'); - } catch (\RuntimeException $e) { - } - - try { - $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', true); - $this->fail('Hidden resources should raise an exception when returning the first matching path'); - } catch (\RuntimeException $e) { - } - } - - public function testLocateResourceOnDirectories() - { - $kernel = $this->getKernel(); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle/', - $kernel->locateResource('@FooBundle/Resources/', __DIR__.'/Fixtures/Resources') - ); - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle', - $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources') - ); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/Resources/', - $kernel->locateResource('@Bundle1Bundle/Resources/') - ); - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/Resources', - $kernel->locateResource('@Bundle1Bundle/Resources') - ); - } - - public function testInitializeBundles() - { - $parent = $this->getBundle(null, null, 'ParentABundle'); - $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $child))) - ; - $kernel->initializeBundles(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent), $map['ParentABundle']); - } - - public function testInitializeBundlesSupportInheritanceCascade() - { - $grandparent = $this->getBundle(null, null, 'GrandParentBBundle'); - $parent = $this->getBundle(null, 'GrandParentBBundle', 'ParentBBundle'); - $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($grandparent, $parent, $child))) - ; - - $kernel->initializeBundles(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']); - $this->assertEquals(array($child, $parent), $map['ParentBBundle']); - $this->assertEquals(array($child), $map['ChildBBundle']); - } - - /** - * @expectedException \LogicException - */ - public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists() - { - $child = $this->getBundle(null, 'FooBar', 'ChildCBundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($child))) - ; - $kernel->initializeBundles(); - } - - public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() - { - $grandparent = $this->getBundle(null, null, 'GrandParentCCundle'); - $parent = $this->getBundle(null, 'GrandParentCCundle', 'ParentCCundle'); - $child = $this->getBundle(null, 'ParentCCundle', 'ChildCCundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $grandparent, $child))) - ; - - $kernel->initializeBundles(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCCundle']); - $this->assertEquals(array($child, $parent), $map['ParentCCundle']); - $this->assertEquals(array($child), $map['ChildCCundle']); - } - - /** - * @expectedException \LogicException - */ - public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtendedByTwoBundles() - { - $parent = $this->getBundle(null, null, 'ParentCBundle'); - $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle'); - $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $child1, $child2))) - ; - $kernel->initializeBundles(); - } - - /** - * @expectedException \LogicException - */ - public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() - { - $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); - $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($fooBundle, $barBundle))) - ; - $kernel->initializeBundles(); - } - - /** - * @expectedException \LogicException - */ - public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself() - { - $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($circularRef))) - ; - $kernel->initializeBundles(); - } - - public function testTerminateReturnsSilentlyIfKernelIsNotBooted() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - - $kernel->expects($this->never()) - ->method('getHttpKernel'); - - $kernel->setIsBooted(false); - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() - { - // does not implement TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface') - ->disableOriginalConstructor() - ->getMock(); - - $httpKernelMock - ->expects($this->never()) - ->method('terminate'); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->setIsBooted(true); - $kernel->terminate(Request::create('/'), new Response()); - - // implements TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->setMethods(array('terminate')) - ->getMock(); - - $httpKernelMock - ->expects($this->once()) - ->method('terminate'); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - - $kernel->expects($this->exactly(2)) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->setIsBooted(true); - $kernel->terminate(Request::create('/'), new Response()); - } - - protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) - { - $bundle = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\BundleForTest') - ->setMethods(array('getPath', 'getParent', 'getName')) - ->disableOriginalConstructor() - ; - - if ($className) { - $bundle->setMockClassName($className); - } - - $bundle = $bundle->getMockForAbstractClass(); - - $bundle - ->expects($this->any()) - ->method('getName') - ->will($this->returnValue(null === $bundleName ? get_class($bundle) : $bundleName)) - ; - - $bundle - ->expects($this->any()) - ->method('getPath') - ->will($this->returnValue($dir)) - ; - - $bundle - ->expects($this->any()) - ->method('getParent') - ->will($this->returnValue($parent)) - ; - - return $bundle; - } - - protected function getKernel() - { - return $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setMethods(array('getBundle', 'registerBundles')) - ->disableOriginalConstructor() - ->getMock() - ; - } - - protected function getKernelForInvalidLocateResource() - { - return $this - ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') - ->disableOriginalConstructor() - ->getMockForAbstractClass() - ; - } -} - -abstract class BundleForTest implements BundleInterface -{ - // We can not extend Symfony\Component\HttpKernel\Bundle\Bundle as we want to mock getName() which is final -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php deleted file mode 100644 index fb55026a9ad7a52f778c3427207b6356367db800..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage; - -class DummyMemcacheProfilerStorage extends MemcacheProfilerStorage -{ - public function getMemcache() - { - return parent::getMemcache(); - } -} - -/** - * @group memcached - */ -class MemcacheProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - public static function tearDownAfterClass() - { - if (self::$storage) { - self::$storage->purge(); - } - } - - protected function setUp() - { - if (!extension_loaded('memcache')) { - $this->markTestSkipped('MemcacheProfilerStorageTest requires that the extension memcache is loaded'); - } - - self::$storage = new DummyMemcacheProfilerStorage('memcache://127.0.0.1:11211', '', '', 86400); - try { - self::$storage->getMemcache(); - $stats = self::$storage->getMemcache()->getExtendedStats(); - if (!isset($stats['127.0.0.1:11211']) || $stats['127.0.0.1:11211'] === false) { - throw new \Exception(); - } - } catch (\Exception $e) { - $this->markTestSkipped('MemcacheProfilerStorageTest requires that there is a Memcache server present on localhost'); - } - - if (self::$storage) { - self::$storage->purge(); - } - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php deleted file mode 100644 index 5f2f5c352275469cc63b3a3c9f1a030ec721dc0c..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage; - -class DummyMemcachedProfilerStorage extends MemcachedProfilerStorage -{ - public function getMemcached() - { - return parent::getMemcached(); - } -} - -/** - * @group memcached - */ -class MemcachedProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - public static function tearDownAfterClass() - { - if (self::$storage) { - self::$storage->purge(); - } - } - - protected function setUp() - { - if (!extension_loaded('memcached')) { - $this->markTestSkipped('MemcachedProfilerStorageTest requires that the extension memcached is loaded'); - } - - self::$storage = new DummyMemcachedProfilerStorage('memcached://127.0.0.1:11211', '', '', 86400); - try { - self::$storage->getMemcached(); - } catch (\Exception $e) { - $this->markTestSkipped('MemcachedProfilerStorageTest requires that there is a Memcache server present on localhost'); - } - - if (self::$storage) { - self::$storage->purge(); - } - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php deleted file mode 100644 index 310320cd656842c7769b9eadcb36854a0791a52a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage; -use Symfony\Component\HttpKernel\Profiler\Profile; - -class DummyMongoDbProfilerStorage extends MongoDbProfilerStorage -{ - public function getMongo() - { - return parent::getMongo(); - } -} - -class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - static public function setUpBeforeClass() - { - if (extension_loaded('mongo')) { - self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400); - try { - self::$storage->getMongo(); - } catch (\MongoConnectionException $e) { - self::$storage = null; - } - } - } - - static public function tearDownAfterClass() - { - if (self::$storage) { - self::$storage->purge(); - self::$storage = null; - } - } - - public function testCleanup() - { - $dt = new \DateTime('-2 day'); - for ($i = 0; $i < 3; $i++) { - $dt->modify('-1 day'); - $profile = new Profile('time_'.$i); - $profile->setTime($dt->getTimestamp()); - $profile->setMethod('GET'); - self::$storage->write($profile); - } - $records = self::$storage->find('', '', 3, 'GET'); - $this->assertCount(1, $records, '->find() returns only one record'); - $this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record'); - self::$storage->purge(); - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } - - protected function setUp() - { - if (self::$storage) { - self::$storage->purge(); - } else { - $this->markTestSkipped('MongoDbProfilerStorageTest requires then mongo PHP extennsion and a MongoDB server on localhost'); - } - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php b/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php deleted file mode 100644 index 88779bc718102ca69aab7a8261df3573bf2f3e9d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage; - -class DummyRedisProfilerStorage extends RedisProfilerStorage -{ - public function getRedis() - { - return parent::getRedis(); - } -} - -class RedisProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - protected function setUp() - { - if (!extension_loaded('redis')) { - $this->markTestSkipped('RedisProfilerStorageTest requires redis extension to be loaded'); - } - - self::$storage = new DummyRedisProfilerStorage('redis://127.0.0.1:6379', '', '', 86400); - try { - self::$storage->getRedis(); - - self::$storage->purge(); - - } catch (\Exception $e) { - self::$storage = false; - $this->markTestSkipped('RedisProfilerStorageTest requires that there is a Redis server present on localhost'); - } - } - - protected function tearDown() - { - if (self::$storage) { - self::$storage->purge(); - self::$storage->getRedis()->close(); - self::$storage = false; - } - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Tests/bootstrap.php b/core/vendor/Symfony/Component/HttpKernel/Tests/bootstrap.php deleted file mode 100644 index 2386a26e1b9ae1be98a33bea9f84cc8226bd731b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/Tests/bootstrap.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -spl_autoload_register(function ($class) { - foreach (array( - 'SYMFONY_EVENT_DISPATCHER' => 'EventDispatcher', - 'SYMFONY_HTTP_FOUNDATION' => 'HttpFoundation', - 'SYMFONY_DEPENDENCY_INJECTION' => 'DependencyInjection', - 'SYMFONY_CONSOLE' => 'Console', - 'SYMFONY_BROWSER_KIT' => 'BrowserKit', - 'SYMFONY_FINDER' => 'Finder', - 'SYMFONY_CLASS_LOADER' => 'ClassLoader', - 'SYMFONY_PROCESS' => 'Process', - 'SYMFONY_ROUTING' => 'Routing', - 'SYMFONY_CONFIG' => 'Config', - ) as $env => $name) { - if (isset($_SERVER[$env]) && 0 === strpos(ltrim($class, '/'), 'Symfony\Component\\'.$name)) { - if (file_exists($file = $_SERVER[$env].'/'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\\'.$name)).'.php')) { - require_once $file; - } - } - } - - if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\HttpKernel')) { - if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\HttpKernel')).'.php')) { - require_once $file; - } - } -}); diff --git a/core/vendor/Symfony/Component/HttpKernel/composer.json b/core/vendor/Symfony/Component/HttpKernel/composer.json deleted file mode 100644 index 95fb176dc6b690de338e9d4301d09982e55eeb6e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "symfony/http-kernel", - "type": "library", - "description": "Symfony HttpKernel Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2", - "symfony/event-dispatcher": "self.version", - "symfony/http-foundation": "self.version" - }, - "suggest": { - "symfony/browser-kit": "self.version", - "symfony/class-loader": "self.version", - "symfony/config": "self.version", - "symfony/console": "self.version", - "symfony/dependency-injection": "self.version", - "symfony/finder": "self.version" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\HttpKernel": "" } - }, - "target-dir": "Symfony/Component/HttpKernel", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -} diff --git a/core/vendor/Symfony/Component/HttpKernel/phpunit.xml.dist b/core/vendor/Symfony/Component/HttpKernel/phpunit.xml.dist deleted file mode 100644 index 0d881e1060734e47554444d11623cd72736f3bc2..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/HttpKernel/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - - - - diff --git a/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php b/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php deleted file mode 100644 index 1291bd12d0eec9b9c7e3851410a5528ca7ace0cc..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * GeneratorDumper is the base class for all built-in generator dumpers. - * - * @author Fabien Potencier - */ -abstract class GeneratorDumper implements GeneratorDumperInterface -{ - private $routes; - - /** - * Constructor. - * - * @param RouteCollection $routes The RouteCollection to dump - */ - public function __construct(RouteCollection $routes) - { - $this->routes = $routes; - } - - public function getRoutes() - { - return $this->routes; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php b/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php deleted file mode 100644 index 7179af291cb11b2515a7d82864326b213072f053..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * GeneratorDumperInterface is the interface that all generator dumper classes must implement. - * - * @author Fabien Potencier - * - * @api - */ -interface GeneratorDumperInterface -{ - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the generator class - */ - function dump(array $options = array()); - - /** - * Gets the routes to dump. - * - * @return RouteCollection A RouteCollection instance - */ - function getRoutes(); -} diff --git a/core/vendor/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/core/vendor/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php deleted file mode 100644 index 0edd6e9b655bab098756444eaab427e5c4b2d56d..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\Route; - -/** - * PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class PhpGeneratorDumper extends GeneratorDumper -{ - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the generator class - * - * @api - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'class' => 'ProjectUrlGenerator', - 'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - ), $options); - - return <<generateDeclaredRoutes()}; - - /** - * Constructor. - */ - public function __construct(RequestContext \$context) - { - \$this->context = \$context; - } - -{$this->generateGenerateMethod()} -} - -EOF; - } - - /** - * Generates PHP code representing an array of defined routes - * together with the routes properties (e.g. requirements). - * - * @return string PHP code - */ - private function generateDeclaredRoutes() - { - $routes = "array(\n"; - foreach ($this->getRoutes()->all() as $name => $route) { - $compiledRoute = $route->compile(); - - $properties = array(); - $properties[] = $compiledRoute->getVariables(); - $properties[] = $compiledRoute->getDefaults(); - $properties[] = $compiledRoute->getRequirements(); - $properties[] = $compiledRoute->getTokens(); - - $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); - } - $routes .= ' )'; - - return $routes; - } - - /** - * Generates PHP code representing the `generate` method that implements the UrlGeneratorInterface. - * - * @return string PHP code - */ - private function generateGenerateMethod() - { - return <<doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$absolute); - } -EOF; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Generator/UrlGenerator.php b/core/vendor/Symfony/Component/Routing/Generator/UrlGenerator.php deleted file mode 100644 index f47f3e5121fe25ead737445fae7052cd3b14d3f3..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Generator/UrlGenerator.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Exception\InvalidParameterException; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; - -/** - * UrlGenerator generates a URL based on a set of routes. - * - * @author Fabien Potencier - * - * @api - */ -class UrlGenerator implements UrlGeneratorInterface -{ - protected $context; - protected $decodedChars = array( - // %2F is not valid in a URL, so we don't encode it (which is fine as the requirements explicitely allowed it) - '%2F' => '/', - ); - - protected $routes; - - /** - * Constructor. - * - * @param RouteCollection $routes A RouteCollection instance - * @param RequestContext $context The context - * - * @api - */ - public function __construct(RouteCollection $routes, RequestContext $context) - { - $this->routes = $routes; - $this->context = $context; - } - - /** - * Sets the request context. - * - * @param RequestContext $context The context - * - * @api - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - } - - /** - * Gets the request context. - * - * @return RequestContext The context - */ - public function getContext() - { - return $this->context; - } - - /** - * {@inheritDoc} - * - * @api - */ - public function generate($name, $parameters = array(), $absolute = false) - { - if (null === $route = $this->routes->get($name)) { - throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name)); - } - - // the Route has a cache of its own and is not recompiled as long as it does not get modified - $compiledRoute = $route->compile(); - - return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $absolute); - } - - /** - * @throws MissingMandatoryParametersException When route has some missing mandatory parameters - * @throws InvalidParameterException When a parameter value is not correct - */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute) - { - $variables = array_flip($variables); - - $originParameters = $parameters; - $parameters = array_replace($this->context->getParameters(), $parameters); - $tparams = array_replace($defaults, $parameters); - - // all params must be given - if ($diff = array_diff_key($variables, $tparams)) { - throw new MissingMandatoryParametersException(sprintf('The "%s" route has some missing mandatory parameters ("%s").', $name, implode('", "', array_keys($diff)))); - } - - $url = ''; - $optional = true; - foreach ($tokens as $token) { - if ('variable' === $token[0]) { - if (false === $optional || !array_key_exists($token[3], $defaults) || (isset($parameters[$token[3]]) && (string) $parameters[$token[3]] != (string) $defaults[$token[3]])) { - if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) { - // check requirement - if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) { - throw new InvalidParameterException(sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $tparams[$token[3]])); - } - } - - if (!$isEmpty || !$optional) { - $url = $token[1].strtr(rawurlencode($tparams[$token[3]]), $this->decodedChars).$url; - } - - $optional = false; - } - } elseif ('text' === $token[0]) { - $url = $token[1].$url; - $optional = false; - } - } - - if (!$url) { - $url = '/'; - } - - // add a query string if needed - $extra = array_diff_key($originParameters, $variables, $defaults); - if ($extra && $query = http_build_query($extra)) { - $url .= '?'.$query; - } - - $url = $this->context->getBaseUrl().$url; - - if ($this->context->getHost()) { - $scheme = $this->context->getScheme(); - if (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme != $req) { - $absolute = true; - $scheme = $req; - } - - if ($absolute) { - $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { - $port = ':'.$this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { - $port = ':'.$this->context->getHttpsPort(); - } - - $url = $scheme.'://'.$this->context->getHost().$port.$url; - } - } - - return $url; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/core/vendor/Symfony/Component/Routing/Loader/AnnotationClassLoader.php deleted file mode 100644 index 28fa896b9cd69fa8084371d4a9aefcc29824f3a1..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ /dev/null @@ -1,214 +0,0 @@ - - * - * 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 Doctrine\Common\Annotations\Reader; -use Symfony\Component\Routing\Annotation\Route as RouteAnnotation; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Loader\LoaderResolverInterface; - -/** - * AnnotationClassLoader loads routing information from a PHP class and its methods. - * - * You need to define an implementation for the getRouteDefaults() method. Most of the - * time, this method should define some PHP callable to be called for the route - * (a controller in MVC speak). - * - * The @Route annotation can be set on the class (for global parameters), - * and on each method. - * - * The @Route annotation main value is the route pattern. The annotation also - * recognizes three parameters: requirements, options, and name. The name parameter - * is mandatory. Here is an example of how you should be able to use it: - * - * /** - * * @Route("/Blog") - * * / - * class Blog - * { - * /** - * * @Route("/", name="blog_index") - * * / - * public function index() - * { - * } - * - * /** - * * @Route("/{id}", name="blog_post", requirements = {"id" = "\d+"}) - * * / - * public function show() - * { - * } - * } - * - * @author Fabien Potencier - */ -abstract class AnnotationClassLoader implements LoaderInterface -{ - protected $reader; - protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route'; - protected $defaultRouteIndex; - - /** - * Constructor. - * - * @param Reader $reader - */ - public function __construct(Reader $reader) - { - $this->reader = $reader; - } - - /** - * Sets the annotation class to read route properties from. - * - * @param string $class A fully-qualified class name - */ - public function setRouteAnnotationClass($class) - { - $this->routeAnnotationClass = $class; - } - - /** - * Loads from annotations from a class. - * - * @param string $class A class name - * @param string $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When route can't be parsed - */ - public function load($class, $type = null) - { - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } - - $globals = array( - 'pattern' => '', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), - ); - - $class = new \ReflectionClass($class); - if ($class->isAbstract()) { - throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class)); - } - - if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { - if (null !== $annot->getPattern()) { - $globals['pattern'] = $annot->getPattern(); - } - - if (null !== $annot->getRequirements()) { - $globals['requirements'] = $annot->getRequirements(); - } - - if (null !== $annot->getOptions()) { - $globals['options'] = $annot->getOptions(); - } - - if (null !== $annot->getDefaults()) { - $globals['defaults'] = $annot->getDefaults(); - } - } - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($class->getFileName())); - - foreach ($class->getMethods() as $method) { - $this->defaultRouteIndex = 0; - foreach ($this->reader->getMethodAnnotations($method) as $annot) { - if ($annot instanceof $this->routeAnnotationClass) { - $this->addRoute($collection, $annot, $globals, $class, $method); - } - } - } - - return $collection; - } - - protected function addRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method) - { - $name = $annot->getName(); - if (null === $name) { - $name = $this->getDefaultRouteName($class, $method); - } - - $defaults = array_merge($globals['defaults'], $annot->getDefaults()); - $requirements = array_merge($globals['requirements'], $annot->getRequirements()); - $options = array_merge($globals['options'], $annot->getOptions()); - - $route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options); - - $this->configureRoute($route, $class, $method, $annot); - - $collection->add($name, $route); - } - - /** - * 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) - { - return is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type); - } - - /** - * Sets the loader resolver. - * - * @param LoaderResolverInterface $resolver A LoaderResolverInterface instance - */ - public function setResolver(LoaderResolverInterface $resolver) - { - } - - /** - * Gets the loader resolver. - * - * @return LoaderResolverInterface A LoaderResolverInterface instance - */ - public function getResolver() - { - } - - /** - * Gets the default route name for a class method. - * - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - * - * @return string - */ - protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) - { - $name = strtolower(str_replace('\\', '_', $class->getName()).'_'.$method->getName()); - if ($this->defaultRouteIndex > 0) { - $name .= '_'.$this->defaultRouteIndex; - } - $this->defaultRouteIndex++; - - return $name; - } - - abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot); -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/core/vendor/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php deleted file mode 100644 index 0fca30494299f61d6abb355c6c3a7e360ca5e5c3..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * 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; -use Symfony\Component\Config\Resource\DirectoryResource; - -/** - * AnnotationDirectoryLoader loads routing information from annotations set - * on PHP classes and methods. - * - * @author Fabien Potencier - */ -class AnnotationDirectoryLoader extends AnnotationFileLoader -{ - /** - * Loads from annotations from a directory. - * - * @param string $path A directory path - * @param string $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed - */ - public function load($path, $type = null) - { - $dir = $this->locator->locate($path); - - $collection = new RouteCollection(); - $collection->addResource(new DirectoryResource($dir, '/\.php$/')); - $files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY)); - usort($files, function (\SplFileInfo $a, \SplFileInfo $b) { - return (string) $a > (string) $b ? 1 : -1; - }); - - foreach ($files as $file) { - if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) { - continue; - } - - if ($class = $this->findClass($file)) { - $refl = new \ReflectionClass($class); - if ($refl->isAbstract()) { - continue; - } - - $collection->addCollection($this->loader->load($class, $type)); - } - } - - return $collection; - } - - /** - * 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) - { - try { - $path = $this->locator->locate($resource); - } catch (\Exception $e) { - return false; - } - - return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type); - } -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/core/vendor/Symfony/Component/Routing/Loader/AnnotationFileLoader.php deleted file mode 100644 index 49e1cb2f7752cc306c1e5c8fde4627a9863113d9..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * 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; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\FileLocator; - -/** - * AnnotationFileLoader loads routing information from annotations set - * on a PHP class and its methods. - * - * @author Fabien Potencier - */ -class AnnotationFileLoader extends FileLoader -{ - protected $loader; - - /** - * Constructor. - * - * @param FileLocator $locator A FileLocator instance - * @param AnnotationClassLoader $loader An AnnotationClassLoader instance - * @param string|array $paths A path or an array of paths where to look for resources - */ - public function __construct(FileLocator $locator, AnnotationClassLoader $loader, $paths = array()) - { - if (!function_exists('token_get_all')) { - throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.'); - } - - parent::__construct($locator, $paths); - - $this->loader = $loader; - } - - /** - * Loads from annotations from a file. - * - * @param string $file A PHP file path - * @param string $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $collection = new RouteCollection(); - if ($class = $this->findClass($path)) { - $collection->addResource(new FileResource($path)); - $collection->addCollection($this->loader->load($class, $type)); - } - - return $collection; - } - - /** - * 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) - { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); - } - - /** - * Returns the full class name for the first class in the file. - * - * @param string $file A PHP file path - * - * @return string|false Full class name if found, false otherwise - */ - protected function findClass($file) - { - $class = false; - $namespace = false; - $tokens = token_get_all(file_get_contents($file)); - for ($i = 0, $count = count($tokens); $i < $count; $i++) { - $token = $tokens[$i]; - - if (!is_array($token)) { - continue; - } - - if (true === $class && T_STRING === $token[0]) { - return $namespace.'\\'.$token[1]; - } - - if (true === $namespace && T_STRING === $token[0]) { - $namespace = ''; - do { - $namespace .= $token[1]; - $token = $tokens[++$i]; - } while ($i < $count && is_array($token) && in_array($token[0], array(T_NS_SEPARATOR, T_STRING))); - } - - if (T_CLASS === $token[0]) { - $class = true; - } - - if (T_NAMESPACE === $token[0]) { - $namespace = true; - } - } - - return false; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/ClosureLoader.php b/core/vendor/Symfony/Component/Routing/Loader/ClosureLoader.php deleted file mode 100644 index ca49c8fa35a97190a3f563d481f4dfca1e4f3cb7..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/ClosureLoader.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * 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\Config\Loader\Loader; - -/** - * ClosureLoader loads routes from a PHP closure. - * - * The Closure must return a RouteCollection instance. - * - * @author Fabien Potencier - * - * @api - */ -class ClosureLoader extends Loader -{ - /** - * Loads a Closure. - * - * @param \Closure $closure A Closure - * @param string $type The resource type - * - * @api - */ - public function load($closure, $type = null) - { - return call_user_func($closure); - } - - /** - * 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 - * - * @api - */ - public function supports($resource, $type = null) - { - return $resource instanceof \Closure && (!$type || 'closure' === $type); - } -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/PhpFileLoader.php b/core/vendor/Symfony/Component/Routing/Loader/PhpFileLoader.php deleted file mode 100644 index ffd31f94442da4b8a2d7a3182bc9972a99185569..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * 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\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; - -/** - * PhpFileLoader loads routes from a PHP file. - * - * The file must return a RouteCollection instance. - * - * @author Fabien Potencier - * - * @api - */ -class PhpFileLoader extends FileLoader -{ - /** - * Loads a PHP file. - * - * @param mixed $file A PHP file path - * @param string $type The resource type - * - * @api - */ - public function load($file, $type = null) - { - // the loader variable is exposed to the included file below - $loader = $this; - - $path = $this->locator->locate($file); - $this->setCurrentDir(dirname($path)); - - $collection = include $path; - $collection->addResource(new FileResource($path)); - - return $collection; - } - - /** - * 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 - * - * @api - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type); - } -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/XmlFileLoader.php b/core/vendor/Symfony/Component/Routing/Loader/XmlFileLoader.php deleted file mode 100644 index 8f27b03c300ef5a0d0015bb7b8b076f49b2fb086..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ /dev/null @@ -1,232 +0,0 @@ - - * - * 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; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; - -/** - * XmlFileLoader loads XML routing files. - * - * @author Fabien Potencier - * - * @api - */ -class XmlFileLoader extends FileLoader -{ - /** - * Loads an XML file. - * - * @param string $file An XML file path - * @param string $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When a tag can't be parsed - * - * @api - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $xml = $this->loadFile($path); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($path)); - - // process routes and imports - foreach ($xml->documentElement->childNodes as $node) { - if (!$node instanceof \DOMElement) { - continue; - } - - $this->parseNode($collection, $node, $path, $file); - } - - return $collection; - } - - /** - * Parses a node from a loaded XML file. - * - * @param RouteCollection $collection the collection to associate with the node - * @param DOMElement $node the node to parse - * @param string $path the path of the XML file being processed - * @param string $file - */ - protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file) - { - switch ($node->tagName) { - case 'route': - $this->parseRoute($collection, $node, $path); - break; - case 'import': - $resource = (string) $node->getAttribute('resource'); - $type = (string) $node->getAttribute('type'); - $prefix = (string) $node->getAttribute('prefix'); - - $defaults = array(); - $requirements = array(); - $options = array(); - - foreach ($node->childNodes as $n) { - if (!$n instanceof \DOMElement) { - continue; - } - - switch ($n->tagName) { - case 'default': - $defaults[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); - break; - case 'requirement': - $requirements[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); - break; - case 'option': - $options[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); - break; - default: - throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $n->tagName)); - } - } - - $this->setCurrentDir(dirname($path)); - $collection->addCollection($this->import($resource, ('' !== $type ? $type : null), false, $file), $prefix, $defaults, $requirements, $options); - break; - default: - throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName)); - } - } - - /** - * 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 - * - * @api - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type); - } - - /** - * Parses a route and adds it to the RouteCollection. - * - * @param RouteCollection $collection A RouteCollection instance - * @param \DOMElement $definition Route definition - * @param string $file An XML file path - * - * @throws \InvalidArgumentException When the definition cannot be parsed - */ - protected function parseRoute(RouteCollection $collection, \DOMElement $definition, $file) - { - $defaults = array(); - $requirements = array(); - $options = array(); - - foreach ($definition->childNodes as $node) { - if (!$node instanceof \DOMElement) { - continue; - } - - switch ($node->tagName) { - case 'default': - $defaults[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); - break; - case 'option': - $options[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); - break; - case 'requirement': - $requirements[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); - break; - default: - throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName)); - } - } - - $route = new Route((string) $definition->getAttribute('pattern'), $defaults, $requirements, $options); - - $collection->add((string) $definition->getAttribute('id'), $route); - } - - /** - * Loads an XML file. - * - * @param string $file An XML file path - * - * @return \DOMDocument - * - * @throws \InvalidArgumentException When loading of XML file returns error - */ - protected function loadFile($file) - { - $dom = new \DOMDocument(); - libxml_use_internal_errors(true); - if (!$dom->load($file, defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0)) { - throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors())); - } - $dom->validateOnParse = true; - $dom->normalizeDocument(); - libxml_use_internal_errors(false); - $this->validate($dom); - - return $dom; - } - - /** - * Validates a loaded XML file. - * - * @param \DOMDocument $dom A loaded XML file - * - * @throws \InvalidArgumentException When XML doesn't validate its XSD schema - */ - protected function validate(\DOMDocument $dom) - { - $location = __DIR__.'/schema/routing/routing-1.0.xsd'; - - $current = libxml_use_internal_errors(true); - if (!$dom->schemaValidate($location)) { - throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors())); - } - libxml_use_internal_errors($current); - } - - /** - * Retrieves libxml errors and clears them. - * - * @return array An array of libxml error strings - */ - private function getXmlErrors() - { - $errors = array(); - foreach (libxml_get_errors() as $error) { - $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', - LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', - $error->code, - trim($error->message), - $error->file ? $error->file : 'n/a', - $error->line, - $error->column - ); - } - - libxml_clear_errors(); - - return $errors; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Loader/YamlFileLoader.php b/core/vendor/Symfony/Component/Routing/Loader/YamlFileLoader.php deleted file mode 100644 index 1f9d711f8145c32ade40c8a0677f857099120cb2..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ /dev/null @@ -1,146 +0,0 @@ - - * - * 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; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Yaml; -use Symfony\Component\Config\Loader\FileLoader; - -/** - * YamlFileLoader loads Yaml routing files. - * - * @author Fabien Potencier - * - * @api - */ -class YamlFileLoader extends FileLoader -{ - private static $availableKeys = array( - 'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements' - ); - - /** - * Loads a Yaml file. - * - * @param string $file A Yaml file path - * @param string $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When route can't be parsed - * - * @api - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $config = Yaml::parse($path); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($path)); - - // empty file - if (null === $config) { - $config = array(); - } - - // not an array - if (!is_array($config)) { - throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $file)); - } - - foreach ($config as $name => $config) { - $config = $this->normalizeRouteConfig($config); - - if (isset($config['resource'])) { - $type = isset($config['type']) ? $config['type'] : null; - $prefix = isset($config['prefix']) ? $config['prefix'] : null; - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); - - $this->setCurrentDir(dirname($path)); - $collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options); - } else { - $this->parseRoute($collection, $name, $config, $path); - } - } - - return $collection; - } - - /** - * 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 - * - * @api - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'yaml' === $type); - } - - /** - * Parses a route and adds it to the RouteCollection. - * - * @param RouteCollection $collection A RouteCollection instance - * @param string $name Route name - * @param array $config Route definition - * @param string $file A Yaml file path - * - * @throws \InvalidArgumentException When config pattern is not defined for the given route - */ - protected function parseRoute(RouteCollection $collection, $name, $config, $file) - { - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); - - if (!isset($config['pattern'])) { - throw new \InvalidArgumentException(sprintf('You must define a "pattern" for the "%s" route.', $name)); - } - - $route = new Route($config['pattern'], $defaults, $requirements, $options); - - $collection->add($name, $route); - } - - /** - * Normalize route configuration. - * - * @param array $config A resource config - * - * @return array - * - * @throws InvalidArgumentException if one of the provided config keys is not supported - */ - private function normalizeRouteConfig(array $config) - { - foreach ($config as $key => $value) { - if (!in_array($key, self::$availableKeys)) { - throw new \InvalidArgumentException(sprintf( - 'Yaml routing loader does not support given key: "%s". Expected one of the (%s).', - $key, implode(', ', self::$availableKeys) - )); - } - } - - return $config; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/core/vendor/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php deleted file mode 100644 index 7499bddff4b7f9b799067cf1f51f2e8951dac8d0..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - - -/** - * Dumps a set of Apache mod_rewrite rules. - * - * @author Fabien Potencier - * @author Kris Wallsmith - */ -class ApacheMatcherDumper extends MatcherDumper -{ - /** - * Dumps a set of Apache mod_rewrite rules. - * - * Available options: - * - * * script_name: The script name (app.php by default) - * * base_uri: The base URI ("" by default) - * - * @param array $options An array of options - * - * @return string A string to be used as Apache rewrite rules - * - * @throws \LogicException When the route regex is invalid - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'script_name' => 'app.php', - 'base_uri' => '', - ), $options); - - $options['script_name'] = self::escape($options['script_name'], ' ', '\\'); - - $rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]"); - $methodVars = array(); - - foreach ($this->getRoutes()->all() as $name => $route) { - $compiledRoute = $route->compile(); - - // prepare the apache regex - $regex = $compiledRoute->getRegex(); - $delimiter = $regex[0]; - $regexPatternEnd = strrpos($regex, $delimiter); - if (strlen($regex) < 2 || 0 === $regexPatternEnd) { - throw new \LogicException('The "%s" route regex "%s" is invalid', $name, $regex); - } - $regex = preg_replace('/\?<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1)); - $regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\'); - - $methods = array(); - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - // GET and HEAD are equivalent - if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - } - - $hasTrailingSlash = (!$methods || in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex; - - $variables = array('E=_ROUTING__route:'.$name); - foreach ($compiledRoute->getVariables() as $i => $variable) { - $variables[] = 'E=_ROUTING_'.$variable.':%'.($i + 1); - } - foreach ($route->getDefaults() as $key => $value) { - $variables[] = 'E=_ROUTING_'.$key.':'.strtr($value, array( - ':' => '\\:', - '=' => '\\=', - '\\' => '\\\\', - ' ' => '\\ ', - )); - } - $variables = implode(',', $variables); - - $rule = array("# $name"); - - // method mismatch - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - // GET and HEAD are equivalent - if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - $allow = array(); - foreach ($methods as $method) { - $methodVars[] = $method; - $allow[] = 'E=_ROUTING__allow_'.$method.':1'; - } - - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = sprintf("RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]", implode('|', $methods)); - $rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow)); - } - - // redirect with trailing slash appended - if ($hasTrailingSlash) { - $rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$'; - $rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]'; - } - - // the main rule - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = "RewriteRule .* {$options['script_name']} [QSA,L,$variables]"; - - $rules[] = implode("\n", $rule); - } - - if (0 < count($methodVars)) { - $rule = array('# 405 Method Not Allowed'); - $methodVars = array_values(array_unique($methodVars)); - foreach ($methodVars as $i => $methodVar) { - $rule[] = sprintf('RewriteCond %%{_ROUTING__allow_%s} !-z%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : ''); - } - $rule[] = sprintf('RewriteRule .* %s [QSA,L]', $options['script_name']); - - $rules[] = implode("\n", $rule); - } - - return implode("\n\n", $rules)."\n"; - } - - /** - * Escapes a string. - * - * @param string $string The string to be escaped - * @param string $char The character to be escaped - * @param string $with The character to be used for escaping - * - * @return string The escaped string - */ - static private function escape($string, $char, $with) - { - $escaped = false; - $output = ''; - foreach(str_split($string) as $symbol) { - if ($escaped) { - $output .= $symbol; - $escaped = false; - continue; - } - if ($symbol === $char) { - $output .= $with.$char; - continue; - } - if ($symbol === $with) { - $escaped = true; - } - $output .= $symbol; - } - - return $output; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php b/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php deleted file mode 100644 index 423368b57ed355809c26a344d7515ceda412a719..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * MatcherDumper is the abstract class for all built-in matcher dumpers. - * - * @author Fabien Potencier - */ -abstract class MatcherDumper implements MatcherDumperInterface -{ - private $routes; - - /** - * Constructor. - * - * @param RouteCollection $routes The RouteCollection to dump - */ - public function __construct(RouteCollection $routes) - { - $this->routes = $routes; - } - - /** - * Gets the routes to dump. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRoutes() - { - return $this->routes; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php b/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php deleted file mode 100644 index 950c396089c68e97b72e0344946cfa11756f39aa..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - -/** - * MatcherDumperInterface is the interface that all matcher dumper classes must implement. - * - * @author Fabien Potencier - */ -interface MatcherDumperInterface -{ - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the matcher class - */ - function dump(array $options = array()); - - /** - * Gets the routes to match. - * - * @return RouteCollection A RouteCollection instance - */ - function getRoutes(); -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/core/vendor/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php deleted file mode 100644 index bc26c0cd0f7dfe8b1290b1cb42fd10567374d643..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ /dev/null @@ -1,289 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class PhpMatcherDumper extends MatcherDumper -{ - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the matcher class - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'class' => 'ProjectUrlMatcher', - 'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - ), $options); - - // trailing slash support is only enabled if we know how to redirect the user - $interfaces = class_implements($options['base_class']); - $supportsRedirections = isset($interfaces['Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcherInterface']); - - return <<context = \$context; - } - -{$this->generateMatchMethod($supportsRedirections)} -} - -EOF; - } - - /** - * Generates the code for the match method implementing UrlMatcherInterface. - * - * @param Boolean $supportsRedirections Whether redirections are supported by the base class - * - * @return string Match method as PHP code - */ - private function generateMatchMethod($supportsRedirections) - { - $code = rtrim($this->compileRoutes($this->getRoutes(), $supportsRedirections), "\n"); - - return <<getPrefix(); - $countDirectChildRoutes = $this->countDirectChildRoutes($routes); - $countAllChildRoutes = count($routes->all()); - // Can the matching be optimized by wrapping it with the prefix condition - // - no need to optimize if current prefix is the same as the parent prefix - // - if $countDirectChildRoutes === 0, the sub-collections can do their own optimizations (in case there are any) - // - it's not worth wrapping a single child route - // - prefixes with variables cannot be optimized because routes within the collection might have different requirements for the same variable - $optimizable = '' !== $prefix && $prefix !== $parentPrefix && $countDirectChildRoutes > 0 && $countAllChildRoutes > 1 && false === strpos($prefix, '{'); - if ($optimizable) { - $code .= sprintf(" if (0 === strpos(\$pathinfo, %s)) {\n", var_export($prefix, true)); - } - - foreach ($routes as $name => $route) { - if ($route instanceof Route) { - // a single route in a sub-collection is not wrapped so it should do its own optimization in ->compileRoute with $parentPrefix = null - $code .= $this->compileRoute($route, $name, $supportsRedirections, 1 === $countAllChildRoutes ? null : $prefix)."\n"; - } elseif ($countAllChildRoutes - $countDirectChildRoutes > 0) { // we can stop iterating recursively if we already know there are no more routes - $code .= $this->compileRoutes($route, $supportsRedirections, $prefix); - } - } - - if ($optimizable) { - $code .= " }\n\n"; - // apply extra indention at each line (except empty ones) - $code = preg_replace('/^.{2,}$/m', ' $0', $code); - } - - return $code; - } - - - /** - * Compiles a single Route to PHP code used to match it against the path info. - * - * @param Route $routes A Route instance - * @param string $name The name of the Route - * @param Boolean $supportsRedirections Whether redirections are supported by the base class - * @param string|null $parentPrefix The prefix of the parent collection used to optimize the code - * - * @return string PHP code - */ - private function compileRoute(Route $route, $name, $supportsRedirections, $parentPrefix = null) - { - $code = ''; - $compiledRoute = $route->compile(); - $conditions = array(); - $hasTrailingSlash = false; - $matches = false; - $methods = array(); - - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - // GET and HEAD are equivalent - if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - } - - $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); - - if (!count($compiledRoute->getVariables()) && false !== preg_match('#^(.)\^(?.*?)\$\1#', $compiledRoute->getRegex(), $m)) { - if ($supportsTrailingSlash && substr($m['url'], -1) === '/') { - $conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); - $hasTrailingSlash = true; - } else { - $conditions[] = sprintf("\$pathinfo === %s", var_export(str_replace('\\', '', $m['url']), true)); - } - } else { - if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) { - $conditions[] = sprintf("0 === strpos(\$pathinfo, %s)", var_export($compiledRoute->getStaticPrefix(), true)); - } - - $regex = $compiledRoute->getRegex(); - if ($supportsTrailingSlash && $pos = strpos($regex, '/$')) { - $regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2); - $hasTrailingSlash = true; - } - $conditions[] = sprintf("preg_match(%s, \$pathinfo, \$matches)", var_export($regex, true)); - - $matches = true; - } - - $conditions = implode(' && ', $conditions); - - $code .= <<context->getMethod() != '$methods[0]') { - \$allow[] = '$methods[0]'; - goto $gotoname; - } - -EOF; - } else { - $methods = implode("', '", $methods); - $code .= <<context->getMethod(), array('$methods'))) { - \$allow = array_merge(\$allow, array('$methods')); - goto $gotoname; - } - -EOF; - } - } - - if ($hasTrailingSlash) { - $code .= <<redirect(\$pathinfo.'/', '$name'); - } - -EOF; - } - - if ($scheme = $route->getRequirement('_scheme')) { - if (!$supportsRedirections) { - throw new \LogicException('The "_scheme" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); - } - - $code .= <<context->getScheme() !== '$scheme') { - return \$this->redirect(\$pathinfo, '$name', '$scheme'); - } - -EOF; - } - - // optimize parameters array - if (true === $matches && $compiledRoute->getDefaults()) { - $code .= sprintf(" return array_merge(\$this->mergeDefaults(\$matches, %s), array('_route' => '%s'));\n" - , str_replace("\n", '', var_export($compiledRoute->getDefaults(), true)), $name); - } elseif (true === $matches) { - $code .= sprintf(" \$matches['_route'] = '%s';\n", $name); - $code .= " return \$matches;\n"; - } elseif ($compiledRoute->getDefaults()) { - $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_merge($compiledRoute->getDefaults(), array('_route' => $name)), true))); - } else { - $code .= sprintf(" return array('_route' => '%s');\n", $name); - } - $code .= " }\n"; - - if ($methods) { - $code .= " $gotoname:\n"; - } - - return $code; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php deleted file mode 100644 index ee8005dc73bc44726d608cd27765eb22fb12afe0..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Route; - -/** - * @author Fabien Potencier - * - * @api - */ -abstract class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface -{ - /** - * @see UrlMatcher::match() - * - * @api - */ - public function match($pathinfo) - { - try { - $parameters = parent::match($pathinfo); - } catch (ResourceNotFoundException $e) { - if ('/' === substr($pathinfo, -1)) { - throw $e; - } - - try { - parent::match($pathinfo.'/'); - - return $this->redirect($pathinfo.'/', null); - } catch (ResourceNotFoundException $e2) { - throw $e; - } - } - - return $parameters; - } - - /** - * {@inheritDoc} - */ - protected function handleRouteRequirements($pathinfo, $name, Route $route) - { - // check HTTP scheme requirement - $scheme = $route->getRequirement('_scheme'); - if ($scheme && $this->context->getScheme() !== $scheme) { - return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, $scheme)); - } - - return array(self::REQUIREMENT_MATCH, null); - } -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php b/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php deleted file mode 100644 index 72a2ec46552bb4eaf9dac55f1f179cbe03a84b6b..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -/** - * RedirectableUrlMatcherInterface knows how to redirect the user. - * - * @author Fabien Potencier - * - * @api - */ -interface RedirectableUrlMatcherInterface -{ - /** - * Redirects the user to another URL. - * - * @param string $path The path info to redirect to. - * @param string $route The route that matched - * @param string $scheme The URL scheme (null to keep the current one) - * - * @return array An array of parameters - * - * @api - */ - function redirect($path, $route, $scheme = null); -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcher.php b/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcher.php deleted file mode 100644 index ded89e637bbec90713878e587915913f1fa0462f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ /dev/null @@ -1,193 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Route; - -/** - * UrlMatcher matches URL based on a set of routes. - * - * @author Fabien Potencier - * - * @api - */ -class UrlMatcher implements UrlMatcherInterface -{ - const REQUIREMENT_MATCH = 0; - const REQUIREMENT_MISMATCH = 1; - const ROUTE_MATCH = 2; - - protected $context; - protected $allow; - - private $routes; - - /** - * Constructor. - * - * @param RouteCollection $routes A RouteCollection instance - * @param RequestContext $context The context - * - * @api - */ - public function __construct(RouteCollection $routes, RequestContext $context) - { - $this->routes = $routes; - $this->context = $context; - } - - /** - * Sets the request context. - * - * @param RequestContext $context The context - * - * @api - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - } - - /** - * Gets the request context. - * - * @return RequestContext The context - */ - public function getContext() - { - return $this->context; - } - - /** - * Tries to match a URL with a set of routes. - * - * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) - * - * @return array An array of parameters - * - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - * - * @api - */ - public function match($pathinfo) - { - $this->allow = array(); - - if ($ret = $this->matchCollection(rawurldecode($pathinfo), $this->routes)) { - return $ret; - } - - throw 0 < count($this->allow) - ? new MethodNotAllowedException(array_unique(array_map('strtoupper', $this->allow))) - : new ResourceNotFoundException(); - } - - /** - * Tries to match a URL with a set of routes. - * - * @param string $pathinfo The path info to be parsed - * @param RouteCollection $routes The set of routes - * - * @return array An array of parameters - * - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - */ - protected function matchCollection($pathinfo, RouteCollection $routes) - { - foreach ($routes as $name => $route) { - if ($route instanceof RouteCollection) { - if (false === strpos($route->getPrefix(), '{') && $route->getPrefix() !== substr($pathinfo, 0, strlen($route->getPrefix()))) { - continue; - } - - if (!$ret = $this->matchCollection($pathinfo, $route)) { - continue; - } - - return $ret; - } - - $compiledRoute = $route->compile(); - - // check the static prefix of the URL first. Only use the more expensive preg_match when it matches - if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) { - continue; - } - - if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) { - continue; - } - - // check HTTP method requirement - if ($req = $route->getRequirement('_method')) { - // HEAD and GET are equivalent as per RFC - if ('HEAD' === $method = $this->context->getMethod()) { - $method = 'GET'; - } - - if (!in_array($method, $req = explode('|', strtoupper($req)))) { - $this->allow = array_merge($this->allow, $req); - - continue; - } - } - - $status = $this->handleRouteRequirements($pathinfo, $name, $route); - - if (self::ROUTE_MATCH === $status[0]) { - return $status[1]; - } - - if (self::REQUIREMENT_MISMATCH === $status[0]) { - continue; - } - - return array_merge($this->mergeDefaults($matches, $route->getDefaults()), array('_route' => $name)); - } - } - - /** - * Handles specific route requirements. - * - * @param string $pathinfo The path - * @param string $name The route name - * @param string $route The route - * - * @return array The first element represents the status, the second contains additional information - */ - protected function handleRouteRequirements($pathinfo, $name, Route $route) - { - // check HTTP scheme requirement - $scheme = $route->getRequirement('_scheme'); - $status = $scheme && $scheme !== $this->context->getScheme() ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; - - return array($status, null); - } - - protected function mergeDefaults($params, $defaults) - { - $parameters = $defaults; - foreach ($params as $key => $value) { - if (!is_int($key)) { - $parameters[$key] = $value; - } - } - - return $parameters; - } -} diff --git a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php b/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php deleted file mode 100644 index 58c5688ad9806a7e6c43e81a52629b96240dab5e..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * UrlMatcherInterface is the interface that all URL matcher classes must implement. - * - * @author Fabien Potencier - * - * @api - */ -interface UrlMatcherInterface extends RequestContextAwareInterface -{ - /** - * Tries to match a URL with a set of routes. - * - * If the matcher can not find information, it must throw one of the exceptions documented - * below. - * - * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) - * - * @return array An array of parameters - * - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - * - * @api - */ - function match($pathinfo); -} diff --git a/core/vendor/Symfony/Component/Routing/README.md b/core/vendor/Symfony/Component/Routing/README.md deleted file mode 100644 index 63c398cfa6511d8fba4aef0bdfb57264732b7e3a..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/README.md +++ /dev/null @@ -1,40 +0,0 @@ -Routing Component -================= - -Routing associates a request with the code that will convert it to a response. - -The example below demonstrates how you can set up a fully working routing -system: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\Routing\Matcher\UrlMatcher; - use Symfony\Component\Routing\RequestContext; - use Symfony\Component\Routing\RouteCollection; - use Symfony\Component\Routing\Route; - - $routes = new RouteCollection(); - $routes->add('hello', new Route('/hello', array('controller' => 'foo'))); - - $context = new RequestContext(); - - // this is optional and can be done without a Request instance - $context->fromRequest(Request::createFromGlobals()); - - $matcher = new UrlMatcher($routes, $context); - - $parameters = $matcher->match('/hello'); - -Resources ---------- - -You can run the unit tests with the following command: - - phpunit -c src/Symfony/Component/Routing/ - -If you also want to run the unit tests that depend on other Symfony -Components, declare the following environment variables before running -PHPUnit: - - export SYMFONY_CONFIG=../path/to/Config - export SYMFONY_YAML=../path/to/Yaml - export DOCTRINE_COMMON=../path/to/doctrine-common diff --git a/core/vendor/Symfony/Component/Routing/RequestContext.php b/core/vendor/Symfony/Component/Routing/RequestContext.php deleted file mode 100644 index 013d9427754ccd81696bb59fc51e36b4b830df8f..0000000000000000000000000000000000000000 --- a/core/vendor/Symfony/Component/Routing/RequestContext.php +++ /dev/null @@ -1,262 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Holds information about the current request. - * - * @author Fabien Potencier - * - * @api - */ -class RequestContext -{ - private $baseUrl; - private $method; - private $host; - private $scheme; - private $httpPort; - private $httpsPort; - private $parameters; - - /** - * Constructor. - * - * @param string $baseUrl The base URL - * @param string $method The HTTP method - * @param string $host The HTTP host name - * @param string $scheme The HTTP scheme - * @param integer $httpPort The HTTP port - * @param integer $httpsPort The HTTPS port - * - * @api - */ - public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443) - { - $this->baseUrl = $baseUrl; - $this->method = strtoupper($method); - $this->host = $host; - $this->scheme = strtolower($scheme); - $this->httpPort = $httpPort; - $this->httpsPort = $httpsPort; - $this->parameters = array(); - } - - public function fromRequest(Request $request) - { - $this->setBaseUrl($request->getBaseUrl()); - $this->setMethod($request->getMethod()); - $this->setHost($request->getHost()); - $this->setScheme($request->getScheme()); - $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort()); - $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort); - } - - /** - * Gets the base URL. - * - * @return string The base URL - */ - public function getBaseUrl() - { - return $this->baseUrl; - } - - /** - * Sets the base URL. - * - * @param string $baseUrl The base URL - * - * @api - */ - publ