diff --git a/core/composer.json b/core/composer.json new file mode 100644 index 0000000..213e68a --- /dev/null +++ b/core/composer.json @@ -0,0 +1,14 @@ +{ + "require": { + "symfony/event-dispatcher": "2.1.x-dev", + "symfony/http-foundation": "2.1.x-dev", + "symfony/http-kernel": "2.1.x-dev", + "symfony/routing": "2.1.x-dev" + }, + "autoload": { + "psr-0": { + "Drupal\\Core": "lib/", + "Drupal\\Component": "lib/" + } + } +} diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 2664a42..6dea8bb 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2133,23 +2133,7 @@ function _drupal_bootstrap_configuration() { drupal_settings_initialize(); // Include and activate the class loader. - $loader = drupal_classloader(); - - // Register explicit vendor namespaces. - $loader->registerNamespaces(array( - // All Symfony-borrowed code lives in /core/vendor/Symfony. - 'Symfony' => DRUPAL_ROOT . '/core/vendor', - )); - // Register the Drupal namespace for classes in core as a fallback. - // This allows to register additional namespaces within the Drupal namespace - // (e.g., for modules) and avoids an additional file_exists() on the Drupal - // core namespace, since the class loader can already determine the best - // namespace match based on a string comparison. It further allows modules to - // register/overload namespaces in Drupal core. - $loader->registerNamespaceFallbacks(array( - // All Drupal-namespaced code in core lives in /core/lib/Drupal. - 'Drupal' => DRUPAL_ROOT . '/core/lib', - )); + drupal_classloader(); } /** @@ -2857,41 +2841,33 @@ function drupal_get_complete_schema($rebuild = FALSE) { * Initializes and returns the class loader. * * The class loader is responsible for lazy-loading all PSR-0 compatible - * classes, interfaces, and traits (PHP 5.4 and later). Its only dependencies - * are DRUPAL_ROOT and variable_get(). Otherwise it may be called as early as - * possible. + * classes, interfaces, and traits (PHP 5.4 and later). Its only dependency is + * DRUPAL_ROOT, otherwise it may be called as early as possible. Calling this + * function will register Drupal\Core, Drupal\Components and Symfony's provided + * components. * - * @return Symfony\Component\ClassLoader\UniversalClassLoader - * A UniversalClassLoader class instance (or extension thereof). + * Example: + * @code + * // Register MyModule's PSR-0 class namespace. + * $loader = drupal_classloader(); + * $path = drupal_get_path('module', 'mymodule') . '/lib/'; + * $loader->add("Drupal\\MyModule", $path); + * @endcode + * + * @return Composer\Autoload\ClassLoader + * Returns the ClassLoader object that was used to register the initial + * namespaces. This allows registration of additional namespaces later on. */ function drupal_classloader() { - // Include the Symfony ClassLoader for loading PSR-0-compatible classes. - require_once DRUPAL_ROOT . '/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - - // By default, use the UniversalClassLoader which is best for development, - // as it does not break when code is moved on the file system. However, as it - // is slow, allow to use the APC class loader in production. static $loader; if (!isset($loader)) { - // @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'; - $loader = new ApcUniversalClassLoader('drupal.' . $GLOBALS['drupal_hash_salt']); - break; - } - // Fall through to the default loader if APC was not loaded, so that the - // site does not fail completely. - case 'dev': - case 'default': - default: - $loader = new UniversalClassLoader(); - break; - } - $loader->register(); + // Drupal Core's classes are auto-loaded by autoload.php. The ClassLoader + // instance used to register the initial namespaces is returned. This file + // is auto-generated by Composer during the build process of composer.json. + $loader = require DRUPAL_ROOT . '/core/vendor/.composer/autoload.php'; } + return $loader; } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 493246c..707ba50 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -229,23 +229,7 @@ function install_begin_request(&$install_state) { // Ensure that the class loader is available so that we can leverage classes // as part of the install routine. - $loader = drupal_classloader(); - - // Register explicit vendor namespaces. - $loader->registerNamespaces(array( - // All Symfony-borrowed code lives in /core/includes/Symfony. - 'Symfony' => DRUPAL_ROOT . '/core/vendor', - )); - // Register the Drupal namespace for classes in core as a fallback. - // This allows to register additional namespaces within the Drupal namespace - // (e.g., for modules) and avoids an additional file_exists() on the Drupal - // core namespace, since the class loader can already determine the best - // namespace match based on a string comparison. It further allows modules to - // register/overload namespaces in Drupal core. - $loader->registerNamespaceFallbacks(array( - // All Drupal-namespaced code in core lives in /core/includes/Drupal. - 'Drupal' => DRUPAL_ROOT . '/core/lib', - )); + drupal_classloader(); if (!$install_state['interactive']) { drupal_override_server_variables($install_state['server']); diff --git a/core/vendor/.composer/ClassLoader.php b/core/vendor/.composer/ClassLoader.php new file mode 100644 index 0000000..94fc76a --- /dev/null +++ b/core/vendor/.composer/ClassLoader.php @@ -0,0 +1,203 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements an PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new ComposerClassLoader(); + * + * // 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. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + private $prefixes = array(); + private $fallbackDirs = array(); + private $useIncludePath = false; + private $classMap = array(); + + public function getPrefixes() + { + return $this->prefixes; + } + + public function getFallbackDirs() + { + return $this->fallbackDirs; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of classes + * + * @param string $prefix The classes prefix + * @param array|string $paths The location(s) of the classes + */ + public function add($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 (isset($this->classMap[$class])) { + return $this->classMap[$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) { + foreach ($dirs as $dir) { + if (0 === strpos($class, $prefix)) { + 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/.composer/autoload.php b/core/vendor/.composer/autoload.php new file mode 100644 index 0000000..1427f02 --- /dev/null +++ b/core/vendor/.composer/autoload.php @@ -0,0 +1,25 @@ + $path) { + $loader->add($namespace, $path); + } + + $classMap = require __DIR__.'/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(); + + return $loader; +}); diff --git a/core/vendor/.composer/autoload_classmap.php b/core/vendor/.composer/autoload_classmap.php new file mode 100644 index 0000000..4a9177d --- /dev/null +++ b/core/vendor/.composer/autoload_classmap.php @@ -0,0 +1,9 @@ + $vendorDir . '/symfony/routing/', + 'Symfony\\Component\\HttpKernel' => $vendorDir . '/symfony/http-kernel/', + 'Symfony\\Component\\HttpFoundation' => $vendorDir . '/symfony/http-foundation/', + 'Symfony\\Component\\EventDispatcher' => $vendorDir . '/symfony/event-dispatcher/', + 'SessionHandlerInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stub', + 'Drupal\\Core' => $baseDir . '/lib/', + 'Drupal\\Component' => $baseDir . '/lib/', +); diff --git a/core/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php deleted file mode 100644 index 1295d0a..0000000 --- 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 da777f2..0000000 --- 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 (!file_exists($metadata) || !file_exists($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 (!file_exists($resource) || filemtime($resource) > $time) { - $reload = true; - - break; - } - } - } - } - } - - if (!$reload && file_exists($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; - -/** - * Checks that the class is actually declared in the included file. - * - * @author Fabien Potencier - */ -class DebugUniversalClassLoader extends UniversalClassLoader -{ - /** - * Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones. - */ - 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) && $function[0] instanceof UniversalClassLoader) { - $loader = new static(); - $loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks()); - $loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks()); - $loader->registerNamespaces($function[0]->getNamespaces()); - $loader->registerPrefixes($function[0]->getPrefixes()); - - $function[0] = $loader; - } - - spl_autoload_register($function); - } - } - - /** - * {@inheritDoc} - */ - public function loadClass($class) - { - if ($file = $this->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)); - } - } - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/MapClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/MapClassLoader.php deleted file mode 100644 index cf17d42..0000000 --- a/core/vendor/Symfony/Component/ClassLoader/MapClassLoader.php +++ /dev/null @@ -1,76 +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; - -/** - * A class loader that uses a mapping file to look up paths. - * - * @author Fabien Potencier - */ -class MapClassLoader -{ - private $map = array(); - - /** - * Constructor. - * - * @param array $map A map where keys are classes and values the absolute file path - */ - public function __construct(array $map) - { - $this->map = $map; - } - - /** - * 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); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - */ - public function loadClass($class) - { - if ('\\' === $class[0]) { - $class = substr($class, 1); - } - - if (isset($this->map[$class])) { - require $this->map[$class]; - } - } - - /** - * 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 (isset($this->map[$class])) { - return $this->map[$class]; - } - } -} diff --git a/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php b/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php deleted file mode 100644 index babf950..0000000 --- a/core/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php +++ /dev/null @@ -1,265 +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', - * )); - * - * // 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(); - - /** - * 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 the directory 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 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); - foreach ($this->namespaces as $ns => $dirs) { - if (0 !== strpos($namespace, $ns)) { - continue; - } - - foreach ($dirs as $dir) { - $className = substr($class, $pos + 1); - $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; - if (file_exists($file)) { - return $file; - } - } - } - - foreach ($this->namespaceFallbacks as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; - if (file_exists($file)) { - return $file; - } - } - } else { - // PEAR-like class name - foreach ($this->prefixes as $prefix => $dirs) { - if (0 !== strpos($class, $prefix)) { - continue; - } - - foreach ($dirs as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; - if (file_exists($file)) { - return $file; - } - } - } - - foreach ($this->prefixFallbacks as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; - if (file_exists($file)) { - 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 f8bde98..0000000 --- a/core/vendor/Symfony/Component/ClassLoader/composer.json +++ /dev/null @@ -1,25 +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" -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ContentTypeMimeTypeGuesser.php b/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ContentTypeMimeTypeGuesser.php deleted file mode 100644 index fb900b2..0000000 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/ContentTypeMimeTypeGuesser.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\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type using the PHP function mime_content_type(). - * - * @author Bernhard Schussek - */ -class ContentTypeMimeTypeGuesser implements MimeTypeGuesserInterface -{ - /** - * Returns whether this guesser is supported on the current OS/PHP setup - * - * @return Boolean - */ - static public function isSupported() - { - return function_exists('mime_content_type'); - } - - /** - * 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; - } - - $type = mime_content_type($path); - - // remove charset (added as of PHP 5.3) - if (false !== $pos = strpos($type, ';')) { - $type = substr($type, 0, $pos); - } - - return $type; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/Session.php b/core/vendor/Symfony/Component/HttpFoundation/Session.php deleted file mode 100644 index a835ef7..0000000 --- a/core/vendor/Symfony/Component/HttpFoundation/Session.php +++ /dev/null @@ -1,405 +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\SessionStorage\SessionStorageInterface; - -/** - * Session. - * - * @author Fabien Potencier - * - * @api - */ -class Session implements \Serializable -{ - protected $storage; - protected $started; - protected $attributes; - protected $flashes; - protected $oldFlashes; - protected $locale; - protected $defaultLocale; - protected $closed; - - /** - * Constructor. - * - * @param SessionStorageInterface $storage A SessionStorageInterface instance - * @param string $defaultLocale The default locale - */ - public function __construct(SessionStorageInterface $storage, $defaultLocale = 'en') - { - $this->storage = $storage; - $this->defaultLocale = $defaultLocale; - $this->locale = $defaultLocale; - $this->flashes = array(); - $this->oldFlashes = array(); - $this->attributes = array(); - $this->setPhpDefaultLocale($this->defaultLocale); - $this->started = false; - $this->closed = false; - } - - /** - * Starts the session storage. - * - * @api - */ - public function start() - { - if (true === $this->started) { - return; - } - - $this->storage->start(); - - $attributes = $this->storage->read('_symfony2'); - - if (isset($attributes['attributes'])) { - $this->attributes = $attributes['attributes']; - $this->flashes = $attributes['flashes']; - $this->locale = $attributes['locale']; - $this->setPhpDefaultLocale($this->locale); - - // flag current flash messages to be removed at shutdown - $this->oldFlashes = $this->flashes; - } - - $this->started = true; - } - - /** - * Checks if an attribute is defined. - * - * @param string $name The attribute name - * - * @return Boolean true if the attribute is defined, false otherwise - * - * @api - */ - public function has($name) - { - return array_key_exists($name, $this->attributes); - } - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value - * - * @return mixed - * - * @api - */ - public function get($name, $default = null) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; - } - - /** - * Sets an attribute. - * - * @param string $name - * @param mixed $value - * - * @api - */ - public function set($name, $value) - { - if (false === $this->started) { - $this->start(); - } - - $this->attributes[$name] = $value; - } - - /** - * Returns attributes. - * - * @return array Attributes - * - * @api - */ - public function all() - { - return $this->attributes; - } - - /** - * Sets attributes. - * - * @param array $attributes Attributes - * - * @api - */ - public function replace(array $attributes) - { - if (false === $this->started) { - $this->start(); - } - - $this->attributes = $attributes; - } - - /** - * Removes an attribute. - * - * @param string $name - * - * @api - */ - public function remove($name) - { - if (false === $this->started) { - $this->start(); - } - - if (array_key_exists($name, $this->attributes)) { - unset($this->attributes[$name]); - } - } - - /** - * Clears all attributes. - * - * @api - */ - public function clear() - { - if (false === $this->started) { - $this->start(); - } - - $this->attributes = array(); - $this->flashes = array(); - $this->setPhpDefaultLocale($this->locale = $this->defaultLocale); - } - - /** - * Invalidates the current session. - * - * @api - */ - public function invalidate() - { - $this->clear(); - $this->storage->regenerate(true); - } - - /** - * Migrates the current session to a new session id while maintaining all - * session attributes. - * - * @api - */ - public function migrate() - { - $this->storage->regenerate(); - } - - /** - * Returns the session ID - * - * @return mixed The session ID - * - * @api - */ - public function getId() - { - if (false === $this->started) { - $this->start(); - } - - return $this->storage->getId(); - } - - /** - * Returns the locale - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Sets the locale. - * - * @param string $locale - */ - public function setLocale($locale) - { - if (false === $this->started) { - $this->start(); - } - - $this->setPhpDefaultLocale($this->locale = $locale); - } - - /** - * Gets the flash messages. - * - * @return array - */ - public function getFlashes() - { - return $this->flashes; - } - - /** - * Sets the flash messages. - * - * @param array $values - */ - public function setFlashes($values) - { - if (false === $this->started) { - $this->start(); - } - - $this->flashes = $values; - $this->oldFlashes = array(); - } - - /** - * Gets a flash message. - * - * @param string $name - * @param string|null $default - * - * @return string - */ - public function getFlash($name, $default = null) - { - return array_key_exists($name, $this->flashes) ? $this->flashes[$name] : $default; - } - - /** - * Sets a flash message. - * - * @param string $name - * @param string $value - */ - public function setFlash($name, $value) - { - if (false === $this->started) { - $this->start(); - } - - $this->flashes[$name] = $value; - unset($this->oldFlashes[$name]); - } - - /** - * Checks whether a flash message exists. - * - * @param string $name - * - * @return Boolean - */ - public function hasFlash($name) - { - if (false === $this->started) { - $this->start(); - } - - return array_key_exists($name, $this->flashes); - } - - /** - * Removes a flash message. - * - * @param string $name - */ - public function removeFlash($name) - { - if (false === $this->started) { - $this->start(); - } - - unset($this->flashes[$name]); - } - - /** - * Removes the flash messages. - */ - public function clearFlashes() - { - if (false === $this->started) { - $this->start(); - } - - $this->flashes = array(); - $this->oldFlashes = array(); - } - - public function save() - { - if (false === $this->started) { - $this->start(); - } - - $this->flashes = array_diff_key($this->flashes, $this->oldFlashes); - - $this->storage->write('_symfony2', array( - 'attributes' => $this->attributes, - 'flashes' => $this->flashes, - 'locale' => $this->locale, - )); - } - - /** - * This method should be called when you don't want the session to be saved - * when the Session object is garbaged collected (useful for instance when - * you want to simulate the interaction of several users/sessions in a single - * PHP process). - */ - public function close() - { - $this->closed = true; - } - - public function __destruct() - { - if (true === $this->started && !$this->closed) { - $this->save(); - } - } - - public function serialize() - { - return serialize(array($this->storage, $this->defaultLocale)); - } - - public function unserialize($serialized) - { - list($this->storage, $this->defaultLocale) = unserialize($serialized); - $this->attributes = array(); - $this->started = false; - } - - 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) { - } - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/ArraySessionStorage.php b/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/ArraySessionStorage.php deleted file mode 100644 index 62aac40..0000000 --- a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/ArraySessionStorage.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\SessionStorage; - -/** - * ArraySessionStorage mocks the session for unit tests. - * - * When doing functional testing, you should use FilesystemSessionStorage instead. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - */ - -class ArraySessionStorage implements SessionStorageInterface -{ - private $data = array(); - - public function read($key, $default = null) - { - return array_key_exists($key, $this->data) ? $this->data[$key] : $default; - } - - public function regenerate($destroy = false) - { - if ($destroy) { - $this->data = array(); - } - - return true; - } - - public function remove($key) - { - unset($this->data[$key]); - } - - public function start() - { - } - - public function getId() - { - } - - public function write($key, $data) - { - $this->data[$key] = $data; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/FilesystemSessionStorage.php b/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/FilesystemSessionStorage.php deleted file mode 100644 index e6eb9ba..0000000 --- a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/FilesystemSessionStorage.php +++ /dev/null @@ -1,175 +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\SessionStorage; - -/** - * FilesystemSessionStorage simulates sessions for functional tests. - * - * This storage does not start the session (session_start()) - * as it is not "available" when running tests on the command line. - * - * @author Fabien Potencier - * - * @api - */ -class FilesystemSessionStorage extends NativeSessionStorage -{ - private $path; - private $data; - private $started; - - /** - * Constructor. - */ - public function __construct($path, array $options = array()) - { - $this->path = $path; - $this->started = false; - - parent::__construct($options); - } - - /** - * Starts the session. - * - * @api - */ - public function start() - { - if ($this->started) { - return; - } - - session_set_cookie_params( - $this->options['lifetime'], - $this->options['path'], - $this->options['domain'], - $this->options['secure'], - $this->options['httponly'] - ); - - if (!ini_get('session.use_cookies') && isset($this->options['id']) && $this->options['id'] && $this->options['id'] != session_id()) { - session_id($this->options['id']); - } - - if (!session_id()) { - session_id(hash('md5', uniqid(mt_rand(), true))); - } - - $file = $this->path.'/'.session_id().'.session'; - - $this->data = file_exists($file) ? unserialize(file_get_contents($file)) : array(); - $this->started = true; - } - - /** - * Returns the session ID - * - * @return mixed The session ID - * - * @throws \RuntimeException If the session was not started yet - * - * @api - */ - public function getId() - { - if (!$this->started) { - throw new \RuntimeException('The session must be started before reading its ID'); - } - - return session_id(); - } - - /** - * Reads data from this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * @param string $default The default value - * - * @return mixed Data associated with the key - * - * @throws \RuntimeException If an error occurs while reading data from this storage - * - * @api - */ - public function read($key, $default = null) - { - return array_key_exists($key, $this->data) ? $this->data[$key] : $default; - } - - /** - * Removes data from this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * - * @return mixed Data associated with the key - * - * @throws \RuntimeException If an error occurs while removing data from this storage - * - * @api - */ - public function remove($key) - { - $retval = $this->data[$key]; - - unset($this->data[$key]); - - return $retval; - } - - /** - * Writes data to this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * @param mixed $data Data associated with your key - * - * @throws \RuntimeException If an error occurs while writing to this storage - * - * @api - */ - public function write($key, $data) - { - $this->data[$key] = $data; - - if (!is_dir($this->path)) { - mkdir($this->path, 0777, true); - } - - file_put_contents($this->path.'/'.session_id().'.session', serialize($this->data)); - } - - /** - * Regenerates id that represents this storage. - * - * @param Boolean $destroy Destroy session when regenerating? - * - * @return Boolean True if session regenerated, false if error - * - * @throws \RuntimeException If an error occurs while regenerating this storage - * - * @api - */ - public function regenerate($destroy = false) - { - if ($destroy) { - $this->data = array(); - } - - return true; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/NativeSessionStorage.php b/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/NativeSessionStorage.php deleted file mode 100644 index b759f74..0000000 --- a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/NativeSessionStorage.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\HttpFoundation\SessionStorage; - -/** - * NativeSessionStorage. - * - * @author Fabien Potencier - * - * @api - */ -class NativeSessionStorage implements SessionStorageInterface -{ - static protected $sessionIdRegenerated = false; - static protected $sessionStarted = false; - - protected $options; - - /** - * Available options: - * - * * name: The cookie name (null [omitted] by default) - * * id: The session id (null [omitted] by default) - * * lifetime: Cookie lifetime - * * path: Cookie path - * * domain: Cookie domain - * * secure: Cookie secure - * * httponly: Cookie http only - * - * The default values for most options are those returned by the session_get_cookie_params() function - * - * @param array $options An associative array of session options - */ - public function __construct(array $options = array()) - { - $cookieDefaults = session_get_cookie_params(); - - $this->options = array_merge(array( - 'lifetime' => $cookieDefaults['lifetime'], - 'path' => $cookieDefaults['path'], - 'domain' => $cookieDefaults['domain'], - 'secure' => $cookieDefaults['secure'], - 'httponly' => isset($cookieDefaults['httponly']) ? $cookieDefaults['httponly'] : false, - ), $options); - - // Skip setting new session name if user don't want it - if (isset($this->options['name'])) { - session_name($this->options['name']); - } - } - - /** - * Starts the session. - * - * @api - */ - public function start() - { - if (self::$sessionStarted) { - return; - } - - session_set_cookie_params( - $this->options['lifetime'], - $this->options['path'], - $this->options['domain'], - $this->options['secure'], - $this->options['httponly'] - ); - - // disable native cache limiter as this is managed by HeaderBag directly - session_cache_limiter(false); - - if (!ini_get('session.use_cookies') && isset($this->options['id']) && $this->options['id'] && $this->options['id'] != session_id()) { - session_id($this->options['id']); - } - - session_start(); - - self::$sessionStarted = true; - } - - /** - * {@inheritDoc} - * - * @api - */ - public function getId() - { - if (!self::$sessionStarted) { - throw new \RuntimeException('The session must be started before reading its ID'); - } - - return session_id(); - } - - /** - * Reads data from this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * @param string $default Default value - * - * @return mixed Data associated with the key - * - * @api - */ - public function read($key, $default = null) - { - return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default; - } - - /** - * Removes data from this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * - * @return mixed Data associated with the key - * - * @api - */ - public function remove($key) - { - $retval = null; - - if (isset($_SESSION[$key])) { - $retval = $_SESSION[$key]; - unset($_SESSION[$key]); - } - - return $retval; - } - - /** - * Writes data to this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * @param mixed $data Data associated with your key - * - * @api - */ - public function write($key, $data) - { - $_SESSION[$key] = $data; - } - - /** - * Regenerates id that represents this storage. - * - * @param Boolean $destroy Destroy session when regenerating? - * - * @return Boolean True if session regenerated, false if error - * - * @api - */ - public function regenerate($destroy = false) - { - if (self::$sessionIdRegenerated) { - return; - } - - session_regenerate_id($destroy); - - self::$sessionIdRegenerated = true; - } -} diff --git a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/SessionStorageInterface.php b/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/SessionStorageInterface.php deleted file mode 100644 index b61a255..0000000 --- a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/SessionStorageInterface.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\SessionStorage; - -/** - * SessionStorageInterface. - * - * @author Fabien Potencier - * - * @api - */ -interface SessionStorageInterface -{ - /** - * Starts the session. - * - * @api - */ - function start(); - - /** - * Returns the session ID - * - * @return mixed The session ID - * - * @throws \RuntimeException If the session was not started yet - * - * @api - */ - function getId(); - - /** - * Reads data from this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * - * @return mixed Data associated with the key - * - * @throws \RuntimeException If an error occurs while reading data from this storage - * - * @api - */ - function read($key); - - /** - * Removes data from this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * - * @return mixed Data associated with the key - * - * @throws \RuntimeException If an error occurs while removing data from this storage - * - * @api - */ - function remove($key); - - /** - * Writes data to this storage. - * - * The preferred format for a key is directory style so naming conflicts can be avoided. - * - * @param string $key A unique key identifying your data - * @param mixed $data Data associated with your key - * - * @throws \RuntimeException If an error occurs while writing to this storage - * - * @api - */ - function write($key, $data); - - /** - * Regenerates id that represents this storage. - * - * @param Boolean $destroy Destroy session when regenerating? - * - * @return Boolean True if session regenerated, false if error - * - * @throws \RuntimeException If an error occurs while regenerating this storage - * - * @api - */ - function regenerate($destroy = false); -} diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/Stopwatch.php b/core/vendor/Symfony/Component/HttpKernel/Debug/Stopwatch.php deleted file mode 100644 index f964d42..0000000 --- a/core/vendor/Symfony/Component/HttpKernel/Debug/Stopwatch.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -/** - * Stopwatch provides a way to profile code. - * - * @author Fabien Potencier - */ -class Stopwatch -{ - private $waiting; - private $sections; - private $events; - private $origin; - - /** - * Starts a new section. - */ - public function startSection() - { - if ($this->events) { - $this->start('section.child', 'section'); - $this->waiting[] = array($this->events, $this->origin); - $this->events = array(); - } - - $this->origin = microtime(true) * 1000; - - $this->start('section'); - } - - /** - * Stops the last started section. - * - * The id parameter is used to retrieve the events from this section. - * - * @see getSectionEvents - * - * @param string $id The identifier of the section - */ - public function stopSection($id) - { - $this->stop('section'); - - if (null !== $id) { - $this->sections[$id] = $this->events; - } - - if ($this->waiting) { - list($this->events, $this->origin) = array_pop($this->waiting); - $this->stop('section.child'); - } else { - $this->origin = null; - $this->events = array(); - } - } - - /** - * Starts an event. - * - * @param string $name The event name - * @param string $category The event category - * - * @return StopwatchEvent A StopwatchEvent instance - */ - public function start($name, $category = null) - { - if (!isset($this->events[$name])) { - $this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category); - } - - return $this->events[$name]->start(); - } - - /** - * Stops an event. - * - * @param string $name The event name - * - * @return StopwatchEvent A StopwatchEvent instance - */ - public function stop($name) - { - if (!isset($this->events[$name])) { - throw new \LogicException(sprintf('Event "%s" is not started.', $name)); - } - - return $this->events[$name]->stop(); - } - - /** - * Stops then restart an event. - * - * @param string $name The event name - * - * @return StopwatchEvent A StopwatchEvent instance - */ - public function lap($name) - { - return $this->stop($name)->start(); - } - - /** - * Gets all events for a given section. - * - * @param string $id A section identifier - * - * @return StopwatchEvent[] An array of StopwatchEvent instances - */ - public function getSectionEvents($id) - { - return isset($this->sections[$id]) ? $this->sections[$id] : array(); - } -} diff --git a/core/vendor/Symfony/Component/Routing/LICENSE b/core/vendor/Symfony/Component/Routing/LICENSE deleted file mode 100644 index 89df448..0000000 --- a/core/vendor/Symfony/Component/Routing/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2011 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/core/vendor/Symfony/Component/EventDispatcher/Event.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php similarity index 100% rename from core/vendor/Symfony/Component/EventDispatcher/Event.php rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php diff --git a/core/vendor/Symfony/Component/EventDispatcher/EventDispatcher.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php similarity index 100% rename from core/vendor/Symfony/Component/EventDispatcher/EventDispatcher.php rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php diff --git a/core/vendor/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php similarity index 100% rename from core/vendor/Symfony/Component/EventDispatcher/EventDispatcherInterface.php rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php diff --git a/core/vendor/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php similarity index 100% rename from core/vendor/Symfony/Component/EventDispatcher/EventSubscriberInterface.php rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php diff --git a/core/vendor/Symfony/Component/ClassLoader/LICENSE b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE similarity index 96% rename from core/vendor/Symfony/Component/ClassLoader/LICENSE rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE index 89df448..cdffe7a 100644 --- a/core/vendor/Symfony/Component/ClassLoader/LICENSE +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2011 Fabien Potencier +Copyright (c) 2004-2012 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/vendor/Symfony/Component/EventDispatcher/README.md b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md similarity index 100% rename from core/vendor/Symfony/Component/EventDispatcher/README.md rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md diff --git a/core/vendor/Symfony/Component/EventDispatcher/composer.json b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json similarity index 79% rename from core/vendor/Symfony/Component/EventDispatcher/composer.json rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json index b9ea291..0c8d455 100644 --- a/core/vendor/Symfony/Component/EventDispatcher/composer.json +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json @@ -4,7 +4,6 @@ "description": "Symfony EventDispatcher Component", "keywords": [], "homepage": "http://symfony.com", - "version": "2.1.0", "license": "MIT", "authors": [ { @@ -22,5 +21,10 @@ "autoload": { "psr-0": { "Symfony\\Component\\EventDispatcher": "" } }, - "target-dir": "Symfony/Component/EventDispatcher" + "target-dir": "Symfony/Component/EventDispatcher", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + } } diff --git a/core/vendor/Symfony/Component/HttpFoundation/ApacheRequest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/ApacheRequest.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/Cookie.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/Cookie.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileException.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileException.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/Exception/UploadException.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/Exception/UploadException.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php new file mode 100644 index 0000000..3134ccd --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php @@ -0,0 +1,129 @@ + + * + * 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); + + return new File($target); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php new file mode 100644 index 0000000..b73cd99 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php @@ -0,0 +1,100 @@ + + * + * 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/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php new file mode 100644 index 0000000..5b14ef9 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php @@ -0,0 +1,26 @@ + + * + * 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/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php similarity index 74% rename from core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php index 1b869f2..12b84cd 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php @@ -21,6 +21,23 @@ use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; */ 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 * @@ -28,8 +45,9 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface */ static public function isSupported() { - return !strstr(PHP_OS, 'WIN'); + return !defined('PHP_WINDOWS_VERSION_BUILD'); } + /** * Guesses the mime type of the file with the given path * @@ -52,7 +70,7 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface ob_start(); // need to use --mime instead of -i. see #6641 - passthru(sprintf('file -b --mime %s 2>/dev/null', escapeshellarg($path)), $return); + passthru(sprintf($this->cmd, escapeshellarg($path)), $return); if ($return > 0) { ob_end_clean(); diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/File.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php similarity index 85% rename from core/vendor/Symfony/Component/HttpFoundation/File/File.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php index 58bc6f4..63b1630 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/File/File.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php @@ -9,27 +9,19 @@ * 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; +namespace Symfony\Component\HttpFoundation\File\Mimetype; /** - * A file in the file system. - * - * @author Bernhard Schussek - * - * @api + * Provides a best-guess mapping of mime type to file extension. */ -class File extends \SplFileInfo +class MimeTypeExtensionGuesser implements ExtensionGuesserInterface { /** * A map of mime types and their default extensions. * * @var array */ - static protected $defaultExtensions = array( + protected $defaultExtensions = array( 'application/andrew-inset' => 'ez', 'application/appledouble' => 'base64', 'application/applefile' => 'base64', @@ -348,6 +340,7 @@ class File extends \SplFileInfo 'image/pict' => 'pic', 'image/pjpeg' => 'jpg', 'image/png' => 'png', + 'image/svg+xml' => 'svg', 'image/targa' => 'tga', 'image/tiff' => 'tif', 'image/vn-svf' => 'svf', @@ -428,7 +421,6 @@ class File extends \SplFileInfo 'video/vnd.sealedmedia.softseal.mov' => 'smov', 'video/vnd.vivo' => 'vivo', 'video/x-fli' => 'fli', - 'video/x-flv' => 'flv', 'video/x-ms-asf' => 'asf', 'video/x-ms-wmv' => 'wmv', 'video/x-msvideo' => 'avi', @@ -444,103 +436,14 @@ 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(); - - return isset(static::$defaultExtensions[$type]) ? static::$defaultExtensions[$type] : null; - } - - /** - * 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() + public function guess($mimeType) { - $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); - - return new File($target); + return isset($this->defaultExtensions[$mimeType]) ? $this->defaultExtensions[$mimeType] : null; } } diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php similarity index 96% rename from core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php index 9601618..d73a093 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php @@ -67,10 +67,6 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface $this->register(new FileBinaryMimeTypeGuesser()); } - if (ContentTypeMimeTypeGuesser::isSupported()) { - $this->register(new ContentTypeMimeTypeGuesser()); - } - if (FileinfoMimeTypeGuesser::isSupported()) { $this->register(new FileinfoMimeTypeGuesser()); } diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/File/UploadedFile.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/File/UploadedFile.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/FileBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/FileBag.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/HeaderBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/HeaderBag.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php diff --git a/core/vendor/Symfony/Component/HttpKernel/LICENSE b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE similarity index 96% rename from core/vendor/Symfony/Component/HttpKernel/LICENSE rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE index 89df448..cdffe7a 100644 --- a/core/vendor/Symfony/Component/HttpKernel/LICENSE +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2011 Fabien Potencier +Copyright (c) 2004-2012 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/vendor/Symfony/Component/HttpFoundation/ParameterBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php similarity index 86% rename from core/vendor/Symfony/Component/HttpFoundation/ParameterBag.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php index e5d237c..84c0fb8 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php @@ -20,6 +20,11 @@ namespace Symfony\Component\HttpFoundation; */ class ParameterBag { + /** + * Parameter storage. + * + * @var array + */ protected $parameters; /** @@ -242,4 +247,34 @@ class ParameterBag { 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); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md new file mode 100644 index 0000000..88adfed --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md @@ -0,0 +1,47 @@ +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 +--------- + +Unit tests: + +https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/HttpFoundation diff --git a/core/vendor/Symfony/Component/HttpFoundation/RedirectResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php similarity index 87% rename from core/vendor/Symfony/Component/HttpFoundation/RedirectResponse.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php index 3318b12..eb0facf 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -20,6 +20,8 @@ namespace Symfony\Component\HttpFoundation; */ class RedirectResponse extends Response { + protected $targetUrl; + /** * Creates a redirect response so that it conforms to the rules defined for a redirect status code. * @@ -36,6 +38,8 @@ class RedirectResponse extends Response throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); } + $this->targetUrl = $url; + parent::__construct( sprintf(' @@ -57,4 +61,14 @@ class RedirectResponse extends Response throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); } } + + /** + * Returns the target URL. + * + * @return string target URL + */ + public function getTargetUrl() + { + return $this->targetUrl; + } } diff --git a/core/vendor/Symfony/Component/HttpFoundation/Request.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php similarity index 88% rename from core/vendor/Symfony/Component/HttpFoundation/Request.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php index 3a20ed9..3fcc123 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/Request.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php @@ -11,6 +11,8 @@ namespace Symfony\Component\HttpFoundation; +use Symfony\Component\HttpFoundation\Session\SessionInterface; + /** * Request represents an HTTP request. * @@ -71,18 +73,74 @@ class Request */ 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; /** @@ -152,7 +210,7 @@ class Request $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')) + && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH')) ) { parse_str($request->getContent(), $data); $request->request = new ParameterBag($data); @@ -211,38 +269,49 @@ class Request $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'] = ''; } - if (in_array(strtoupper($method), array('POST', 'PUT', 'DELETE'))) { - $request = $parameters; - $query = array(); - $defaults['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - } else { - $request = array(); - $query = $parameters; - if (false !== $pos = strpos($uri, '?')) { - $qs = substr($uri, $pos + 1); - parse_str($qs, $params); - - $query = array_merge($params, $query); - } + 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; } - $queryString = isset($components['query']) ? html_entity_decode($components['query']) : ''; - parse_str($queryString, $qs); - if (is_array($qs)) { - $query = array_replace($qs, $query); + 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, + 'REQUEST_METHOD' => strtoupper($method), + 'PATH_INFO' => '', + 'REQUEST_URI' => $uri, + 'QUERY_STRING' => $queryString, )); return new static($query, $request, array(), $cookies, $files, $server, $content); @@ -373,10 +442,15 @@ class Request * 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 @@ -391,7 +465,7 @@ class Request /** * Gets the Session. * - * @return Session|null The session + * @return SessionInterface|null The session * * @api */ @@ -429,11 +503,11 @@ class Request /** * Sets the Session. * - * @param Session $session The Session + * @param SessionInterface $session The Session * * @api */ - public function setSession(Session $session) + public function setSession(SessionInterface $session) { $this->session = $session; } @@ -570,6 +644,26 @@ class Request } /** + * 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. @@ -622,7 +716,20 @@ class Request $qs = '?'.$qs; } - return $this->getScheme().'://'.$this->getHttpHost().$this->getBaseUrl().$this->getPathInfo().$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; } /** @@ -851,22 +958,50 @@ class Request $this->format = $format; } - public function setLocale($locale) + /** + * Gets the format associated with the request. + * + * @return string The format (null if no content type is present) + * + * @api + */ + public function getContentType() { - if (!$this->hasSession()) { - throw new \LogicException('Forward compatibility for Request::setLocale() requires the session to be set.'); - } + return $this->getFormat($this->server->get('CONTENT_TYPE')); + } - $this->session->setLocale($locale); + /** + * Sets the default locale. + * + * @param string $locale + * + * @api + */ + public function setDefaultLocale($locale) + { + $this->setPhpDefaultLocale($this->defaultLocale = $locale); } - public function getLocale() + /** + * Sets the locale. + * + * @param string $locale + * + * @api + */ + public function setLocale($locale) { - if (!$this->hasSession()) { - throw new \LogicException('Forward compatibility for Request::getLocale() requires the session to be set.'); - } + $this->setPhpDefaultLocale($this->locale = $locale); + } - return $this->session->getLocale(); + /** + * Get the locale. + * + * @return string + */ + public function getLocale() + { + return null === $this->locale ? $this->defaultLocale : $this->locale; } /** @@ -1107,6 +1242,11 @@ class Request return $requestUri; } + /** + * Prepares the base URL. + * + * @return string + */ protected function prepareBaseUrl() { $filename = basename($this->server->get('SCRIPT_FILENAME')); @@ -1169,7 +1309,7 @@ class Request } /** - * Prepares base path. + * Prepares the base path. * * @return string base path */ @@ -1195,7 +1335,7 @@ class Request } /** - * Prepares path info. + * Prepares the path info. * * @return string path info */ @@ -1238,6 +1378,25 @@ class Request '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) { + } + } } diff --git a/core/vendor/Symfony/Component/HttpFoundation/RequestMatcher.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php similarity index 83% rename from core/vendor/Symfony/Component/HttpFoundation/RequestMatcher.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php index e82b3e1..0ca082d 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -20,10 +20,31 @@ namespace Symfony\Component\HttpFoundation; */ class RequestMatcher implements RequestMatcherInterface { + /** + * @var string + */ private $path; + + /** + * @var string + */ private $host; + + /** + * @var string + */ private $methods; + + /** + * @var string + */ private $ip; + + /** + * Attributes. + * + * @var array + */ private $attributes; public function __construct($path = null, $host = null, $methods = null, $ip = null, array $attributes = array()) @@ -122,6 +143,14 @@ class RequestMatcher implements RequestMatcherInterface return true; } + /** + * Validates an IP address. + * + * @param string $requestIp + * @param string $ip + * + * @return boolean True valid, false if not. + */ protected function checkIp($requestIp, $ip) { // IPv6 address @@ -132,6 +161,14 @@ class RequestMatcher implements RequestMatcherInterface } } + /** + * Validates an IPv4 address. + * + * @param string $requestIp + * @param string $ip + * + * @return boolean True valid, false if not. + */ protected function checkIp4($requestIp, $ip) { if (false !== strpos($ip, '/')) { @@ -149,8 +186,15 @@ class RequestMatcher implements RequestMatcherInterface } /** + * Validates an IPv6 address. + * * @author David Soria Parra * @see https://github.com/dsp/v6tools + * + * @param string $requestIp + * @param string $ip + * + * @return boolean True valid, false if not. */ protected function checkIp6($requestIp, $ip) { @@ -160,14 +204,14 @@ class RequestMatcher implements RequestMatcherInterface list($address, $netmask) = explode('/', $ip, 2); - $bytes_addr = unpack("n*", inet_pton($address)); - $bytes_test = unpack("n*", inet_pton($requestIp)); + $bytesAddr = unpack("n*", inet_pton($address)); + $bytesTest = unpack("n*", inet_pton($requestIp)); for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; $i++) { $left = $netmask - 16 * ($i-1); $left = ($left <= 16) ? $left : 16; $mask = ~(0xffff >> $left) & 0xffff; - if (($bytes_addr[$i] & $mask) != ($bytes_test[$i] & $mask)) { + if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) { return false; } } diff --git a/core/vendor/Symfony/Component/HttpFoundation/RequestMatcherInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpFoundation/RequestMatcherInterface.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php new file mode 100644 index 0000000..24b9648 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php @@ -0,0 +1,155 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Session Savehandler Interface. + * + * This interface is for implementing methods required for the + * session_set_save_handler() function. + * + * @see http://php.net/session_set_save_handler + * + * These are methods called by PHP when the session is started + * and closed and for various house-keeping tasks required + * by session management. + * + * PHP requires session save handlers. There are some defaults set + * automatically when PHP starts, but these can be overriden using + * this command if you need anything other than PHP's default handling. + * + * When the session starts, PHP will call the read() handler + * which should return a string extactly as stored (which will have + * been encoded by PHP using a special session serializer session_decode() + * which is different to the serialize() function. PHP will then populate + * these into $_SESSION. + * + * When PHP shuts down, the write() handler is called and will pass + * the $_SESSION contents already serialized (using session_encode()) to + * be stored. + * + * When a session is specifically destroyed, PHP will call the + * destroy() handler with the session ID. This happens when the + * session is regenerated for example and th handler MUST delete the + * session by ID from the persistent storage immediately. + * + * PHP will call gc() from time to time to expire any session + * records according to the set max lifetime of a session. This routine + * should delete all records from persistent storage which were last + * accessed longer than the $lifetime. + * + * PHP open() and close() are pretty much redundant and + * can return true. + * + * @author Drak + */ +interface SessionHandlerInterface +{ + /** + * Open session. + * + * This method is for internal use by PHP and must not be called manually. + * + * @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. + * + * This method is for internal use by PHP and must not be called manually. + * + * @return boolean + */ + function close(); + + /** + * Read session. + * + * This method is for internal use by PHP and must not be called manually. + * + * This method is called by PHP itself when the session is started. + * This method should retrieve the session data from storage by the + * ID provided by PHP. Return the string directly as is from storage. + * If the record was not found you must return an empty string. + * + * The returned data will be unserialized automatically by PHP using a + * special unserializer method session_decode() and the result will be used + * to populate the $_SESSION superglobal. This is done automatically and + * is not configurable. + * + * @param string $sessionId Session ID. + * + * @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. + * + * This method is for internal use by PHP and must not be called manually. + * + * PHP will call this method when the session is closed. It sends + * the session ID and the contents of $_SESSION to be saved in a lightweight + * serialized format (which PHP does automatically using session_encode() + * which should be stored exactly as is given in $data. + * + * Note this method is normally called by PHP after the output buffers + * have been closed. + * + * @param string $sessionId Session ID. + * @param string $data Session serialized data to save. + * + * @throws \RuntimeException On fatal error. + * + * @return boolean + */ + function write($sessionId, $data); + + /** + * Destroys this session. + * + * This method is for internal use by PHP and must not be called manually. + * + * PHP will call this method when the session data associated + * with the session ID provided needs to be immediately + * deleted from the permanent storage. + * + * @param string $sessionId Session ID. + * + * @throws \RuntimeException On fatal error. + * + * @return boolean + */ + function destroy($sessionId); + + /** + * Garbage collection for storage. + * + * This method is for internal use by PHP and must not be called manually. + * + * This method is called by PHP periodically and passes the maximum + * time a session can exist for before being deleted from permanent storage. + * + * @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/http-foundation/Symfony/Component/HttpFoundation/Response.php similarity index 89% rename from core/vendor/Symfony/Component/HttpFoundation/Response.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php index b6cb484..f5b9e51 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/Response.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php @@ -25,12 +25,36 @@ class Response */ 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. + * + * @var array + */ static public $statusTexts = array( 100 => 'Continue', 101 => 'Switching Protocols', @@ -96,14 +120,18 @@ class Response } /** - * Returns the response content as it will be sent (with the headers). + * Returns the Response as an HTTP string. + * + * The string representation of the Resonse 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 content + * @return string The Response as an HTTP string + * + * @see prepare() */ public function __toString() { - $this->prepare(); - return sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n". $this->headers."\r\n". @@ -122,26 +150,48 @@ class Response * Prepares the Response before it is sent to the client. * * This method tweaks the Response to ensure that it is - * compliant with RFC 2616. + * 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 */ - public function prepare() + 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 (!$this->headers->has('Content-Type')) { - $this->headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === strpos($this->headers->get('Content-Type'), 'text/') && false === strpos($this->headers->get('Content-Type'), 'charset')) { + 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 - $this->headers->set('Content-Type', $this->headers->get('Content-Type').'; charset='.$charset); + $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); } // Fix Content-Length - if ($this->headers->has('Transfer-Encoding')) { - $this->headers->remove('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); + } } } @@ -155,8 +205,6 @@ class Response return; } - $this->prepare(); - // status header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)); @@ -732,7 +780,7 @@ class Response /** * Returns true if the response includes a Vary header. * - * @return true if the response includes a Vary header, false otherwise + * @return Boolean true if the response includes a Vary header, false otherwise * * @api */ @@ -802,6 +850,10 @@ class Response // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html /** + * Is response invalid? + * + * @return Boolean + * * @api */ public function isInvalid() @@ -810,6 +862,10 @@ class Response } /** + * Is response informative? + * + * @return Boolean + * * @api */ public function isInformational() @@ -818,6 +874,10 @@ class Response } /** + * Is response successful? + * + * @return Boolean + * * @api */ public function isSuccessful() @@ -826,6 +886,10 @@ class Response } /** + * Is the response a redirect? + * + * @return Boolean + * * @api */ public function isRedirection() @@ -834,6 +898,10 @@ class Response } /** + * Is there a client error? + * + * @return Boolean + * * @api */ public function isClientError() @@ -842,6 +910,10 @@ class Response } /** + * Was there a server side error? + * + * @return Boolean + * * @api */ public function isServerError() @@ -850,6 +922,10 @@ class Response } /** + * Is the response OK? + * + * @return Boolean + * * @api */ public function isOk() @@ -858,6 +934,10 @@ class Response } /** + * Is the reponse forbidden? + * + * @return Boolean + * * @api */ public function isForbidden() @@ -866,6 +946,10 @@ class Response } /** + * Is the response a not found error? + * + * @return Boolean + * * @api */ public function isNotFound() @@ -874,6 +958,12 @@ class Response } /** + * Is the response a redirect of some form? + * + * @param string $location + * + * @return Boolean + * * @api */ public function isRedirect($location = null) @@ -882,6 +972,10 @@ class Response } /** + * Is the response empty? + * + * @return Boolean + * * @api */ public function isEmpty() diff --git a/core/vendor/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php similarity index 70% rename from core/vendor/Symfony/Component/HttpFoundation/ResponseHeaderBag.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index 999f0ab..11615b9 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -20,10 +20,20 @@ namespace Symfony\Component\HttpFoundation; */ class ResponseHeaderBag extends HeaderBag { - const COOKIES_FLAT = 'flat'; - const COOKIES_ARRAY = 'array'; + const COOKIES_FLAT = 'flat'; + const COOKIES_ARRAY = 'array'; + const DISPOSITION_ATTACHMENT = 'attachment'; + const DISPOSITION_INLINE = 'inline'; + + /** + * @var array + */ protected $computedCacheControl = array(); + + /** + * @var array + */ protected $cookies = array(); /** @@ -121,8 +131,6 @@ class ResponseHeaderBag extends HeaderBag * * @param Cookie $cookie * - * @return void - * * @api */ public function setCookie(Cookie $cookie) @@ -137,8 +145,6 @@ class ResponseHeaderBag extends HeaderBag * @param string $path * @param string $domain * - * @return void - * * @api */ public function removeCookie($name, $path = '/', $domain = null) @@ -198,8 +204,6 @@ class ResponseHeaderBag extends HeaderBag * @param string $path * @param string $domain * - * @return void - * * @api */ public function clearCookie($name, $path = '/', $domain = null) @@ -208,6 +212,54 @@ class ResponseHeaderBag extends HeaderBag } /** + * Generates a HTTP Content-Disposition field-value. + * + * @param string $disposition One of "inline" or "attachment" + * @param string $filename A unicode string + * @param string $filenameFallback A string containing only ASCII characters that + * is semantically equivalent to $filename. If the filename is already ASCII, + * it can be omitted, or just copied from $filename + * + * @return string A string suitable for use as a Content-Disposition field-value. + * + * @throws \InvalidArgumentException + * @see RFC 6266 + */ + public function makeDisposition($disposition, $filename, $filenameFallback = '') + { + if (!in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) { + throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE)); + } + + if (!$filenameFallback) { + $filenameFallback = $filename; + } + + // filenameFallback is not ASCII. + if (!preg_match('/^[\x20-\x7e]*$/', $filenameFallback)) { + throw new \InvalidArgumentException('The filename fallback must only contain ASCII characters.'); + } + + // percent characters aren't safe in fallback. + if (false !== strpos($filenameFallback, '%')) { + throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.'); + } + + // path separators aren't allowed in either. + if (preg_match('#[/\\\\]#', $filename) || preg_match('#[/\\\\]#', $filenameFallback)) { + throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.'); + } + + $output = sprintf('%s; filename="%s"', $disposition, str_replace(array('\\', '"'), array('\\\\', '\\"'), $filenameFallback)); + + if ($filename != $filenameFallback) { + $output .= sprintf("; filename*=utf-8''%s", str_replace(array("'", '(', ')', '*'), array('%27', '%28', '%29', '%2A'), urlencode($filename))); + } + + return $output; + } + + /** * Returns the calculated value of the cache-control header. * * This considers several other headers and calculates or modifies the diff --git a/core/vendor/Symfony/Component/HttpFoundation/ServerBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php similarity index 94% rename from core/vendor/Symfony/Component/HttpFoundation/ServerBag.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php index 9cb7786..9b57f9e 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/ServerBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php @@ -19,6 +19,11 @@ namespace Symfony\Component\HttpFoundation; */ class ServerBag extends ParameterBag { + /** + * Gets the HTTP headers. + * + * @return string + */ public function getHeaders() { $headers = array(); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php new file mode 100644 index 0000000..d1bcb0f --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php @@ -0,0 +1,137 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Attribute; + +/** + * This class relates to session attribute storage + */ +class AttributeBag implements AttributeBagInterface +{ + private $name = 'attributes'; + + /** + * @var string + */ + private $storageKey; + + /** + * @var array + */ + protected $attributes = array(); + + /** + * Constructor. + * + * @param string $storageKey The key used to store flashes in the session. + */ + public function __construct($storageKey = '_sf2_attributes') + { + $this->storageKey = $storageKey; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function initialize(array &$attributes) + { + $this->attributes = &$attributes; + } + + /** + * {@inheritdoc} + */ + public function getStorageKey() + { + return $this->storageKey; + } + + /** + * {@inheritdoc} + */ + public function has($name) + { + return array_key_exists($name, $this->attributes); + } + + /** + * {@inheritdoc} + */ + public function get($name, $default = null) + { + return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; + } + + /** + * {@inheritdoc} + */ + public function set($name, $value) + { + $this->attributes[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function all() + { + return $this->attributes; + } + + /** + * {@inheritdoc} + */ + public function replace(array $attributes) + { + $this->attributes = array(); + foreach ($attributes as $key => $value) { + $this->set($key, $value); + } + } + + /** + * {@inheritdoc} + */ + public function remove($name) + { + $retval = null; + if (array_key_exists($name, $this->attributes)) { + $retval = $this->attributes[$name]; + unset($this->attributes[$name]); + } + + return $retval; + } + + /** + * {@inheritdoc} + */ + public function clear() + { + $return = $this->attributes; + $this->attributes = array(); + + return $return; + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php new file mode 100644 index 0000000..ec6d93c --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Attribute; + +use Symfony\Component\HttpFoundation\Session\SessionBagInterface; + +/** + * Attributes store. + * + * @author Drak + */ +interface AttributeBagInterface extends SessionBagInterface +{ + /** + * Checks if an attribute is defined. + * + * @param string $name The attribute name + * + * @return Boolean true if the attribute is defined, false otherwise + */ + function has($name); + + /** + * Returns an attribute. + * + * @param string $name The attribute name + * @param mixed $default The default value if not found. + * + * @return mixed + */ + function get($name, $default = null); + + /** + * Sets an attribute. + * + * @param string $name + * @param mixed $value + */ + function set($name, $value); + + /** + * Returns attributes. + * + * @return array Attributes + */ + function all(); + + /** + * Sets attributes. + * + * @param array $attributes Attributes + */ + function replace(array $attributes); + + /** + * Removes an attribute. + * + * @param string $name + * + * @return mixed The removed value + */ + function remove($name); +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php new file mode 100644 index 0000000..138aa36 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php @@ -0,0 +1,154 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Attribute; + +/** + * This class provides structured storage of session attributes using + * a name spacing character in the key. + * + * @author Drak + */ +class NamespacedAttributeBag extends AttributeBag +{ + /** + * Namespace character. + * + * @var string + */ + private $namespaceCharacter; + + /** + * Constructor. + * + * @param string $storageKey Session storage key. + * @param string $namespaceCharacter Namespace character to use in keys. + */ + public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/') + { + $this->namespaceCharacter = $namespaceCharacter; + parent::__construct($storageKey); + } + + /** + * {@inheritdoc} + */ + public function has($name) + { + $attributes = $this->resolveAttributePath($name); + $name = $this->resolveKey($name); + + return array_key_exists($name, $attributes); + } + + /** + * {@inheritdoc} + */ + public function get($name, $default = null) + { + $attributes = $this->resolveAttributePath($name); + $name = $this->resolveKey($name); + + return array_key_exists($name, $attributes) ? $attributes[$name] : $default; + } + + /** + * {@inheritdoc} + */ + public function set($name, $value) + { + $attributes = & $this->resolveAttributePath($name, true); + $name = $this->resolveKey($name); + $attributes[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function remove($name) + { + $retval = null; + $attributes = & $this->resolveAttributePath($name); + $name = $this->resolveKey($name); + if (array_key_exists($name, $attributes)) { + $retval = $attributes[$name]; + unset($attributes[$name]); + } + + return $retval; + } + + /** + * Resolves a path in attributes property and returns it as a reference. + * + * This method allows structured namespacing of session attributes. + * + * @param string $name Key name + * @param boolean $writeContext Write context, default false + * + * @return array + */ + protected function &resolveAttributePath($name, $writeContext = false) + { + $array = & $this->attributes; + $name = (strpos($name, $this->namespaceCharacter) === 0) ? substr($name, 1) : $name; + + // Check if there is anything to do, else return + if (!$name) { + return $array; + } + + $parts = explode($this->namespaceCharacter, $name); + if (count($parts) < 2) { + if (!$writeContext) { + return $array; + } + + $array[$parts[0]] = array(); + + return $array; + } + + unset($parts[count($parts)-1]); + + foreach ($parts as $part) { + if (!array_key_exists($part, $array)) { + if (!$writeContext) { + return $array; + } + + $array[$part] = array(); + } + + $array = & $array[$part]; + } + + return $array; + } + + /** + * Resolves the key from the name. + * + * This is the last part in a dot separated string. + * + * @param string $name + * + * @return string + */ + protected function resolveKey($name) + { + if (strpos($name, $this->namespaceCharacter) !== false) { + $name = substr($name, strrpos($name, $this->namespaceCharacter)+1, strlen($name)); + } + + return $name; + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php new file mode 100644 index 0000000..1025784 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php @@ -0,0 +1,171 @@ + + * + * 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; + +/** + * AutoExpireFlashBag flash message container. + * + * @author Drak + */ +class AutoExpireFlashBag implements FlashBagInterface +{ + private $name = 'flashes'; + + /** + * Flash messages. + * + * @var array + */ + private $flashes = array(); + + /** + * The storage key for flashes in the session + * + * @var string + */ + private $storageKey; + + /** + * Constructor. + * + * @param string $storageKey The key used to store flashes in the session. + */ + public function __construct($storageKey = '_sf2_flashes') + { + $this->storageKey = $storageKey; + $this->flashes = array('display' => array(), 'new' => array()); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function initialize(array &$flashes) + { + $this->flashes = &$flashes; + + // The logic: messages from the last request will be stored in new, so we move them to previous + // This request we will show what is in 'display'. What is placed into 'new' this time round will + // be moved to display next time round. + $this->flashes['display'] = array_key_exists('new', $this->flashes) ? $this->flashes['new'] : array(); + $this->flashes['new'] = array(); + } + + /** + * {@inheritdoc} + */ + public function peek($type, $default = null) + { + return $this->has($type) ? $this->flashes['display'][$type] : $default; + } + + /** + * {@inheritdoc} + */ + public function peekAll() + { + return array_key_exists('display', $this->flashes) ? (array)$this->flashes['display'] : array(); + } + + /** + * {@inheritdoc} + */ + public function get($type, $default = null) + { + $return = $default; + + if (!$this->has($type)) { + return $return; + } + + if (isset($this->flashes['display'][$type])) { + $return = $this->flashes['display'][$type]; + unset($this->flashes['display'][$type]); + } + + return $return; + } + + /** + * {@inheritdoc} + */ + public function all() + { + $return = $this->flashes['display']; + $this->flashes = array('new' => array(), 'display' => array()); + + return $return; + } + + /** + * {@inheritdoc} + */ + public function setAll(array $messages) + { + $this->flashes['new'] = $messages; + } + + /** + * {@inheritdoc} + */ + public function set($type, $message) + { + $this->flashes['new'][$type] = $message; + } + + /** + * {@inheritdoc} + */ + public function has($type) + { + return array_key_exists($type, $this->flashes['display']); + } + + /** + * {@inheritdoc} + */ + public function keys() + { + return array_keys($this->flashes['display']); + } + + /** + * {@inheritdoc} + */ + public function getStorageKey() + { + return $this->storageKey; + } + + /** + * {@inheritdoc} + */ + public function clear() + { + $return = $this->all(); + $this->flashes = array('display' => array(), 'new' => array()); + + return $return; + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php new file mode 100644 index 0000000..c0b4ee5 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -0,0 +1,158 @@ + + * + * 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; + +/** + * FlashBag flash message container. + * + * @author Drak + */ +class FlashBag implements FlashBagInterface +{ + private $name = 'flashes'; + + /** + * Flash messages. + * + * @var array + */ + private $flashes = array(); + + /** + * The storage key for flashes in the session + * + * @var string + */ + private $storageKey; + + /** + * Constructor. + * + * @param string $storageKey The key used to store flashes in the session. + */ + public function __construct($storageKey = '_sf2_flashes') + { + $this->storageKey = $storageKey; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function initialize(array &$flashes) + { + $this->flashes = &$flashes; + } + + /** + * {@inheritdoc} + */ + public function peek($type, $default = null) + { + return $this->has($type) ? $this->flashes[$type] : $default; + } + + /** + * {@inheritdoc} + */ + public function peekAll() + { + return $this->flashes; + } + + /** + * {@inheritdoc} + */ + public function get($type, $default = null) + { + if (!$this->has($type)) { + return $default; + } + + $return = $this->flashes[$type]; + + unset($this->flashes[$type]); + + return $return; + } + + /** + * {@inheritdoc} + */ + public function all() + { + $return = $this->peekAll(); + $this->flashes = array(); + + return $return; + } + + /** + * {@inheritdoc} + */ + public function set($type, $message) + { + $this->flashes[$type] = $message; + } + + /** + * {@inheritdoc} + */ + public function setAll(array $messages) + { + $this->flashes = $messages; + } + + /** + * {@inheritdoc} + */ + public function has($type) + { + return array_key_exists($type, $this->flashes); + } + + /** + * {@inheritdoc} + */ + public function keys() + { + return array_keys($this->flashes); + } + + /** + * {@inheritdoc} + */ + public function getStorageKey() + { + return $this->storageKey; + } + + /** + * {@inheritdoc} + */ + public function clear() + { + return $this->all(); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php new file mode 100644 index 0000000..0c45d74 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php @@ -0,0 +1,85 @@ + + * + * 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 +{ + /** + * 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 string $default Default value if $type doee not exist. + * + * @return string + */ + function peek($type, $default = null); + + /** + * Gets all flash messages. + * + * @return array + */ + function peekAll(); + + /** + * Gets and clears flash from the stack. + * + * @param string $type + * @param string $default Default value if $type doee not exist. + * + * @return string + */ + function get($type, $default = null); + + /** + * 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/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php new file mode 100644 index 0000000..63dda8d --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php @@ -0,0 +1,263 @@ + + * + * 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; + +/** + * Session. + * + * @author Fabien Potencier + * @author Drak + * + * @api + */ +class Session implements SessionInterface +{ + /** + * Storage driver. + * + * @var SessionStorageInterface + */ + protected $storage; + + /** + * 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, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) + { + $this->storage = $storage; + $this->registerBag($attributes ?: new AttributeBag()); + $this->registerBag($flashes ?: new FlashBag()); + } + + /** + * {@inheritdoc} + */ + public function start() + { + return $this->storage->start(); + } + + /** + * {@inheritdoc} + */ + public function has($name) + { + return $this->storage->getBag('attributes')->has($name); + } + + /** + * {@inheritdoc} + */ + public function get($name, $default = null) + { + return $this->storage->getBag('attributes')->get($name, $default); + } + + /** + * {@inheritdoc} + */ + public function set($name, $value) + { + $this->storage->getBag('attributes')->set($name, $value); + } + + /** + * {@inheritdoc} + */ + public function all() + { + return $this->storage->getBag('attributes')->all(); + } + + /** + * {@inheritdoc} + */ + public function replace(array $attributes) + { + $this->storage->getBag('attributes')->replace($attributes); + } + + /** + * {@inheritdoc} + */ + public function remove($name) + { + return $this->storage->getBag('attributes')->remove($name); + } + + /** + * {@inheritdoc} + */ + public function clear() + { + $this->storage->getBag('attributes')->clear(); + } + + /** + * {@inheritdoc} + */ + public function invalidate() + { + $this->storage->clear(); + + return $this->storage->regenerate(true); + } + + /** + * {@inheritdoc} + */ + public function migrate($destroy = false) + { + return $this->storage->regenerate($destroy); + } + + /** + * {@inheritdoc} + */ + public function save() + { + $this->storage->save(); + } + + /** + * Returns the session ID + * + * @return mixed The session ID + * + * @api + */ + public function getId() + { + return $this->storage->getId(); + } + + /** + * Registers a SessionBagInterface with the sessio. + * + * @param SessionBagInterface $bag + */ + public function registerBag(SessionBagInterface $bag) + { + $this->storage->registerBag($bag); + } + + /** + * Get's a bag instance. + * + * @param string $name + * + * @return SessionBagInterface + */ + public function getBag($name) + { + return $this->storage->getBag($name); + } + + /** + * Gets the flashbag interface. + * + * @return FlashBagInterface + */ + public function getFlashBag() + { + return $this->getBag('flashes'); + } + + // 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() + { + return $this->getBag('flashes')->all(); + } + + /** + * @param array $values + * + * @deprecated since 2.1, will be removed from 2.3 + */ + public function setFlashes($values) + { + $this->getBag('flashes')->setAll($values); + } + + /** + * @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('flashes')->get($name, $default); + } + + /** + * @param string $name + * @param string $value + * + * @deprecated since 2.1, will be removed from 2.3 + */ + public function setFlash($name, $value) + { + $this->getBag('flashes')->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('flashes')->has($name); + } + + /** + * @param string $name + * + * @deprecated since 2.1, will be removed from 2.3 + */ + public function removeFlash($name) + { + $this->getBag('flashes')->get($name); + } + + /** + * @return array + * + * @deprecated since 2.1, will be removed from 2.3 + */ + public function clearFlashes() + { + return $this->getBag('flashes')->clear(); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php new file mode 100644 index 0000000..50c2d4b --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session; + +/** + * Session Bag store. + * + * @author Drak + */ +interface SessionBagInterface +{ + /** + * Gets this bag's name + * + * @return string + */ + function getName(); + + /** + * Initializes the Bag + * + * @param array $array + */ + function initialize(array &$array); + + /** + * Gets the storage key for this bag. + * + * @return string + */ + function getStorageKey(); + + /** + * Clears out data from bag. + * + * @return mixed Whatever data was contained. + */ + function clear(); +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php new file mode 100644 index 0000000..741969b --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php @@ -0,0 +1,131 @@ + + * + * 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(); + + /** + * Invalidates the current session. + * + * Clears all session attributes and flashes and regenerates the + * session and deletes the old session from persistence. + * + * @return Boolean True if session invalidated, false if error. + * + * @api + */ + function invalidate(); + + /** + * 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. + * + * @return Boolean True if session migrated, false if error. + * + * @api + */ + function migrate($destroy = false); + + /** + * 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(); +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php new file mode 100644 index 0000000..9fcabab --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php @@ -0,0 +1,326 @@ + + * + * 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; + +/** + * This provides a base class for session attribute storage. + * + * @author Drak + */ +abstract class AbstractSessionStorage implements SessionStorageInterface +{ + /** + * Array of SessionBagInterface + * + * @var array + */ + protected $bags; + + /** + * @var array + */ + protected $options = array(); + + /** + * @var boolean + */ + protected $started = false; + + /** + * @var boolean + */ + protected $closed = false; + + /** + * 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://www.php.net/manual/en/session.configuration.php for options + * but we omit 'session.' from the beginning of the keys. + * + * auto_start, "0" + * cache_limiter, "" + * 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, "" + * save_path, "" + * 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. + */ + public function __construct(array $options = array()) + { + $this->setOptions($options); + $this->registerSaveHandlers(); + $this->registerShutdownFunction(); + } + + /** + * {@inheritdoc} + */ + public function start() + { + if ($this->started && !$this->closed) { + return true; + } + + if ($this->options['use_cookies'] && headers_sent()) { + throw new \RuntimeException('Failed to start the session because header have already been sent.'); + } + + // start the session + if (!session_start()) { + throw new \RuntimeException('Failed to start the session'); + } + + $this->loadSession(); + + $this->started = true; + $this->closed = false; + + return true; + } + + /** + * {@inheritdoc} + */ + public function getId() + { + if (!$this->started) { + return ''; // returning empty is consistent with session_id() behaviour + } + + return session_id(); + } + + /** + * {@inheritdoc} + */ + public function regenerate($destroy = false) + { + return session_regenerate_id($destroy); + } + + /** + * {@inheritdoc} + */ + public function save() + { + session_write_close(); + $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 ($this->options['auto_start'] && !$this->started) { + $this->start(); + } + + return $this->bags[$name]; + } + + /** + * Sets session.* ini variables. + * + * For convenience we omit 'session.' from the beginning of the keys. + * Explicitly ignores other ini keys. + * + * session_get_cookie_params() overrides values. + * + * @param array $options + * + * @see http://www.php.net/manual/en/session.configuration.php + */ + protected function setOptions(array $options) + { + $cookieDefaults = session_get_cookie_params(); + $this->options = array_merge(array( + 'cookie_lifetime' => $cookieDefaults['lifetime'], + 'cookie_path' => $cookieDefaults['path'], + 'cookie_domain' => $cookieDefaults['domain'], + 'cookie_secure' => $cookieDefaults['secure'], + 'cookie_httponly' => isset($cookieDefaults['httponly']) ? $cookieDefaults['httponly'] : false, + ), $options); + + // Unless session.cache_limiter has been set explicitly, disable it + // because this is managed by HeaderBag directly (if used). + if (!isset($this->options['cache_limiter'])) { + $this->options['cache_limiter'] = false; + } + + if (!isset($this->options['auto_start'])) { + $this->options['auto_start'] = 0; + } + + if (!isset($this->options['use_cookies'])) { + $this->options['use_cookies'] = 1; + } + + foreach ($this->options as $key => $value) { + if (in_array($key, 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', + 'save_path', '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'))) { + ini_set('session.'.$key, $value); + } + } + } + + /** + * Registers this storage device for PHP session handling. + * + * PHP requires session save handlers to be set, either it's own, or custom ones. + * There are some defaults set automatically when PHP starts, but these can be overriden + * using this command if you need anything other than PHP's default handling. + * + * When the session starts, PHP will call the sessionRead() handler which should return an array + * of any session attributes. PHP will then populate these into $_SESSION. + * + * When PHP shuts down, the write() handler is called and will pass the $_SESSION contents + * to be stored. + * + * When a session is specifically destroyed, PHP will call the destroy() handler with the + * session ID. This happens when the session is regenerated for example and th handler + * MUST delete the session by ID from the persistent storage immediately. + * + * PHP will call gc() from time to time to expire any session records according to the + * set max lifetime of a session. This routine should delete all records from persistent + * storage which were last accessed longer than the $lifetime. + * + * PHP open() and close() are pretty much redundant and can just return true. + * + * NOTE: + * + * To use PHP native 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/manual/en/function.session-set-save-handler.php + * @see \SessionHandlerInterface + * @see http://php.net/manual/en/class.sessionhandlerinterface.php + */ + protected function registerSaveHandlers() + { + // note this can be reset to PHP's control using ini_set('session.save_handler', 'files'); + // so long as ini_set() is called before the session is started. + if ($this instanceof \SessionHandlerInterface) { + session_set_save_handler( + array($this, 'open'), + array($this, 'close'), + array($this, 'read'), + array($this, 'write'), + array($this, 'destroy'), + array($this, 'gc') + ); + } + } + + /** + * Registers PHP shutdown function. + * + * This method is required to avoid strange issues when using PHP objects as + * session save handlers. + */ + protected function registerShutdownFunction() + { + register_shutdown_function('session_write_close'); + } + + /** + * Load the session with attributes. + * + * After starting the session, PHP retrieves the session from whatever handlers + * are set to (either PHP's internal, custom set with session_set_save_handler()). + * PHP takes the return value from the sessionRead() 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; + } + + foreach ($this->bags as $bag) { + $key = $bag->getStorageKey(); + $session[$key] = isset($session[$key]) ? $session[$key] : array(); + $bag->initialize($session[$key]); + } + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MemcacheSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MemcacheSessionStorage.php new file mode 100644 index 0000000..c9b0ca5 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MemcacheSessionStorage.php @@ -0,0 +1,143 @@ + + * + * 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; + +/** + * MemcacheSessionStorage. + * + * @author Drak + */ +class MemcacheSessionStorage extends AbstractSessionStorage 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 Memcachge options + * @param array $options Session configuration options. + * + * @see AbstractSessionStorage::__construct() + */ + 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; + + parent::__construct($options); + } + + 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) + { + return $this->memcache->set($this->prefix.$sessionId, $data, 0, $this->memcacheOptions['expiretime']); + } + + /** + * {@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/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php new file mode 100644 index 0000000..46da898 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php @@ -0,0 +1,129 @@ + + * + * 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; + +/** + * MemcachedSessionStorage. + * + * @author Drak + */ +class MemcachedSessionStorage extends AbstractSessionStorage 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. + * + * @see AbstractSessionStorage::__construct() + */ + 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; + + parent::__construct($options); + } + + /** + * {@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/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php new file mode 100644 index 0000000..2447418 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php @@ -0,0 +1,124 @@ + + * + * 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; + +/** + * 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 extends AbstractSessionStorage +{ + /** + * @var string + */ + protected $sessionId; + + /** + * @var array + */ + protected $sessionData = array(); + + public function setSessionData(array $array) + { + $this->sessionData = $array; + } + + /** + * {@inheritdoc} + */ + public function start() + { + if ($this->started && !$this->closed) { + return true; + } + + $this->started = true; + $this->loadSession($this->sessionData); + + $this->sessionId = $this->generateSessionId(); + session_id($this->sessionId); + + return true; + } + + + /** + * {@inheritdoc} + */ + public function regenerate($destroy = false) + { + if ($this->options['auto_start'] && !$this->started) { + $this->start(); + } + + $this->sessionId = $this->generateSessionId(); + session_id($this->sessionId); + + return true; + } + + /** + * {@inheritdoc} + */ + public function getId() + { + if (!$this->started) { + return ''; + } + + return $this->sessionId; + } + + /** + * {@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->sessionData = array(); + + // reconnect the bags to the session + $this->loadSession($this->sessionData); + } + + /** + * Generates a session ID. + * + * @return string + */ + protected function generateSessionId() + { + return sha1(uniqid(mt_rand(), true)); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php new file mode 100644 index 0000000..094c4d6 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php @@ -0,0 +1,136 @@ + + * + * 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. + * + * @author Drak + */ +class MockFileSessionStorage extends MockArraySessionStorage +{ + /** + * @var string + */ + private $savePath; + + /** + * Constructor. + * + * @param string $savePath Path of directory to save session files. + * @param array $options Session options. + * + * @see AbstractSessionStorage::__construct() + */ + public function __construct($savePath = null, array $options = array()) + { + if (null === $savePath) { + $savePath = sys_get_temp_dir(); + } + + if (!is_dir($savePath)) { + mkdir($savePath, 0777, true); + } + + $this->savePath = $savePath; + + parent::__construct($options); + } + + /** + * {@inheritdoc} + */ + public function start() + { + if ($this->started) { + return true; + } + + if (!session_id()) { + session_id($this->generateSessionId()); + } + + $this->sessionId = session_id(); + + $this->read(); + + $this->started = true; + + return true; + } + + /** + * {@inheritdoc} + */ + public function regenerate($destroy = false) + { + if ($destroy) { + $this->destroy(); + } + + session_id($this->generateSessionId()); + $this->sessionId = session_id(); + + $this->save(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function getId() + { + if (!$this->started) { + return ''; + } + + return $this->sessionId; + } + + /** + * {@inheritdoc} + */ + public function save() + { + file_put_contents($this->getFilePath(), serialize($this->sessionData)); + } + + private function destroy() + { + if (is_file($this->getFilePath())) { + unlink($this->getFilePath()); + } + } + + /** + * Calculate path to file. + * + * @return string File path + */ + public function getFilePath() + { + return $this->savePath.'/'.$this->sessionId.'.sess'; + } + + private function read() + { + $filePath = $this->getFilePath(); + $this->sessionData = is_readable($filePath) && is_file($filePath) ? unserialize(file_get_contents($filePath)) : array(); + + $this->loadSession($this->sessionData); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php new file mode 100644 index 0000000..09350e8 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php @@ -0,0 +1,59 @@ + + * + * 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; + +/** + * NativeFileSessionStorage. + * + * Native session handler using PHP's built in file storage. + * + * @author Drak + */ +class NativeFileSessionStorage extends AbstractSessionStorage +{ + /** + * @var string + */ + private $savePath; + + /** + * Constructor. + * + * @param string $savePath Path of directory to save session files. + * @param array $options Session configuration options. + * + * @see AbstractSessionStorage::__construct() + */ + public function __construct($savePath = null, array $options = array()) + { + if (null === $savePath) { + $savePath = sys_get_temp_dir(); + } + + if (!is_dir($savePath)) { + mkdir($savePath, 0777, true); + } + + $this->savePath = $savePath; + + parent::__construct($options); + } + + /** + * {@inheritdoc} + */ + protected function registerSaveHandlers() + { + ini_set('session.save_handler', 'files'); + ini_set('session.save_path', $this->savePath); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php new file mode 100644 index 0000000..5572c47 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php @@ -0,0 +1,77 @@ + + * + * 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; + +/** + * NativeMemcacheSessionStorage. + * + * Session based on native PHP memcache database handler. + * + * @author Drak + */ +class NativeMemcacheSessionStorage extends AbstractSessionStorage +{ + /** + * @var string + */ + private $savePath; + + /** + * Constructor. + * + * @param string $savePath Path of memcache server. + * @param array $options Session configuration options. + * + * @see AbstractSessionStorage::__construct() + */ + 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'); + } + + $this->savePath = $savePath; + parent::__construct($options); + } + + /** + * {@inheritdoc} + */ + protected function registerSaveHandlers() + { + ini_set('session.save_handler', 'memcache'); + ini_set('session.save_path', $this->savePath); + } + + /** + * {@inheritdoc} + * + * Sets any values memcached ini values. + * + * @see http://www.php.net/manual/en/memcache.ini.php + */ + protected function setOptions(array $options) + { + foreach ($options as $key => $value) { + if (in_array($key, 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'))) { + ini_set($key, $value); + } + } + + parent::setOptions($options); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php new file mode 100644 index 0000000..50d8d06 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php @@ -0,0 +1,76 @@ + + * + * 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; + +/** + * NativeMemcachedSessionStorage. + * + * Session based on native PHP memcached database handler. + * + * @author Drak + */ +class NativeMemcachedSessionStorage extends AbstractSessionStorage +{ + /** + * @var string + */ + private $savePath; + + /** + * 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. + * + * @see AbstractSessionStorage::__construct() + */ + 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'); + } + + $this->savePath = $savePath; + parent::__construct($options); + } + + /** + * {@inheritdoc} + */ + protected function registerSaveHandlers() + { + ini_set('session.save_handler', 'memcached'); + ini_set('session.save_path', $this->savePath); + } + + /** + * {@inheritdoc} + * + * Sets any values memcached ini values. + * + * @see https://github.com/php-memcached-dev/php-memcached/blob/master/memcached.ini + */ + protected function setOptions(array $options) + { + foreach ($options as $key => $value) { + if (in_array($key, array( + 'memcached.sess_locking', 'memcached.sess_lock_wait', + 'memcached.sess_prefix', 'memcached.compression_type', + 'memcached.compression_factor', 'memcached.compression_threshold', + 'memcached.serializer'))) { + ini_set($key, $value); + } + } + + parent::setOptions($options); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php new file mode 100644 index 0000000..1dac36a --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php @@ -0,0 +1,54 @@ + + * + * 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; + +/** + * NativeSqliteSessionStorage. + * + * Session based on native PHP sqlite database handler. + * + * @author Drak + */ +class NativeSqliteSessionStorage extends AbstractSessionStorage +{ + /** + * @var string + */ + private $dbPath; + + /** + * Constructor. + * + * @param string $dbPath Path to SQLite database file. + * @param array $options Session configuration options. + * + * @see AbstractSessionStorage::__construct() + */ + public function __construct($dbPath, array $options = array()) + { + if (!extension_loaded('sqlite')) { + throw new \RuntimeException('PHP does not have "sqlite" session module registered'); + } + + $this->dbPath = $dbPath; + parent::__construct($options); + } + + /** + * {@inheritdoc} + */ + protected function registerSaveHandlers() + { + ini_set('session.save_handler', 'sqlite'); + ini_set('session.save_path', $this->dbPath); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php new file mode 100644 index 0000000..8f45a6e --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php @@ -0,0 +1,72 @@ + + * + * 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; + +/** + * NullSessionStorage. + * + * Can be used in unit testing or in a sitation where persisted sessions are not desired. + * + * @author Drak + * + * @api + */ +class NullSessionStorage extends AbstractSessionStorage 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/SessionStorage/PdoSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PdoSessionStorage.php similarity index 63% rename from core/vendor/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PdoSessionStorage.php index 09d032a..da76694 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PdoSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\SessionStorage; +namespace Symfony\Component\HttpFoundation\Session\Storage; /** * PdoSessionStorage. @@ -17,29 +17,42 @@ namespace Symfony\Component\HttpFoundation\SessionStorage; * @author Fabien Potencier * @author Michael Williams */ -class PdoSessionStorage extends NativeSessionStorage +class PdoSessionStorage extends AbstractSessionStorage implements \SessionHandlerInterface { - private $db; + /** + * PDO instance. + * + * @var \PDO + */ + private $pdo; + + /** + * Database options. + * + * + * @var array + */ private $dbOptions; /** * Constructor. * - * @param \PDO $db A PDO instance - * @param array $options An associative array of session options - * @param array $dbOptions An associative array of DB options + * + * @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 * - * @see NativeSessionStorage::__construct() + * @see AbstractSessionStorage::__construct() */ - public function __construct(\PDO $db, array $options = array(), array $dbOptions = array()) + 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->db = $db; + $this->pdo = $pdo; $this->dbOptions = array_merge(array( 'db_id_col' => 'sess_id', 'db_data_col' => 'sess_data', @@ -50,61 +63,25 @@ class PdoSessionStorage extends NativeSessionStorage } /** - * Starts the session. - */ - public function start() - { - if (self::$sessionStarted) { - return; - } - - // use this object as the session handler - session_set_save_handler( - array($this, 'sessionOpen'), - array($this, 'sessionClose'), - array($this, 'sessionRead'), - array($this, 'sessionWrite'), - array($this, 'sessionDestroy'), - array($this, 'sessionGC') - ); - - parent::start(); - } - - /** - * Opens a session. - * - * @param string $path (ignored) - * @param string $name (ignored) - * - * @return Boolean true, if the session was opened, otherwise an exception is thrown + * {@inheritdoc} */ - public function sessionOpen($path = null, $name = null) + public function open($path, $name) { return true; } /** - * Closes a session. - * - * @return Boolean true, if the session was closed, otherwise false + * {@inheritdoc} */ - public function sessionClose() + public function close() { - // do nothing return true; } /** - * Destroys a session. - * - * @param string $id A session ID - * - * @return Boolean true, if the session was destroyed, otherwise an exception is thrown - * - * @throws \RuntimeException If the session cannot be destroyed + * {@inheritdoc} */ - public function sessionDestroy($id) + public function destroy($id) { // get table/column $dbTable = $this->dbOptions['db_table']; @@ -114,7 +91,7 @@ class PdoSessionStorage extends NativeSessionStorage $sql = "DELETE FROM $dbTable WHERE $dbIdCol = :id"; try { - $stmt = $this->db->prepare($sql); + $stmt = $this->pdo->prepare($sql); $stmt->bindParam(':id', $id, \PDO::PARAM_STR); $stmt->execute(); } catch (\PDOException $e) { @@ -125,25 +102,19 @@ class PdoSessionStorage extends NativeSessionStorage } /** - * Cleans up old sessions. - * - * @param int $lifetime The lifetime of a session - * - * @return Boolean true, if old sessions have been cleaned, otherwise an exception is thrown - * - * @throws \RuntimeException If any old sessions cannot be cleaned + * {@inheritdoc} */ - public function sessionGC($lifetime) + public function gc($lifetime) { // get table/column $dbTable = $this->dbOptions['db_table']; $dbTimeCol = $this->dbOptions['db_time_col']; - // delete the record associated with this id + // delete the session records that have expired $sql = "DELETE FROM $dbTable WHERE $dbTimeCol < (:time - $lifetime)"; try { - $stmt = $this->db->prepare($sql); + $stmt = $this->pdo->prepare($sql); $stmt->bindValue(':time', time(), \PDO::PARAM_INT); $stmt->execute(); } catch (\PDOException $e) { @@ -154,15 +125,9 @@ class PdoSessionStorage extends NativeSessionStorage } /** - * Reads a session. - * - * @param string $id A session ID - * - * @return string The session data if the session was read or created, otherwise an exception is thrown - * - * @throws \RuntimeException If the session cannot be read + * {@inheritdoc} */ - public function sessionRead($id) + public function read($id) { // get table/columns $dbTable = $this->dbOptions['db_table']; @@ -172,7 +137,7 @@ class PdoSessionStorage extends NativeSessionStorage try { $sql = "SELECT $dbDataCol FROM $dbTable WHERE $dbIdCol = :id"; - $stmt = $this->db->prepare($sql); + $stmt = $this->pdo->prepare($sql); $stmt->bindParam(':id', $id, \PDO::PARAM_STR, 255); $stmt->execute(); @@ -189,21 +154,14 @@ class PdoSessionStorage extends NativeSessionStorage return ''; } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); } } /** - * Writes session data. - * - * @param string $id A session ID - * @param string $data A serialized chunk of session data - * - * @return Boolean true, if the session was written, otherwise an exception is thrown - * - * @throws \RuntimeException If the session data cannot be written + * {@inheritdoc} */ - public function sessionWrite($id, $data) + public function write($id, $data) { // get table/column $dbTable = $this->dbOptions['db_table']; @@ -211,7 +169,7 @@ class PdoSessionStorage extends NativeSessionStorage $dbIdCol = $this->dbOptions['db_id_col']; $dbTimeCol = $this->dbOptions['db_time_col']; - $sql = ('mysql' === $this->db->getAttribute(\PDO::ATTR_DRIVER_NAME)) + $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"; @@ -219,7 +177,7 @@ class PdoSessionStorage extends NativeSessionStorage try { //session data can contain non binary safe characters so we need to encode it $encoded = base64_encode($data); - $stmt = $this->db->prepare($sql); + $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); @@ -231,7 +189,7 @@ class PdoSessionStorage extends NativeSessionStorage $this->createNewSession($id, $data); } } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); } return true; @@ -242,6 +200,8 @@ class PdoSessionStorage extends NativeSessionStorage * * @param string $id * @param string $data + * + * @return boolean True. */ private function createNewSession($id, $data = '') { @@ -255,7 +215,7 @@ class PdoSessionStorage extends NativeSessionStorage //session data can contain non binary safe characters so we need to encode it $encoded = base64_encode($data); - $stmt = $this->db->prepare($sql); + $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); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php new file mode 100644 index 0000000..6065a55 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php @@ -0,0 +1,96 @@ + + * + * 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; + +/** + * 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 mixed The session ID or false if the session has not started. + * + * @api + */ + function getId(); + + /** + * 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. + * + * @param Boolean $destroy Destroy session when regenerating? + * + * @return Boolean True if session regenerated, false if error + * + * @throws \RuntimeException If an error occurs while regenerating this storage + * + * @api + */ + function regenerate($destroy = false); + + /** + * 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); +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php new file mode 100644 index 0000000..5684c3c --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation; + +/** + * StreamedResponse represents a streamed HTTP response. + * + * A StreamedResponse uses a callback for its content. + * + * The callback should use the standard PHP functions like echo + * to stream the response back to the client. The flush() method + * can also be used if needed. + * + * @see flush() + * + * @author Fabien Potencier + * + * @api + */ +class StreamedResponse extends Response +{ + protected $callback; + protected $streamed; + + /** + * Constructor. + * + * @param mixed $callback A valid PHP callback + * @param integer $status The response status code + * @param array $headers An array of response headers + * + * @api + */ + public function __construct($callback = null, $status = 200, $headers = array()) + { + parent::__construct(null, $status, $headers); + + if (null !== $callback) { + $this->setCallback($callback); + } + $this->streamed = false; + } + + /** + * Sets the PHP callback associated with this Response. + * + * @param mixed $callback A valid PHP callback + */ + public function setCallback($callback) + { + $this->callback = $callback; + if (!is_callable($this->callback)) { + throw new \LogicException('The Response callback must be a valid PHP callable.'); + } + } + + /** + * @{inheritdoc} + */ + public function prepare(Request $request) + { + if ('1.0' != $request->server->get('SERVER_PROTOCOL')) { + $this->setProtocolVersion('1.1'); + } + + $this->headers->set('Cache-Control', 'no-cache'); + + parent::prepare($request); + } + + /** + * @{inheritdoc} + * + * This method only sends the content once. + */ + public function sendContent() + { + if ($this->streamed) { + return; + } + + $this->streamed = true; + + if (null === $this->callback) { + throw new \LogicException('The Response callback must not be null.'); + } + + call_user_func($this->callback); + } + + /** + * @{inheritdoc} + * + * @throws \LogicException when the content is not null + */ + public function setContent($content) + { + if (null !== $content) { + throw new \LogicException('The content cannot be set on a StreamedResponse instance.'); + } + } + + /** + * @{inheritdoc} + * + * @return false + */ + public function getContent() + { + return false; + } +} diff --git a/core/vendor/Symfony/Component/HttpFoundation/composer.json b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json similarity index 62% rename from core/vendor/Symfony/Component/HttpFoundation/composer.json rename to core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json index 53e0b10..c2f49aa 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/composer.json +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json @@ -19,7 +19,15 @@ "php": ">=5.3.2" }, "autoload": { - "psr-0": { "Symfony\\Component\\HttpFoundation": "" } + "psr-0": { + "Symfony\\Component\\HttpFoundation": "", + "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stub" + } }, - "target-dir": "Symfony/Component/HttpFoundation" + "target-dir": "Symfony/Component/HttpFoundation", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + } } diff --git a/core/vendor/Symfony/Component/HttpKernel/Bundle/Bundle.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Bundle/Bundle.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Bundle/BundleInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Bundle/BundleInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Client.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Client.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Config/FileLocator.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Config/FileLocator.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolver.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php similarity index 96% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 54d9fac..4029d7c 100644 --- a/core/vendor/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -72,6 +72,7 @@ class RequestDataCollector extends DataCollector '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(), ); } @@ -121,6 +122,11 @@ class RequestDataCollector extends DataCollector return $this->data['session_attributes']; } + public function getFlashes() + { + return $this->data['flashes']; + } + public function getContent() { return $this->data['content']; diff --git a/core/vendor/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php similarity index 85% rename from core/vendor/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index bdeb84c..a91e91c 100644 --- a/core/vendor/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -68,14 +68,13 @@ class TimeDataCollector extends DataCollector /** * Gets the request elapsed time. * - * @return integer The elapsed time + * @return float The elapsed time */ public function getTotalTime() { - $values = array_values($this->data['events']); - $lastEvent = $values[count($values) - 1]; + $lastEvent = $this->data['events']['__section__']; - return $lastEvent->getOrigin() + $lastEvent->getEndTime() - $this->data['start_time']; + return $lastEvent->getOrigin() + $lastEvent->getTotalTime() - $this->data['start_time']; } /** @@ -83,11 +82,11 @@ class TimeDataCollector extends DataCollector * * This is the time spent until the beginning of the request handling. * - * @return integer The elapsed time + * @return float The elapsed time */ public function getInitTime() { - return $this->data['events']['section']->getOrigin() - $this->getStartTime(); + return $this->data['events']['__section__']->getOrigin() - $this->getStartTime(); } /** diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/ErrorHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Debug/ErrorHandler.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php new file mode 100644 index 0000000..63e14e2 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/Stopwatch.php @@ -0,0 +1,251 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Symfony\Component\HttpKernel\Debug; + +/** + * Stopwatch provides a way to profile code. + * + * @author Fabien Potencier + */ +class Stopwatch +{ + private $sections; + private $activeSections; + + public function __construct() + { + $this->sections = $this->activeSections = array('__root__' => new Section('__root__')); + } + + /** + * Creates a new section or re-opens an existing section. + * + * @param string|null $id The id of the session to re-open, null to create a new one + * + * @throws \LogicException When the section to re-open is not reachable + */ + public function openSection($id = null) + { + $current = end($this->activeSections); + + if (null !== $id && null === $current->get($id)) { + throw new \LogicException(sprintf('The section "%s" has been started at an other level and can not be opened.', $id)); + } + + $this->start('__section__.child', 'section'); + $this->activeSections[] = $current->open($id); + $this->start('__section__'); + } + + /** + * Stops the last started section. + * + * The id parameter is used to retrieve the events from this section. + * + * @see getSectionEvents + * + * @param string $id The identifier of the section + */ + public function stopSection($id) + { + $this->stop('__section__'); + + if (1 == count($this->activeSections)) { + throw new \LogicException('There is no started section to stop.'); + } + + $this->sections[$id] = array_pop($this->activeSections)->setId($id); + $this->stop('__section__.child'); + } + + /** + * Starts an event. + * + * @param string $name The event name + * @param string $category The event category + * + * @return StopwatchEvent A StopwatchEvent instance + */ + public function start($name, $category = null) + { + return end($this->activeSections)->startEvent($name, $category); + } + + /** + * Stops an event. + * + * @param string $name The event name + * + * @return StopwatchEvent A StopwatchEvent instance + */ + public function stop($name) + { + return end($this->activeSections)->stopEvent($name); + } + + /** + * Stops then restarts an event. + * + * @param string $name The event name + * + * @return StopwatchEvent A StopwatchEvent instance + */ + public function lap($name) + { + return end($this->activeSections)->stopEvent($name)->start(); + } + + /** + * Gets all events for a given section. + * + * @param string $id A section identifier + * + * @return StopwatchEvent[] An array of StopwatchEvent instances + */ + public function getSectionEvents($id) + { + return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : array(); + } +} + +class Section +{ + private $events = array(); + private $origin; + private $id; + private $children = array(); + + /** + * Constructor. + * + * @param float|null $origin Set the origin of the events in this section, use null to set their origin to their start time + */ + public function __construct($origin = null) + { + $this->origin = is_numeric($origin) ? $origin : null; + } + + /** + * Returns the child section. + * + * @param string $id The child section identifier + * + * @return Section|null The child section or null when none found + */ + public function get($id) + { + foreach ($this->children as $child) { + if ($id === $child->getId()) { + return $child; + } + } + + return null; + } + + /** + * Creates or re-opens a child section. + * + * @param string|null $id null to create a new section, the identifier to re-open an existing one. + * + * @return Section A child section + */ + public function open($id) + { + if (null === $session = $this->get($id)) { + $session = $this->children[] = new self(microtime(true) * 1000); + } + + return $session; + } + + /** + * @return string The identifier of the section + */ + public function getId() + { + return $this->id; + } + + /** + * Sets the session identifier. + * + * @param string $id The session identifier + * + * @return Section The current section + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Starts an event. + * + * @param string $name The event name + * @param string $category The event category + * + * @return StopwatchEvent The event + */ + public function startEvent($name, $category) + { + if (!isset($this->events[$name])) { + $this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category); + } + + return $this->events[$name]->start(); + } + + /** + * Stops an event. + * + * @param string $name The event name + * + * @return StopwatchEvent The event + * + * @throws \LogicException When the event has not been started + */ + public function stopEvent($name) + { + if (!isset($this->events[$name])) { + throw new \LogicException(sprintf('Event "%s" is not started.', $name)); + } + + return $this->events[$name]->stop(); + } + + /** + * Stops then restarts an event. + * + * @param string $name The event name + * + * @return StopwatchEvent The event + * + * @throws \LogicException When the event has not been started + */ + public function lap($name) + { + return $this->stop($name)->start(); + } + + /** + * Returns the events from this section. + * + * @return StopwatchEvent[] An array of StopwatchEvent instances + */ + public function getEvents() + { + return $this->events; + } +} diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php similarity index 91% rename from core/vendor/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php index f606f1b..70b6a5e 100644 --- a/core/vendor/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/StopwatchEvent.php @@ -26,7 +26,7 @@ class StopwatchEvent /** * Constructor. * - * @param integer $origin The origin time in milliseconds + * @param float $origin The origin time in milliseconds * @param string $category The event category * * @throws \InvalidArgumentException When the raw time is not valid @@ -62,7 +62,7 @@ class StopwatchEvent /** * Starts a new event period. * - * @return StopwatchEvent The event. + * @return StopwatchEvent The event */ public function start() { @@ -74,7 +74,7 @@ class StopwatchEvent /** * Stops the last started event period. * - * @return StopwatchEvent The event. + * @return StopwatchEvent The event */ public function stop() { @@ -90,7 +90,7 @@ class StopwatchEvent /** * Stops the current period and then starts a new one. * - * @return StopwatchEvent The event. + * @return StopwatchEvent The event */ public function lap() { @@ -152,7 +152,12 @@ class StopwatchEvent return $this->formatTime($total); } - private function getNow() + /** + * Return the current time relative to origin. + * + * @return float Time in ms + */ + protected function getNow() { return $this->formatTime(microtime(true) * 1000 - $this->origin); } diff --git a/core/vendor/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DependencyInjection/Extension.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DependencyInjection/Extension.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php diff --git a/core/vendor/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/GetResponseEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/KernelEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/KernelEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Event/PostResponseEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Event/PostResponseEvent.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/EsiListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/EsiListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/LocaleListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php similarity index 87% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index aa78dba..dbbb441 100644 --- a/core/vendor/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -87,14 +87,15 @@ class ProfilerListener implements EventSubscriberInterface return; } + $request = $event->getRequest(); $exception = $this->exception; $this->exception = null; - if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) { + if (null !== $this->matcher && !$this->matcher->matches($request)) { return; } - if (!$profile = $this->profiler->collect($event->getRequest(), $event->getResponse(), $exception)) { + if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) { return; } @@ -102,25 +103,20 @@ class ProfilerListener implements EventSubscriberInterface if (!$master) { array_pop($this->requests); - $parent = $this->requests[count($this->requests) - 1]; - if (!isset($this->children[$parent])) { - $profiles = array($profile); - } else { - $profiles = $this->children[$parent]; - $profiles[] = $profile; - } - + $parent = end($this->requests); + $profiles = isset($this->children[$parent]) ? $this->children[$parent] : array(); + $profiles[] = $profile; $this->children[$parent] = $profiles; } // store the profile and its children - if (isset($this->children[$event->getRequest()])) { - foreach ($this->children[$event->getRequest()] as $child) { + if (isset($this->children[$request])) { + foreach ($this->children[$request] as $child) { $child->setParent($profile); $profile->addChild($child); $this->profiler->saveProfile($child); } - $this->children[$event->getRequest()] = array(); + $this->children[$request] = array(); } $this->profiler->saveProfile($profile); diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/ResponseListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/ResponseListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php similarity index 98% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/RouterListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php index a352685..5d5a543 100644 --- a/core/vendor/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -61,6 +61,7 @@ class RouterListener implements EventSubscriberInterface $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()); diff --git a/core/vendor/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/FlattenException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Exception/FlattenException.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/HttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Exception/HttpException.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/Esi.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpCache/Esi.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpCache/HttpCache.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/Store.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpCache/Store.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpKernel.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php diff --git a/core/vendor/Symfony/Component/HttpKernel/HttpKernelInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/HttpKernelInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Kernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Kernel.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php diff --git a/core/vendor/Symfony/Component/HttpKernel/KernelEvents.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/KernelEvents.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php diff --git a/core/vendor/Symfony/Component/HttpKernel/KernelInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/KernelInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php diff --git a/core/vendor/Symfony/Component/EventDispatcher/LICENSE b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE similarity index 96% rename from core/vendor/Symfony/Component/EventDispatcher/LICENSE rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE index 89df448..cdffe7a 100644 --- a/core/vendor/Symfony/Component/EventDispatcher/LICENSE +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2011 Fabien Potencier +Copyright (c) 2004-2012 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/vendor/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Log/LoggerInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Log/LoggerInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Log/NullLogger.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Log/NullLogger.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php new file mode 100644 index 0000000..7b015da --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php @@ -0,0 +1,260 @@ + + * + * 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; + } + + return array_values($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/FileProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php new file mode 100644 index 0000000..fdf5ff0 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php @@ -0,0 +1,100 @@ + + * + * 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('Please check your configuration. You are trying to use Memcache with an invalid dsn. "' . $this->dsn . '"'); + } + + $host = $matches[1]; + $port = $matches[2]; + + $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/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php new file mode 100644 index 0000000..32f6331 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php @@ -0,0 +1,95 @@ + + * + * 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('Please check your configuration. You are trying to use Memcached with an invalid dsn. "' . $this->dsn . '"'); + } + + $host = $matches[1]; + $port = $matches[2]; + + $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/MongoDbProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php similarity index 94% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php index c87b871..8e2bea4 100644 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php @@ -91,22 +91,16 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface ':created_at' => time(), ); - if ($this->read($profile->getToken())) { - try { + 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); - $this->cleanup(); - $status = true; - } catch (\Exception $e) { - $status = false; - } - } else { - try { + } 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->cleanup(); + $status = true; + } catch (\Exception $e) { + $status = false; } $this->close($db); diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/Profile.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/Profile.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/Profiler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php similarity index 98% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/Profiler.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php index 966111c..f2fc8a9 100644 --- a/core/vendor/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -157,7 +157,7 @@ class Profiler * @param Response $response A Response instance * @param \Exception $exception An exception instance if the request threw one * - * @return Profile|false A Profile instance or false if the profiler is disabled + * @return Profile|null A Profile instance or null if the profiler is disabled */ public function collect(Request $request, Response $response, \Exception $exception = null) { diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php diff --git a/core/vendor/Symfony/Component/HttpKernel/README.md b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/README.md rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md diff --git a/core/vendor/Symfony/Component/HttpKernel/TerminableInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php similarity index 100% rename from core/vendor/Symfony/Component/HttpKernel/TerminableInterface.php rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php diff --git a/core/vendor/Symfony/Component/HttpKernel/composer.json b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json similarity index 87% rename from core/vendor/Symfony/Component/HttpKernel/composer.json rename to core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json index d48cc2d..95fb176 100644 --- a/core/vendor/Symfony/Component/HttpKernel/composer.json +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json @@ -4,7 +4,6 @@ "description": "Symfony HttpKernel Component", "keywords": [], "homepage": "http://symfony.com", - "version": "2.1.0", "license": "MIT", "authors": [ { @@ -32,5 +31,10 @@ "autoload": { "psr-0": { "Symfony\\Component\\HttpKernel": "" } }, - "target-dir": "Symfony/Component/HttpKernel" + "target-dir": "Symfony/Component/HttpKernel", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + } } diff --git a/core/vendor/Symfony/Component/Routing/Annotation/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Annotation/Route.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php diff --git a/core/vendor/Symfony/Component/Routing/CompiledRoute.php b/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/CompiledRoute.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php diff --git a/core/vendor/Symfony/Component/Routing/Exception/ExceptionInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Exception/ExceptionInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php diff --git a/core/vendor/Symfony/Component/Routing/Exception/InvalidParameterException.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Exception/InvalidParameterException.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php diff --git a/core/vendor/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Exception/MethodNotAllowedException.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php diff --git a/core/vendor/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php diff --git a/core/vendor/Symfony/Component/Routing/Exception/ResourceNotFoundException.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Exception/ResourceNotFoundException.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php diff --git a/core/vendor/Symfony/Component/Routing/Exception/RouteNotFoundException.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Exception/RouteNotFoundException.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php diff --git a/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php diff --git a/core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php diff --git a/core/vendor/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php diff --git a/core/vendor/Symfony/Component/Routing/Generator/UrlGenerator.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Generator/UrlGenerator.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php diff --git a/core/vendor/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php diff --git a/core/vendor/Symfony/Component/HttpFoundation/LICENSE b/core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE similarity index 96% rename from core/vendor/Symfony/Component/HttpFoundation/LICENSE rename to core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE index 89df448..cdffe7a 100644 --- a/core/vendor/Symfony/Component/HttpFoundation/LICENSE +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2011 Fabien Potencier +Copyright (c) 2004-2012 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/vendor/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/AnnotationClassLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/AnnotationFileLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/ClosureLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/ClosureLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/PhpFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/PhpFileLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/XmlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/XmlFileLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/YamlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/YamlFileLoader.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php diff --git a/core/vendor/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd similarity index 100% rename from core/vendor/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd rename to core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd diff --git a/core/vendor/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php similarity index 97% rename from core/vendor/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php index 66ba493..6e5e2db 100644 --- a/core/vendor/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php @@ -52,6 +52,7 @@ class ApacheUrlMatcher extends UrlMatcher if ('_route' == $name) { $match = true; + $parameters[$name] = $value; } elseif (0 === strpos($name, '_allow_')) { $allow[] = substr($name, 7); } else { diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php diff --git a/core/vendor/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php diff --git a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php similarity index 56% rename from core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php index fcd5880..ee8005d 100644 --- a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Routing\Matcher; use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\Route; /** * @author Fabien Potencier @@ -20,8 +21,6 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException; */ abstract class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface { - private $trailingSlashTest = false; - /** * @see UrlMatcher::match() * @@ -36,18 +35,29 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable throw $e; } - // try with a / at the end - $this->trailingSlashTest = true; + try { + parent::match($pathinfo.'/'); - return $this->match($pathinfo.'/'); + return $this->redirect($pathinfo.'/', null); + } catch (ResourceNotFoundException $e2) { + throw $e; + } } - if ($this->trailingSlashTest) { - $this->trailingSlashTest = false; + return $parameters; + } - return $this->redirect($pathinfo, null); + /** + * {@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 $parameters; + return array(self::REQUIREMENT_MATCH, null); } } diff --git a/core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php diff --git a/core/vendor/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php similarity index 99% rename from core/vendor/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php index ec00380..df8e89e 100644 --- a/core/vendor/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php @@ -73,7 +73,7 @@ class TraceableUrlMatcher extends UrlMatcher if (in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) { $this->addTrace(sprintf('Requirement for "%s" does not match (%s)', $n, $regex), self::ROUTE_ALMOST_MATCHES, $name, $route); - continue; + continue 2; } } diff --git a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php similarity index 70% rename from core/vendor/Symfony/Component/Routing/Matcher/UrlMatcher.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php index 5d30ae9..eaae027 100644 --- a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -15,7 +15,7 @@ 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\Matcher\RedirectableUrlMatcherInterface; +use Symfony\Component\Routing\Route; /** * UrlMatcher matches URL based on a set of routes. @@ -26,7 +26,12 @@ use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; */ class UrlMatcher implements UrlMatcherInterface { + const REQUIREMENT_MATCH = 0; + const REQUIREMENT_MISMATCH = 1; + const ROUTE_MATCH = 2; + protected $context; + protected $allow; private $routes; @@ -75,7 +80,7 @@ class UrlMatcher implements UrlMatcherInterface { $this->allow = array(); - if ($ret = $this->matchCollection($pathinfo, $this->routes)) { + if ($ret = $this->matchCollection(urldecode($pathinfo), $this->routes)) { return $ret; } @@ -84,10 +89,19 @@ class UrlMatcher implements UrlMatcherInterface : 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) { - $pathinfo = urldecode($pathinfo); - foreach ($routes as $name => $route) { if ($route instanceof RouteCollection) { if (false === strpos($route->getPrefix(), '{') && $route->getPrefix() !== substr($pathinfo, 0, strlen($route->getPrefix()))) { @@ -126,21 +140,38 @@ class UrlMatcher implements UrlMatcherInterface } } - // check HTTP scheme requirement - if ($scheme = $route->getRequirement('_scheme')) { - if (!$this instanceof RedirectableUrlMatcherInterface) { - throw new \LogicException('The "_scheme" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); - } + $status = $this->handleRouteRequirements($pathinfo, $name, $route); - if ($this->context->getScheme() !== $scheme) { - return $this->redirect($pathinfo, $name, $scheme); - } + 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; diff --git a/core/vendor/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php diff --git a/core/vendor/Symfony/Component/Routing/README.md b/core/vendor/symfony/routing/Symfony/Component/Routing/README.md similarity index 100% rename from core/vendor/Symfony/Component/Routing/README.md rename to core/vendor/symfony/routing/Symfony/Component/Routing/README.md diff --git a/core/vendor/Symfony/Component/Routing/RequestContext.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/RequestContext.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php diff --git a/core/vendor/Symfony/Component/Routing/RequestContextAwareInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/RequestContextAwareInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php diff --git a/core/vendor/Symfony/Component/Routing/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Route.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Route.php diff --git a/core/vendor/Symfony/Component/Routing/RouteCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/RouteCollection.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php diff --git a/core/vendor/Symfony/Component/Routing/RouteCompiler.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php similarity index 94% rename from core/vendor/Symfony/Component/Routing/RouteCompiler.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php index a09b016..5cebd22 100644 --- a/core/vendor/Symfony/Component/Routing/RouteCompiler.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php @@ -51,6 +51,11 @@ class RouteCompiler implements RouteCompilerInterface } $tokens[] = array('variable', $match[0][0][0], $regexp, $var); + + if (in_array($var, $variables)) { + throw new \LogicException(sprintf('Route pattern "%s" cannot reference variable name "%s" more than once.', $route->getPattern(), $var)); + } + $variables[] = $var; } diff --git a/core/vendor/Symfony/Component/Routing/RouteCompilerInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/RouteCompilerInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php diff --git a/core/vendor/Symfony/Component/Routing/Router.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php similarity index 100% rename from core/vendor/Symfony/Component/Routing/Router.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/Router.php diff --git a/core/vendor/Symfony/Component/Routing/RouterInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php similarity index 98% rename from core/vendor/Symfony/Component/Routing/RouterInterface.php rename to core/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php index 8591af8..529a85f 100644 --- a/core/vendor/Symfony/Component/Routing/RouterInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php @@ -15,7 +15,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; /** - * RouterInterface is the interface that all Router classes must implements. + * RouterInterface is the interface that all Router classes must implement. * * This interface is the concatenation of UrlMatcherInterface and UrlGeneratorInterface. * diff --git a/core/vendor/Symfony/Component/Routing/composer.json b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json similarity index 82% rename from core/vendor/Symfony/Component/Routing/composer.json rename to core/vendor/symfony/routing/Symfony/Component/Routing/composer.json index a3b5e88..fb0af2d 100644 --- a/core/vendor/Symfony/Component/Routing/composer.json +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json @@ -4,7 +4,6 @@ "description": "Symfony Routing Component", "keywords": [], "homepage": "http://symfony.com", - "version": "2.1.0", "license": "MIT", "authors": [ { @@ -26,5 +25,10 @@ "autoload": { "psr-0": { "Symfony\\Component\\Routing": "" } }, - "target-dir": "Symfony/Component/Routing" + "target-dir": "Symfony/Component/Routing", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + } }