diff --git a/composer.lock b/composer.lock index 5a70a6e5aab63759821208d3ef2bf2af2549e7b8..f85fc2cf12d1eb7c2fb356a1420442c6b94ce6cd 100644 --- a/composer.lock +++ b/composer.lock @@ -1157,27 +1157,32 @@ }, { "name": "symfony-cmf/routing", - "version": "1.1.0-beta1", + "version": "1.1.0", "target-dir": "Symfony/Cmf/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "1.1.0-beta1" + "reference": "9f8607950cbf888ec678713a35f3d0088857c85f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.1.0-beta1", - "reference": "1.1.0-beta1", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/9f8607950cbf888ec678713a35f3d0088857c85f", + "reference": "9f8607950cbf888ec678713a35f3d0088857c85f", "shasum": "" }, "require": { "php": ">=5.3.3", - "psr/log": ">=1.0,<2.0", - "symfony/http-kernel": ">=2.2,<3.0", - "symfony/routing": ">=2.2,<3.0" + "psr/log": "~1.0", + "symfony/http-kernel": "~2.2", + "symfony/routing": "~2.2" + }, + "require-dev": { + "symfony/config": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/event-dispatcher": "~2.1" }, "suggest": { - "symfony/http-foundation": "ChainRouter/DynamicRouter have optional support for Request instances, several enhancers require a Request instances, ~2.2" + "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1" }, "type": "library", "extra": { @@ -1206,7 +1211,7 @@ "database", "routing" ], - "time": "2013-06-03 17:23:01" + "time": "2013-10-14 15:32:46" }, { "name": "symfony/class-loader", diff --git a/core/vendor/autoload.php b/core/vendor/autoload.php index aac8b6206a86859fcee9a05d9d1a67bca962d94a..b5fc8225880696f9e0dbd565ac60b8aea706c5fd 100644 --- a/core/vendor/autoload.php +++ b/core/vendor/autoload.php @@ -1,7 +1,7 @@ <?php -// autoload.php @generated by Composer +// autoload.php generated by Composer require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit7ffa68419492d19fe654de54c86ae5d2::getLoader(); +return ComposerAutoloaderInit2f086fd5a6ac4778e93c60384b7d424a::getLoader(); diff --git a/core/vendor/composer/ClassLoader.php b/core/vendor/composer/ClassLoader.php index 1db8d9a0b2e2207309eb93e83ab8ab4736fd4ab2..bcf980915da5d5a3dc4ef2370efab8f7d165c9fd 100644 --- a/core/vendor/composer/ClassLoader.php +++ b/core/vendor/composer/ClassLoader.php @@ -49,7 +49,7 @@ class ClassLoader public function getPrefixes() { - return call_user_func_array('array_merge', $this->prefixes); + return $this->prefixes; } public function getFallbackDirs() @@ -98,21 +98,19 @@ public function add($prefix, $paths, $prepend = false) return; } - - $first = $prefix[0]; - if (!isset($this->prefixes[$first][$prefix])) { - $this->prefixes[$first][$prefix] = (array) $paths; + if (!isset($this->prefixes[$prefix])) { + $this->prefixes[$prefix] = (array) $paths; return; } if ($prepend) { - $this->prefixes[$first][$prefix] = array_merge( + $this->prefixes[$prefix] = array_merge( (array) $paths, - $this->prefixes[$first][$prefix] + $this->prefixes[$prefix] ); } else { - $this->prefixes[$first][$prefix] = array_merge( - $this->prefixes[$first][$prefix], + $this->prefixes[$prefix] = array_merge( + $this->prefixes[$prefix], (array) $paths ); } @@ -121,8 +119,8 @@ public function add($prefix, $paths, $prepend = false) /** * Registers a set of classes, replacing any others previously set. * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes + * @param string $prefix The classes prefix + * @param array|string $paths The location(s) of the classes */ public function set($prefix, $paths) { @@ -131,7 +129,7 @@ public function set($prefix, $paths) return; } - $this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths; + $this->prefixes[$prefix] = (array) $paths; } /** @@ -197,7 +195,6 @@ public function loadClass($class) */ public function findFile($class) { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 if ('\\' == $class[0]) { $class = substr($class, 1); } @@ -208,7 +205,7 @@ public function findFile($class) if (false !== $pos = strrpos($class, '\\')) { // namespaced class name - $classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR; $className = substr($class, $pos + 1); } else { // PEAR-like class name @@ -216,16 +213,13 @@ public function findFile($class) $className = $class; } - $classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php'; + $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - $first = $class[0]; - if (isset($this->prefixes[$first])) { - foreach ($this->prefixes[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; - } + foreach ($this->prefixes as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { + return $dir . DIRECTORY_SEPARATOR . $classPath; } } } diff --git a/core/vendor/composer/autoload_classmap.php b/core/vendor/composer/autoload_classmap.php index 96f77f2d4929111dccd0f8fc4fc9a5820570d72f..fe65adea6b374fb1f149242402532da3f7cf38d2 100644 --- a/core/vendor/composer/autoload_classmap.php +++ b/core/vendor/composer/autoload_classmap.php @@ -1,6 +1,6 @@ <?php -// autoload_classmap.php @generated by Composer +// autoload_classmap.php generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); diff --git a/core/vendor/composer/autoload_namespaces.php b/core/vendor/composer/autoload_namespaces.php index f6dbb7cc1c34109b40d28fe9e88a9cd3ab57d045..24be466c45fb738c08c8fa55503188ee0d27b612 100644 --- a/core/vendor/composer/autoload_namespaces.php +++ b/core/vendor/composer/autoload_namespaces.php @@ -1,43 +1,43 @@ <?php -// autoload_namespaces.php @generated by Composer +// autoload_namespaces.php generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); return array( - 'Zend\\Stdlib\\' => array($vendorDir . '/zendframework/zend-stdlib'), - 'Zend\\Feed\\' => array($vendorDir . '/zendframework/zend-feed'), - 'Zend\\Escaper\\' => array($vendorDir . '/zendframework/zend-escaper'), - 'Twig_' => array($vendorDir . '/twig/twig/lib'), - 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), - 'Symfony\\Component\\Validator\\' => array($vendorDir . '/symfony/validator'), - 'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'), - 'Symfony\\Component\\Serializer\\' => array($vendorDir . '/symfony/serializer'), - 'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'), - 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), - 'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'), - 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), - 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), - 'Symfony\\Component\\DependencyInjection\\' => array($vendorDir . '/symfony/dependency-injection'), - 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'), - 'Symfony\\Component\\ClassLoader\\' => array($vendorDir . '/symfony/class-loader'), - 'Symfony\\Cmf\\Component\\Routing' => array($vendorDir . '/symfony-cmf/routing'), - 'Psr\\Log\\' => array($vendorDir . '/psr/log'), - 'Guzzle\\Stream' => array($vendorDir . '/guzzle/stream'), - 'Guzzle\\Parser' => array($vendorDir . '/guzzle/parser'), - 'Guzzle\\Http' => array($vendorDir . '/guzzle/http'), - 'Guzzle\\Common' => array($vendorDir . '/guzzle/common'), - 'Gliph' => array($vendorDir . '/sdboyer/gliph/src'), - 'EasyRdf_' => array($vendorDir . '/easyrdf/easyrdf/lib'), - 'Drupal\\Driver' => array($baseDir . '/drivers/lib'), - 'Drupal\\Core' => array($baseDir . '/core/lib'), - 'Drupal\\Component' => array($baseDir . '/core/lib'), - 'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'), - 'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'), - 'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'), - 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'), - 'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'), - 'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib'), - 'Assetic' => array($vendorDir . '/kriswallsmith/assetic/src'), + 'Zend\\Stdlib\\' => $vendorDir . '/zendframework/zend-stdlib', + 'Zend\\Feed\\' => $vendorDir . '/zendframework/zend-feed', + 'Zend\\Escaper\\' => $vendorDir . '/zendframework/zend-escaper', + 'Twig_' => $vendorDir . '/twig/twig/lib', + 'Symfony\\Component\\Yaml\\' => $vendorDir . '/symfony/yaml', + 'Symfony\\Component\\Validator\\' => $vendorDir . '/symfony/validator', + 'Symfony\\Component\\Translation\\' => $vendorDir . '/symfony/translation', + 'Symfony\\Component\\Serializer\\' => $vendorDir . '/symfony/serializer', + 'Symfony\\Component\\Routing\\' => $vendorDir . '/symfony/routing', + 'Symfony\\Component\\Process\\' => $vendorDir . '/symfony/process', + 'Symfony\\Component\\HttpKernel\\' => $vendorDir . '/symfony/http-kernel', + 'Symfony\\Component\\HttpFoundation\\' => $vendorDir . '/symfony/http-foundation', + 'Symfony\\Component\\EventDispatcher\\' => $vendorDir . '/symfony/event-dispatcher', + 'Symfony\\Component\\DependencyInjection\\' => $vendorDir . '/symfony/dependency-injection', + 'Symfony\\Component\\Debug\\' => $vendorDir . '/symfony/debug', + 'Symfony\\Component\\ClassLoader\\' => $vendorDir . '/symfony/class-loader', + 'Symfony\\Cmf\\Component\\Routing' => $vendorDir . '/symfony-cmf/routing', + 'Psr\\Log\\' => $vendorDir . '/psr/log', + 'Guzzle\\Stream' => $vendorDir . '/guzzle/stream', + 'Guzzle\\Parser' => $vendorDir . '/guzzle/parser', + 'Guzzle\\Http' => $vendorDir . '/guzzle/http', + 'Guzzle\\Common' => $vendorDir . '/guzzle/common', + 'Gliph' => $vendorDir . '/sdboyer/gliph/src', + 'EasyRdf_' => $vendorDir . '/easyrdf/easyrdf/lib', + 'Drupal\\Driver' => $baseDir . '/drivers/lib', + 'Drupal\\Core' => $baseDir . '/core/lib', + 'Drupal\\Component' => $baseDir . '/core/lib', + 'Doctrine\\Common\\Lexer\\' => $vendorDir . '/doctrine/lexer/lib', + 'Doctrine\\Common\\Inflector\\' => $vendorDir . '/doctrine/inflector/lib', + 'Doctrine\\Common\\Collections\\' => $vendorDir . '/doctrine/collections/lib', + 'Doctrine\\Common\\Cache\\' => $vendorDir . '/doctrine/cache/lib', + 'Doctrine\\Common\\Annotations\\' => $vendorDir . '/doctrine/annotations/lib', + 'Doctrine\\Common\\' => $vendorDir . '/doctrine/common/lib', + 'Assetic' => $vendorDir . '/kriswallsmith/assetic/src', ); diff --git a/core/vendor/composer/autoload_real.php b/core/vendor/composer/autoload_real.php index b7dd370c8a2534d2541169efa2aaec38b2509298..31fbf8d035cd1c181b61a8e10d1dc90ceafda031 100644 --- a/core/vendor/composer/autoload_real.php +++ b/core/vendor/composer/autoload_real.php @@ -1,8 +1,8 @@ <?php -// autoload_real.php @generated by Composer +// autoload_real.php generated by Composer -class ComposerAutoloaderInit7ffa68419492d19fe654de54c86ae5d2 +class ComposerAutoloaderInit2f086fd5a6ac4778e93c60384b7d424a { private static $loader; @@ -19,9 +19,9 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit7ffa68419492d19fe654de54c86ae5d2', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit2f086fd5a6ac4778e93c60384b7d424a', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit7ffa68419492d19fe654de54c86ae5d2', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit2f086fd5a6ac4778e93c60384b7d424a', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); @@ -32,7 +32,7 @@ public static function getLoader() $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); + $loader->add($namespace, $path); } $classMap = require __DIR__ . '/autoload_classmap.php'; @@ -42,10 +42,8 @@ public static function getLoader() $loader->register(true); - $includeFiles = require __DIR__ . '/autoload_files.php'; - foreach ($includeFiles as $file) { - require $file; - } + require $vendorDir . '/kriswallsmith/assetic/src/functions.php'; + require $baseDir . '/core/lib/Drupal.php'; return $loader; } diff --git a/core/vendor/composer/include_paths.php b/core/vendor/composer/include_paths.php index 771d07b204ee0d73d46337855c3fccda64e34e33..66f70988d77dd9babc082acaf466338a020ed6fd 100644 --- a/core/vendor/composer/include_paths.php +++ b/core/vendor/composer/include_paths.php @@ -1,6 +1,6 @@ <?php -// include_paths.php @generated by Composer +// include_paths.php generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 8347a6421cf5092499883e4f65b4511c8000d689..ed258f02b05b83ac69dd3ab4bc5a416d610dab0c 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -219,61 +219,6 @@ "minification" ] }, - { - "name": "symfony-cmf/routing", - "version": "1.1.0-beta1", - "version_normalized": "1.1.0.0-beta1", - "target-dir": "Symfony/Cmf/Component/Routing", - "source": { - "type": "git", - "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "1.1.0-beta1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.1.0-beta1", - "reference": "1.1.0-beta1", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "psr/log": ">=1.0,<2.0", - "symfony/http-kernel": ">=2.2,<3.0", - "symfony/routing": ">=2.2,<3.0" - }, - "suggest": { - "symfony/http-foundation": "ChainRouter/DynamicRouter have optional support for Request instances, several enhancers require a Request instances, ~2.2" - }, - "time": "2013-06-03 17:23:01", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Cmf\\Component\\Routing": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony CMF Community", - "homepage": "https://github.com/symfony-cmf/Routing/contributors" - } - ], - "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", - "homepage": "http://cmf.symfony.com", - "keywords": [ - "database", - "routing" - ] - }, { "name": "phpunit/php-text-template", "version": "1.1.4", @@ -2110,5 +2055,65 @@ "php", "spl" ] + }, + { + "name": "symfony-cmf/routing", + "version": "1.1.0", + "version_normalized": "1.1.0.0", + "target-dir": "Symfony/Cmf/Component/Routing", + "source": { + "type": "git", + "url": "https://github.com/symfony-cmf/Routing.git", + "reference": "9f8607950cbf888ec678713a35f3d0088857c85f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/9f8607950cbf888ec678713a35f3d0088857c85f", + "reference": "9f8607950cbf888ec678713a35f3d0088857c85f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "psr/log": "~1.0", + "symfony/http-kernel": "~2.2", + "symfony/routing": "~2.2" + }, + "require-dev": { + "symfony/config": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1" + }, + "time": "2013-10-14 15:32:46", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Cmf\\Component\\Routing": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony CMF Community", + "homepage": "https://github.com/symfony-cmf/Routing/contributors" + } + ], + "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", + "homepage": "http://cmf.symfony.com", + "keywords": [ + "database", + "routing" + ] } ] diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/.travis.yml b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/.travis.yml index 494db9829aeae7f0cbc2c49237782c0a1ba35668..9a8b51a4996aee6fa047587ed7adf7a2b48f962f 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/.travis.yml +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/.travis.yml @@ -3,6 +3,7 @@ language: php php: - 5.3 - 5.4 + - 5.5 env: - SYMFONY_VERSION=2.2.* @@ -10,11 +11,14 @@ env: - SYMFONY_VERSION=dev-master before_script: - - composer require symfony/routing:${SYMFONY_VERSION} --no-update - - composer install --dev + - composer require symfony/routing:${SYMFONY_VERSION} --prefer-source script: phpunit --coverage-text notifications: irc: "irc.freenode.org#symfony-cmf" email: "symfony-cmf-devs@googlegroups.com" + +matrix: + allow_failures: + - env: SYMFONY_VERSION=dev-master diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CHANGELOG.md b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CHANGELOG.md index fe5dcfc79879586019287645cd142b8cf00eebfe..a8a0c7990b4cbc0e9253345311e3a6d9e253bef3 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CHANGELOG.md +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CHANGELOG.md @@ -1,8 +1,20 @@ Changelog ========= -1.1 ---- +1.1.0-RC1 +--------- -* **2013-04-30**: Dropped Symfony 2.1 support and got rid of ConfigurableUrlMatcher class -* **2013-04-05**: [ContentAwareGenerator] Fix locale handling to always respect locale but never have unnecessary ?locale= +* **2013-07-31**: DynamicRouter now accepts an EventDispatcher to trigger a + RouteMatchEvent right before the matching starts +* **2013-07-29**: Renamed RouteAwareInterface to RouteReferrersReadInterface + for naming consistency and added RouteReferrersInterface for write access. +* **2013-07-13**: NestedMatcher now expects a FinalMatcherInterface as second + argument of the constructor + +1.1.0-alpha1 +------------ + +* **2013-04-30**: Dropped Symfony 2.1 support and got rid of + ConfigurableUrlMatcher class +* **2013-04-05**: [ContentAwareGenerator] Fix locale handling to always respect + locale but never have unnecessary ?locale= diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CONTRIBUTING.md b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..0e4efaba58dce302d66b8deea97870c228041199 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/CONTRIBUTING.md @@ -0,0 +1,12 @@ +Contributing +------------ + +Symfony2 CMF is an open source, community-driven project. We follow the same +guidelines as core Symfony2. If you'd like to contribute, please read the +[Contributing Code][1] part of the documentation. If you're submitting a pull +request, please follow the guidelines in the [Submitting a Patch][2] section +and use the [Pull Request Template][3]. + +[1]: http://symfony.com/doc/current/contributing/code/index.html +[2]: http://symfony.com/doc/current/contributing/code/patches.html#check-list +[3]: http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php index 2ed85e0ddad4f99f2ce3dab9b654b8be23774e6a..f7452b29e0ef6fd50b0f4b1035fc13e1e72be077 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; use Symfony\Component\Routing\RouterInterface; @@ -168,6 +178,7 @@ private function doMatch($url, Request $request = null) if (null === $request) { $request = Request::create($url); } + return $router->matchRequest($request); } // every router implements the match method @@ -217,9 +228,7 @@ public function generate($name, $parameters = array(), $absolute = false) try { return $router->generate($name, $parameters, $absolute); } catch (RouteNotFoundException $e) { - $hint = ($router instanceof VersatileGeneratorInterface) - ? $router->getRouteDebugMessage($name, $parameters) - : "Route '$name' not found"; + $hint = $this->getErrorMessage($name, $router, $parameters); $debug[] = $hint; if ($this->logger) { $this->logger->info('Router '.get_class($router)." was unable to generate route. Reason: '$hint': ".$e->getMessage()); @@ -231,12 +240,28 @@ public function generate($name, $parameters = array(), $absolute = false) $debug = array_unique($debug); $info = implode(', ', $debug); } else { - $info = "No route '$name' found"; + $info = $this->getErrorMessage($name); } throw new RouteNotFoundException(sprintf('None of the chained routers were able to generate route: %s', $info)); } + private function getErrorMessage($name, $router = null, $parameters = null) + { + if ($router instanceof VersatileGeneratorInterface) { + $displayName = $router->getRouteDebugMessage($name, $parameters); + } elseif (is_object($name)) { + $displayName = method_exists($name, '__toString') + ? (string) $name + : get_class($name) + ; + } else { + $displayName = (string) $name; + } + + return "Route '$displayName' not found"; + } + /** * {@inheritdoc} */ diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainedRouterInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainedRouterInterface.php index 29d276f75359d36cd2307520e495e3ec06e64d1a..ae2307ef09aceb40b1cfded4df5f8ff40b219564 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainedRouterInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainedRouterInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; use Symfony\Component\Routing\RouterInterface; @@ -9,5 +19,4 @@ */ interface ChainedRouterInterface extends RouterInterface, VersatileGeneratorInterface { - // nothing new to add } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php index 976c65f4ec0faa36cda65b8486558222217a1d6d..b1254bdea35a15c13c0bbe597f53d0c74850c909 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php @@ -1,7 +1,18 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; +use Doctrine\Common\Collections\Collection; use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\RouteCollection; @@ -16,6 +27,14 @@ */ class ContentAwareGenerator extends ProviderBasedGenerator { + /** + * The locale to use when neither the parameters nor the request context + * indicate the locale to use. + * + * @var string + */ + protected $defaultLocale = null; + /** * The content repository used to find content by it's id * This can be used to specify a parameter content_id when generating urls @@ -42,7 +61,7 @@ public function setContentRepository(ContentRepositoryInterface $contentReposito * @param string $name ignored * @param array $parameters must either contain the field 'route' with a * RouteObjectInterface or the field 'content_id' with a document - * id to get the route for (implementing RouteAwareInterface) + * id to get the route for (implementing RouteReferrersReadInterface) * * @throws RouteNotFoundException If there is no such route in the database */ @@ -103,8 +122,8 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) } $locale = $this->getLocale($parameters); if (! $this->checkLocaleRequirement($route, $locale)) { - $content = $route->getRouteContent(); - if ($content instanceof RouteAwareInterface) { + $content = $route->getContent(); + if ($content instanceof RouteReferrersReadInterface) { $routes = $content->getRoutes(); $contentRoute = $this->getRouteByLocale($routes, $locale); if ($contentRoute) { @@ -117,9 +136,10 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) } /** - * Get the route based on the $name that is a RouteAwareInterface or a - * RouteAwareInterface content found in the content repository with the - * content_id specified in parameters. + * Get the route based on the $name that is an object implementing + * RouteReferrersReadInterface or a content found in the content repository + * with the content_id specified in parameters that is an instance of + * RouteReferrersReadInterface. * * Called in generate when there is no route given in the parameters. * @@ -131,7 +151,8 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) * first route. * * @param mixed $name - * @param array $parameters which should contain a content field containing a RouteAwareInterface object + * @param array $parameters which should contain a content field containing + * a RouteReferrersReadInterface object * * @return SymfonyRoute the route instance * @@ -139,7 +160,7 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) */ protected function getRouteByContent($name, &$parameters) { - if ($name instanceof RouteAwareInterface) { + if ($name instanceof RouteReferrersReadInterface) { $content = $name; } elseif (isset($parameters['content_id']) && null !== $this->contentRepository @@ -148,12 +169,12 @@ protected function getRouteByContent($name, &$parameters) if (empty($content)) { throw new RouteNotFoundException('The content repository found nothing at id ' . $parameters['content_id']); } - if (!$content instanceof RouteAwareInterface) { - throw new RouteNotFoundException('Content repository did not return a RouteAwareInterface for id ' . $parameters['content_id']); + if (!$content instanceof RouteReferrersReadInterface) { + throw new RouteNotFoundException('Content repository did not return a RouteReferrersReadInterface instance for id ' . $parameters['content_id']); } } else { $hint = is_object($name) ? get_class($name) : gettype($name); - throw new RouteNotFoundException("The route name argument '$hint' is not RouteAwareInterface and there is no 'content_id' parameter"); + throw new RouteNotFoundException("The route name argument '$hint' is not RouteReferrersReadInterface instance and there is no 'content_id' parameter"); } $routes = $content->getRoutes(); @@ -171,7 +192,11 @@ protected function getRouteByContent($name, &$parameters) return $route; } - // if none matched, continue and randomly return the first one + // if none matched, randomly return the first one + if ($routes instanceof Collection) { + return $routes->first(); + } + return reset($routes); } @@ -216,8 +241,9 @@ private function checkLocaleRequirement(SymfonyRoute $route, $locale) * * @param array $parameters the parameters determined by the route * - * @return string|null the locale following of the parameters or any other - * information the router has available. + * @return string the locale following of the parameters or any other + * information the router has available. defaultLocale if no other locale + * can be determined. */ protected function getLocale($parameters) { @@ -225,7 +251,22 @@ protected function getLocale($parameters) return $parameters['_locale']; } - return null; + if ($this->getContext()->hasParameter('_locale')) { + return $this->getContext()->getParameter('_locale'); + } + + return $this->defaultLocale; + } + + /** + * Overwrite the locale to be used by default if there is neither one in + * the parameters when building the route nor a request available (i.e. CLI). + * + * @param string $locale + */ + public function setDefaultLocale($locale) + { + $this->defaultLocale = $locale; } /** @@ -233,7 +274,7 @@ protected function getLocale($parameters) */ public function supports($name) { - return ! $name || parent::supports($name) || $name instanceof RouteAwareInterface; + return ! $name || parent::supports($name) || $name instanceof RouteReferrersReadInterface; } /** @@ -245,24 +286,29 @@ public function getRouteDebugMessage($name, array $parameters = array()) return 'Content id ' . $parameters['content_id']; } - if ($name instanceof RouteAwareInterface) { - return 'Route aware content ' . $name; + if ($name instanceof RouteReferrersReadInterface) { + return 'Route aware content ' . parent::getRouteDebugMessage($name, $parameters); } return parent::getRouteDebugMessage($name, $parameters); } /** - * Unset the _locale parameter if it is there and not needed + * If the _locale parameter is allowed by the requirements of the route + * and it is the default locale, remove it from the parameters so that we + * do not get an unneeded ?_locale= query string. * - * @param SymfonyRoute $route - * @param array $parameters + * @param SymfonyRoute $route The route being generated. + * @param array $parameters The parameters used, will be modified to + * remove the _locale field if needed. */ - protected function unsetLocaleIfNotNeeded(SymfonyRoute $route, array &$parameters) + protected function unsetLocaleIfNotNeeded(SymfonyRoute $route, array &$parameters) { $locale = $this->getLocale($parameters); if (null !== $locale) { - if (preg_match('/'.$route->getRequirement('_locale').'/', $locale) && $locale == $route->getDefault('_locale')) { + if (preg_match('/'.$route->getRequirement('_locale').'/', $locale) + && $locale == $route->getDefault('_locale') + ) { $compiledRoute = $route->compile(); if (!in_array('_locale', $compiledRoute->getVariables())) { unset($parameters['_locale']); diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentRepositoryInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentRepositoryInterface.php index d8c5cb437258879395ee1e89c6825b456d57378d..2f2c66df88c169fb9691c4db3571f2dd17eff05c 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentRepositoryInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentRepositoryInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; /** @@ -16,8 +26,8 @@ interface ContentRepositoryInterface /** * Return a content object by it's id or null if there is none. * - * If the returned content implements RouteAwareInterface, it will be used - * to get the route from it to generate an URL. + * If the returned content implements RouteReferrersReadInterface, it will + * be used to get the route from it to generate an URL. * * @param string $id id of the content object * diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php new file mode 100644 index 0000000000000000000000000000000000000000..927651e29c8b0e82911c6dfc620c1e907908182d --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php @@ -0,0 +1,54 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * This compiler pass adds additional route enhancers + * to the dynamic router. + * + * @author Daniel Leech <dan.t.leech@gmail.com> + * @author Nathaniel Catchpole (catch) + */ +class RegisterRouteEnhancersPass implements CompilerPassInterface +{ + /** + * @var string + */ + protected $dynamicRouterService; + + protected $enhancerTag; + + public function __construct($dynamicRouterService = 'cmf_routing.dynamic_router', $enhancerTag = 'dynamic_router_route_enhancer') + { + $this->dynamicRouterService = $dynamicRouterService; + $this->enhancerTag = $enhancerTag; + } + + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition($this->dynamicRouterService)) { + return; + } + + $router = $container->getDefinition($this->dynamicRouterService); + + foreach ($container->findTaggedServiceIds($this->enhancerTag) as $id => $attributes) { + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $router->addMethodCall('addRouteEnhancer', array(new Reference($id), $priority)); + } + } +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DependencyInjection/Compiler/RegisterRoutersPass.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DependencyInjection/Compiler/RegisterRoutersPass.php new file mode 100644 index 0000000000000000000000000000000000000000..7e564f3c837c28cae2d20349d4f06a3cad3c7b03 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DependencyInjection/Compiler/RegisterRoutersPass.php @@ -0,0 +1,55 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Compiler pass to register routers to the ChainRouter. + * + * @author Wouter J <waldio.webdesign@gmail.com> + * @author Henrik Bjornskov <henrik@bjrnskov.dk> + * @author Magnus Nordlander <magnus@e-butik.se> + */ +class RegisterRoutersPass implements CompilerPassInterface +{ + /** + * @var string + */ + protected $chainRouterService; + + protected $routerTag; + + public function __construct($chainRouterService = 'cmf_routing.router', $routerTag = 'router') + { + $this->chainRouterService = $chainRouterService; + $this->routerTag = $routerTag; + } + + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition($this->chainRouterService)) { + return; + } + + $definition = $container->getDefinition($this->chainRouterService); + + foreach ($container->findTaggedServiceIds($this->routerTag) as $id => $attributes) { + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + + $definition->addMethodCall('add', array(new Reference($id), $priority)); + } + } +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DynamicRouter.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DynamicRouter.php index f9db1f1844cb68af0c01e2d90205bbf7ff05f9a9..1ac34b26b08470209165620e9b4ba54363c4ccf8 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DynamicRouter.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DynamicRouter.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; use Symfony\Component\HttpFoundation\Request; @@ -13,8 +23,10 @@ use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\MethodNotAllowedException; - use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Cmf\Component\Routing\Event\Events; +use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent; /** * A flexible router accepting matcher and generator through injection and @@ -35,6 +47,11 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained */ protected $generator; + /** + * @var EventDispatcherInterface + */ + protected $eventDispatcher; + /** * @var RouteEnhancerInterface[] */ @@ -64,15 +81,21 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained * @param RequestMatcherInterface|UrlMatcherInterface $matcher * @param UrlGeneratorInterface $generator * @param string $uriFilterRegexp + * @param EventDispatcherInterface|null $eventDispatcher */ - public function __construct(RequestContext $context, $matcher, UrlGeneratorInterface $generator, $uriFilterRegexp = '') - { + public function __construct(RequestContext $context, + $matcher, + UrlGeneratorInterface $generator, + $uriFilterRegexp = '', + EventDispatcherInterface $eventDispatcher = null + ) { $this->context = $context; if (! $matcher instanceof RequestMatcherInterface && ! $matcher instanceof UrlMatcherInterface) { throw new \InvalidArgumentException('Invalid $matcher'); } $this->matcher = $matcher; $this->generator = $generator; + $this->eventDispatcher = $eventDispatcher; $this->uriFilterRegexp = $uriFilterRegexp; $this->generator->setContext($context); @@ -167,6 +190,12 @@ public function supports($name) */ public function match($pathinfo) { + $request = Request::create($pathinfo); + if ($this->eventDispatcher) { + $event = new RouterMatchEvent(); + $this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH, $event); + } + if (! empty($this->uriFilterRegexp) && ! preg_match($this->uriFilterRegexp, $pathinfo)) { throw new ResourceNotFoundException("$pathinfo does not match the '{$this->uriFilterRegexp}' pattern"); } @@ -178,7 +207,7 @@ public function match($pathinfo) $defaults = $matcher->match($pathinfo); - return $this->applyRouteEnhancers($defaults, Request::create($pathinfo)); + return $this->applyRouteEnhancers($defaults, $request); } /** @@ -198,6 +227,11 @@ public function match($pathinfo) */ public function matchRequest(Request $request) { + if ($this->eventDispatcher) { + $event = new RouterMatchEvent($request); + $this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH_REQUEST, $event); + } + if (! empty($this->uriFilterRegexp) && ! preg_match($this->uriFilterRegexp, $request->getPathInfo()) ) { @@ -206,12 +240,11 @@ public function matchRequest(Request $request) $matcher = $this->getMatcher(); if ($matcher instanceof UrlMatcherInterface) { - // the match method will enhance the route $defaults - return $this->match($request->getPathInfo()); + $defaults = $matcher->match($request->getPathInfo()); + } else { + $defaults = $matcher->matchRequest($request); } - $defaults = $matcher->matchRequest($request); - return $this->applyRouteEnhancers($defaults, $request); } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldByClassEnhancer.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldByClassEnhancer.php index 23bc714ccb684d02d9611e05b100df6baf76d903..52b70d5acd29c8996da9a587c8f16d200b5fe8a2 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldByClassEnhancer.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldByClassEnhancer.php @@ -1,11 +1,19 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Enhancer; use Symfony\Component\HttpFoundation\Request; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; - /** * This enhancer sets a field if not yet existing from the class of an object * in another field. diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldMapEnhancer.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldMapEnhancer.php index 53f6c0edb02ddbdd19ce1671ef4737cc281e952c..a5f34883ececdac164b440ca042598301f6825b7 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldMapEnhancer.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldMapEnhancer.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Enhancer; use Symfony\Component\HttpFoundation\Request; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldPresenceEnhancer.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldPresenceEnhancer.php index 9eb3a2a1c13158a7eb00f49c059af344f794aadd..6dcb9084e9a158cabf8bbcd3449bc4c17f0eb8f5 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldPresenceEnhancer.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/FieldPresenceEnhancer.php @@ -1,35 +1,53 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Enhancer; use Symfony\Component\HttpFoundation\Request; /** - * This enhancer can set a field to a fixed value if an other field is present. + * This enhancer sets a field to a fixed value. You can specify a source field + * name to only set the target field if the source is present. * * @author David Buchmann */ class FieldPresenceEnhancer implements RouteEnhancerInterface { /** - * @var string field for the source class + * Field name for the source field that must exist. If null, the target + * field is always set if not already present. + * + * @var string|null */ protected $source; + /** - * @var string field to write hashmap lookup result into + * Field name to write the value into. + * + * @var string */ protected $target; + /** - * value to set the target field to + * Value to set the target field to. * * @var string */ private $value; /** - * @param string $source the field name of the class - * @param string $target the field name to set from the map - * @param string $value value to set target field to if source field exists + * @param null|string $source the field name of the class, null to disable the check + * @param string $target the field name to set from the map + * @param string $value value to set target field to if source field exists */ public function __construct($source, $target, $value) { @@ -48,7 +66,7 @@ public function enhance(array $defaults, Request $request) return $defaults; } - if (! isset($defaults[$this->source])) { + if (null !== $this->source && !isset($defaults[$this->source])) { return $defaults; } @@ -56,5 +74,4 @@ public function enhance(array $defaults, Request $request) return $defaults; } - } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteContentEnhancer.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteContentEnhancer.php index 39e54d878720439065473b1e2635127cad1959b0..1c1d5e7f821be8fc8b36c9ca753cf6e4e92c3224 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteContentEnhancer.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteContentEnhancer.php @@ -1,14 +1,23 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Enhancer; -use Symfony\Component\Routing\Route; use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** - * This enhancer sets the content to target field if the route provides content + * This enhancer sets the content to target field if the route provides content. * * Only works with RouteObjectInterface routes that can return a referenced * content. @@ -56,9 +65,10 @@ public function enhance(array $defaults, Request $request) // we can't determine the content return $defaults; } + /** @var $route RouteObjectInterface */ $route = $defaults[$this->routefield]; - $content = $route->getRouteContent(); + $content = $route->getContent(); if (! $content) { // we have no content return $defaults; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteEnhancerInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteEnhancerInterface.php index 5932c71609eb1cd72ab73e6b60a4c35bad17dccd..19a9da9cf73f0c20d1b6ca7c4bffc68fca296a52 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteEnhancerInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteEnhancerInterface.php @@ -1,8 +1,17 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Enhancer; -use Symfony\Component\Routing\Route; use Symfony\Component\HttpFoundation\Request; /** @@ -19,9 +28,10 @@ interface RouteEnhancerInterface /** * Update the defaults based on its own data and the request. * - * @param array $defaults the getRouteDefaults array + * @param array $defaults the getRouteDefaults array. * - * @return array the modified defaults. Each enhancer MUST return the $defaults but may add or remove values + * @return array the modified defaults. Each enhancer MUST return the + * $defaults but may add or remove values. */ public function enhance(array $defaults, Request $request); } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Event/Events.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Event/Events.php new file mode 100644 index 0000000000000000000000000000000000000000..9804f45cc9a9d2a071cc5bd2e8063b18c1468ea2 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Event/Events.php @@ -0,0 +1,30 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing\Event; + +final class Events +{ + /** + * Fired before a path is matched in \Symfony\Cmf\Component\Routing\DynamicRouter#match + * + * The event object is RouteMatchEvent. + */ + const PRE_DYNAMIC_MATCH = 'cmf_routing.pre_dynamic_match'; + + /** + * Fired before a Request is matched in \Symfony\Cmf\Component\Routing\DynamicRouter#match + * + * The event object is RouteMatchEvent. + */ + const PRE_DYNAMIC_MATCH_REQUEST = 'cmf_routing.pre_dynamic_match_request'; +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Event/RouterMatchEvent.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Event/RouterMatchEvent.php new file mode 100644 index 0000000000000000000000000000000000000000..39ca607282e406fa79a7383a9c657ba2a4c57927 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Event/RouterMatchEvent.php @@ -0,0 +1,40 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing\Event; + +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpFoundation\Request; + +class RouterMatchEvent extends Event +{ + /** + * @var Request + */ + protected $request; + + /** + * @param Request $request + */ + public function __construct(Request $request = null) + { + $this->request = $request; + } + + /** + * @return Request | null + */ + public function getRequest() + { + return $this->request; + } +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/LICENSE b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/LICENSE index 797b3965fad0a23c71ca57aa7e599a0378719faf..32077a63d7636a5d467c59e07d2abe6e15adb6a4 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/LICENSE +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/LICENSE @@ -2,7 +2,7 @@ Routing The MIT License - Copyright (c) 2011-2012 Symfony2 CMF + Copyright (c) 2011-2013 Symfony2 CMF 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-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/FinalMatcherInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/FinalMatcherInterface.php index b48859c7e639c9dacdf03f3e6cb7e9c5342389ab..1d0417d15817ff38c33ce3b9bfad6a2165626ced 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/FinalMatcherInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/FinalMatcherInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\NestedMatcher; use Symfony\Component\HttpFoundation\Request; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/NestedMatcher.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/NestedMatcher.php index 9d31d8116e9ff8f0fc6717e4c891ede92e7cbade..d283ff5796fea84e99859f4eabff891e3f2df20c 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/NestedMatcher.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/NestedMatcher.php @@ -1,11 +1,20 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\NestedMatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\Route; use Symfony\Cmf\Component\Routing\RouteProviderInterface; /** @@ -55,17 +64,28 @@ class NestedMatcher implements RequestMatcherInterface /** * Constructs a new NestedMatcher * - * @param RouteProviderInterface $provider The Route Provider this matcher should use. + * @param RouteProviderInterface $provider The route provider this matcher + * should use + * @param FinalMatcherInterface $final The Final Matcher to match the + * routes */ - public function __construct(RouteProviderInterface $provider) - { - $this->routeProvider = $provider; + public function __construct( + RouteProviderInterface $provider = null, + FinalMatcherInterface $final = null + ) { + if (null !== $provider) { + $this->setRouteProvider($provider); + } + if (null !== $final) { + $this->setFinalMatcher($final); + } } /** * Sets the route provider for the matching plan. * - * @param RouteProviderInterface $provider A route provider. It is responsible for its own configuration. + * @param RouteProviderInterface $provider A route provider. It is + * responsible for its own configuration. * * @return NestedMatcher this object to have a fluent interface */ @@ -82,7 +102,8 @@ public function setRouteProvider(RouteProviderInterface $provider) * Partial matchers will be run in the order in which they are added. * * @param RouteFilterInterface $filter - * @param int $priority (optional) The priority of the filter. Higher number filters will be used first. Default to 0. + * @param int $priority (optional) The priority of the + * filter. Higher number filters will be used first. Default to 0. * * @return NestedMatcher this object to have a fluent interface */ @@ -101,7 +122,8 @@ public function addRouteFilter(RouteFilterInterface $filter, $priority = 0) /** * Sets the final matcher for the matching plan. * - * @param FinalMatcherInterface $final The final matcher that will have to pick the route that will be used. + * @param FinalMatcherInterface $final The final matcher that will have to + * pick the route that will be used. * * @return NestedMatcher this object to have a fluent interface */ @@ -122,7 +144,7 @@ public function matchRequest(Request $request) throw new ResourceNotFoundException(); } - // Route Filters are expected to throw an exception themselves if they + // Route filters are expected to throw an exception themselves if they // end up filtering the list down to 0. foreach ($this->getRouteFilters() as $filter) { $collection = $filter->filter($collection, $request); diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/RouteFilterInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/RouteFilterInterface.php index 7fe4ca9bb6e48157610badf2a2fd343b9b1442d9..f0945668a63d91690e82482965decad922cddad5 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/RouteFilterInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/RouteFilterInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\NestedMatcher; use Symfony\Component\Routing\RouteCollection; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/UrlMatcher.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/UrlMatcher.php index bb1ef21c8645c30f5c99207fda3690ca416e1d8a..94b8ec90809eb2548a9fcf59c2bf65b5e7887448 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/UrlMatcher.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/NestedMatcher/UrlMatcher.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\NestedMatcher; use Symfony\Component\Routing\Route; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php index 2b2aa517dfaff5f50d87fc10972856fc90285e44..e3aef91e8027fa70d1874c2376947567ff47ee4f 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ProviderBasedGenerator.php @@ -1,15 +1,26 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; +use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Route as SymfonyRoute; +use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\Generator\UrlGenerator; -use Psr\Log\LoggerInterface; - use Symfony\Cmf\Component\Routing\RouteProviderInterface; +use Psr\Log\LoggerInterface; + /** * A Generator that uses a RouteProvider rather than a RouteCollection * @@ -28,6 +39,7 @@ public function __construct(RouteProviderInterface $provider, LoggerInterface $l { $this->provider = $provider; $this->logger = $logger; + $this->context = new RequestContext(); } /** @@ -45,7 +57,9 @@ public function generate($name, $parameters = array(), $absolute = false) $compiledRoute = $route->compile(); $hostTokens = $compiledRoute->getHostTokens(); - return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $absolute, $hostTokens); + $debug_message = $this->getRouteDebugMessage($name); + + return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $debug_message, $absolute, $hostTokens); } /** @@ -63,6 +77,14 @@ public function supports($name) */ public function getRouteDebugMessage($name, array $parameters = array()) { + if (is_scalar($name)) { + return $name; + } + + if (is_array($name)) { + return serialize($name); + } + if ($name instanceof RouteObjectInterface) { return 'Route with key ' . $name->getRouteKey(); } @@ -71,7 +93,7 @@ public function getRouteDebugMessage($name, array $parameters = array()) return 'Route with pattern ' . $name->getPattern(); } - return $name; + return get_class($name); } } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/README.md b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/README.md index 607fb7234b241e0460a167b5088492ca48caf97c..a9855cf25a34b8e7cad6d5c5f1a971273301106d 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/README.md +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/README.md @@ -1,7 +1,54 @@ -# Symfony CMF Routing Component [](http://travis-ci.org/symfony-cmf/Routing) +# Symfony CMF Routing Component -This library extends the Symfony2 Routing component. Even though it has Symfony -in its name, it does not need the full Symfony2 framework and can be used in -standalone projects. +[](http://travis-ci.org/symfony-cmf/Routing) +[](https://packagist.org/packages/symfony-cmf/routing) +[](https://packagist.org/packages/symfony-cmf/routing) -http://symfony.com/doc/master/cmf/components/routing.html +The Symfony CMF Routing component extends the Symfony2 core routing component. +It provides: + + * A ChainRouter to run several routers in parallel + * A DynamicRouter that can load routes from any database and can generate + additional information in the route match. + +Even though it has Symfony in its name, the Routing component does not need the +full Symfony2 Framework and can be used in standalone projects. + +For Symfon2 projects, an optional +[RoutingBundle](https://github.com/symfony-cmf/RoutingBundle) +is also available. + +This library is provided by the [Symfony Content Management Framework (CMF) project](http://cmf.symfony.com/) +and licensed under the [MIT License](LICENSE). + + +## Requirements + +* The Symfony Routing component (>= 2.2.0) +* See also the `require` section of [composer.json](composer.json) + + +## Documentation + +For the install guide and reference, see: + +* [Routing component documentation](http://symfony.com/doc/master/cmf/components/routing.html) + +See also: + +* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference +* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links + + +## Contributing + +Pull requests are welcome. Please see our +[CONTRIBUTING](https://github.com/symfony-cmf/symfony-cmf/blob/master/CONTRIBUTING.md) +guide. + +Unit and/or functional tests exist for this component. See the +[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html) +for a guide to running the tests. + +Thanks to +[everyone who has contributed](https://github.com/symfony-cmf/Routing/contributors) already. diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RedirectRouteInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RedirectRouteInterface.php index c4ac783fd915d19f56c8a0e7f3305a3b17fb25ea..6f462f30605563f0034a881dffd8761279af598f 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RedirectRouteInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RedirectRouteInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; /** diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteAwareInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteAwareInterface.php deleted file mode 100644 index b95a6b8ec39c3b312c68986682a85d7079197b8c..0000000000000000000000000000000000000000 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteAwareInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -namespace Symfony\Cmf\Component\Routing; - -/** - * Interface to be implemented by content that wants to be compatible with the - * DynamicRouter - */ -interface RouteAwareInterface -{ - /** - * Get the routes that point to this content. - * - * Note: For PHPCR ODM, as explained in RouteObjectInterface the route must use the - * routeContent field to store the reference to the content so you can get the routes with - * Referrers(referringDocument="Symfony\Cmf\Bundle\RoutingBundle\Document\Route", referencedBy="routeContent") - * - * @return \Symfony\Component\Routing\Route[] Route instances that point to this content - */ - public function getRoutes(); -} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php index 16b760a2562bee8941fa01ba44bfef305bc848e2..8287a930356899f09e71afe2493d3d1683c87328 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteObjectInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; /** @@ -50,13 +60,9 @@ interface RouteObjectInterface * If there is no specific content for this url (i.e. its an "application" * page), may return null. * - * To interoperate with the standard Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent - * the instance MUST store the property in the field <code>routeContent</code> - * to have referrer resolution work. - * * @return object the document or entity this route entry points to */ - public function getRouteContent(); + public function getContent(); /** * Get the route key. diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteProviderInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteProviderInterface.php index ef8fe3e6d1a7fb39bb74b58e748573a1846866df..99d79642debbe1529c073996ce1772d928425ec6 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteProviderInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteProviderInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; use Symfony\Component\HttpFoundation\Request; @@ -38,11 +48,11 @@ interface RouteProviderInterface public function getRouteCollectionForRequest(Request $request); /** - * Find the route using the provided route name (and parameters) + * Find the route using the provided route name. * * @param string $name the route name to fetch - * @param array $parameters the parameters as they are passed to the - * UrlGeneratorInterface::generate call + * @param array $parameters DEPRECATED the parameters as they are passed + * to the UrlGeneratorInterface::generate call * * @return \Symfony\Component\Routing\Route * @@ -52,19 +62,20 @@ public function getRouteCollectionForRequest(Request $request); public function getRouteByName($name, $parameters = array()); /** - * Find many routes by their names using the provided list of names + * Find many routes by their names using the provided list of names. * * Note that this method may not throw an exception if some of the routes - * are not found. It will just return the list of those routes it found. + * are not found or are not actually Route instances. It will just return the + * list of those Route instances it found. * * This method exists in order to allow performance optimizations. The * simple implementation could be to just repeatedly call - * $this->getRouteByName() + * $this->getRouteByName() while catching and ignoring eventual exceptions. * * @param array $names the list of names to retrieve - * @param array $parameters the parameters as they are passed to the - * UrlGeneratorInterface::generate call. (Only one array, not one for - * each entry in $names. + * @param array $parameters DEPRECATED the parameters as they are passed to + * the UrlGeneratorInterface::generate call. (Only one array, not one + * for each entry in $names. * * @return \Symfony\Component\Routing\Route[] iterable thing with the keys * the names of the $names argument. diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteReferrersInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteReferrersInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..9cf1f0f10dbd689be43673a09900763eff399b8d --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteReferrersInterface.php @@ -0,0 +1,36 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing; + +use Symfony\Component\Routing\Route; + +/** + * Interface to be implemented by content that exposes editable route + * referrers. + */ +interface RouteReferrersInterface extends RouteReferrersReadInterface +{ + /** + * Add a route to the collection. + * + * @param Route $route + */ + public function addRoute($route); + + /** + * Remove a route from the collection. + * + * @param Route $route + */ + public function removeRoute($route); +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteReferrersReadInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteReferrersReadInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..96691b248a2323975b3095fd2bfcfcb0b2bcbc29 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/RouteReferrersReadInterface.php @@ -0,0 +1,29 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing; + +use Symfony\Component\Routing\Route; + +/** + * Interface to be implemented by content that wants to be support route generation + * from content with the DynamicRouter by providing the routes that point to it. + */ +interface RouteReferrersReadInterface +{ + /** + * Get the routes that point to this content. + * + * @return Route[] Route instances that point to this content + */ + public function getRoutes(); +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Test/CmfUnitTestCase.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Test/CmfUnitTestCase.php index 789823876d48bde56943874e35f6598cf179a4ba..782a431352571f50e4f127d350d545b4454df6fb 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Test/CmfUnitTestCase.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Test/CmfUnitTestCase.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Test; class CmfUnitTestCase extends \PHPUnit_Framework_TestCase diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c05f79775c0ccb2a421ef91eaff329b21d9dc010 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php @@ -0,0 +1,72 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Component\Routing\Tests\DependencyInjection\Compiler; + +use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRouteEnhancersPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +class RegisterRouteEnhancersPassTest extends \PHPUnit_Framework_TestCase +{ + public function testRouteEnhancerPass() + { + $serviceIds = array( + 'test_enhancer' => array( + 0 => array( + 'id' => 'foo_enhancer' + ) + ), + ); + + $definition = new Definition('router'); + $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + $builder->expects($this->at(0)) + ->method('hasDefinition') + ->with('cmf_routing.dynamic_router') + ->will($this->returnValue(true)) + ; + $builder->expects($this->once()) + ->method('findTaggedServiceIds') + ->will($this->returnValue($serviceIds)) + ; + $builder->expects($this->once()) + ->method('getDefinition') + ->with('cmf_routing.dynamic_router') + ->will($this->returnValue($definition)) + ; + + $pass = new RegisterRouteEnhancersPass(); + $pass->process($builder); + + $calls = $definition->getMethodCalls(); + $this->assertEquals(1, count($calls)); + $this->assertEquals('addRouteEnhancer', $calls[0][0]); + } + + /** + * If there is no dynamic router defined in the container builder, nothing + * should be processed. + */ + public function testNoDynamicRouter() + { + $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + $builder->expects($this->once()) + ->method('hasDefinition') + ->with('cmf_routing.dynamic_router') + ->will($this->returnValue(false)) + ; + + $pass = new RegisterRouteEnhancersPass(); + $pass->process($builder); + } +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/DependencyInjection/Compiler/RegisterRoutersPassTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/DependencyInjection/Compiler/RegisterRoutersPassTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ebeb5b08ce198aeda9f1a96b41c32de52a1e8d12 --- /dev/null +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/DependencyInjection/Compiler/RegisterRoutersPassTest.php @@ -0,0 +1,99 @@ +<?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace Symfony\Cmf\Routing\Tests\DependencyInjection\Compiler; + +use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRoutersPass; + +use Symfony\Component\DependencyInjection\Reference; + +class RegisterRoutersPassTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getValidRoutersData + */ + public function testValidRouters($name, $priority = null) + { + if (!method_exists($this, 'callback')) { + $this->markTestSkipped('PHPUnit version too old for this test'); + } + $services = array(); + $services[$name] = array(0 => array('priority' => $priority)); + + $priority = $priority ?: 0; + + $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition->expects($this->atLeastOnce()) + ->method('addMethodCall') + ->with($this->equalTo('add'), $this->callback(function($arg) use ($name, $priority) { + if (!$arg[0] instanceof Reference || $name !== $arg[0]->__toString()) { + return false; + } + + if ($priority !== $arg[1]) { + return false; + } + + return true; + })); + + $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')); + $builder->expects($this->any()) + ->method('hasDefinition') + ->with('cmf_routing.router') + ->will($this->returnValue(true)); + + $builder->expects($this->atLeastOnce()) + ->method('findTaggedServiceIds') + ->will($this->returnValue($services)); + + $builder->expects($this->atLeastOnce()) + ->method('getDefinition') + ->will($this->returnValue($definition)); + + $registerRoutersPass = new RegisterRoutersPass(); + $registerRoutersPass->process($builder); + } + + public function getValidRoutersData() + { + return array( + array('my_router'), + array('my_primary_router', 99), + array('my_router', 0), + ); + } + + /** + * If there is no chain router defined in the container builder, nothing + * should be processed. + */ + public function testNoChainRouter() + { + $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')); + $builder->expects($this->once()) + ->method('hasDefinition') + ->with('cmf_routing.router') + ->will($this->returnValue(false)) + ; + + $builder->expects($this->never()) + ->method('findTaggedServiceIds') + ; + $builder->expects($this->never()) + ->method('getDefinition') + ; + + $registerRoutersPass = new RegisterRoutersPass(); + $registerRoutersPass->process($builder); + } +} diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php index 85fc2d381444128b5fb709266db4263ae7e6321d..9675f455c171c2900e07c31a002920b7dfca4fb0 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldByClassEnhancerTest.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; use Symfony\Component\HttpFoundation\Request; @@ -18,9 +28,9 @@ class FieldByClassEnhancerTest extends CmfUnitTestCase public function setUp() { - $this->document = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Enhancer\\RouteObject'); + $this->document = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject'); - $mapping = array('Symfony\\Cmf\\Component\\Routing\\Tests\\Enhancer\\RouteObject' + $mapping = array('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject' => 'cmf_content.controller:indexAction'); $this->mapper = new FieldByClassEnhancer('_content', '_controller', $mapping); diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php index 9e7ca861b56de460a93f09d3e4d38cd9130cad75..4fa59177c82eb9caa09cbd21b4e87d1760e1562c 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldMapEnhancerTest.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Mapper; use Symfony\Component\HttpFoundation\Request; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php index e389be2d377c780bb64b9e6a53ac12df4168acc7..596780a210d4ad13cfbae13c6491d8cbc2babf7c 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/FieldPresenceEnhancerTest.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; use Symfony\Component\HttpFoundation\Request; @@ -42,9 +52,21 @@ public function testFieldAlreadyThere() $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); } - public function testHasNoTemplate() + public function testHasNoSourceValue() { $defaults = array('foo' => 'bar'); $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); } + + public function testHasNoSource() + { + $this->mapper = new FieldPresenceEnhancer(null, '_controller', 'cmf_content.controller:indexAction'); + + $defaults = array('foo' => 'bar'); + $expected = array( + 'foo' => 'bar', + '_controller' => 'cmf_content.controller:indexAction', + ); + $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request)); + } } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteContentEnhancerTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteContentEnhancerTest.php index 1206eaf2761ec8b51996be7ad47debd3df672c31..6383fb3c8a614236c6c82dfe0a5b13a028752c8b 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteContentEnhancerTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteContentEnhancerTest.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; use Symfony\Component\HttpFoundation\Request; @@ -20,8 +30,8 @@ class RouteContentEnhancerTest extends CmfUnitTestCase public function setUp() { - $this->document = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Enhancer\\RouteObject', - array('getRouteContent', 'getRouteDefaults', 'getUrl')); + $this->document = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject', + array('getContent', 'getRouteDefaults', 'getUrl')); $this->mapper = new RouteContentEnhancer(RouteObjectInterface::ROUTE_OBJECT, '_content'); @@ -32,7 +42,7 @@ public function testContent() { $targetDocument = new TargetDocument(); $this->document->expects($this->once()) - ->method('getRouteContent') + ->method('getContent') ->will($this->returnValue($targetDocument)); $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->document); @@ -44,7 +54,7 @@ public function testContent() public function testFieldAlreadyThere() { $this->document->expects($this->never()) - ->method('getRouteContent') + ->method('getContent') ; $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->document, '_content' => 'foo'); @@ -55,7 +65,7 @@ public function testFieldAlreadyThere() public function testNoContent() { $this->document->expects($this->once()) - ->method('getRouteContent') + ->method('getContent') ->will($this->returnValue(null)); $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->document); @@ -64,7 +74,7 @@ public function testNoContent() public function testNoCmfRoute() { - $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->buildMock('Symfony\\Component\\Routing\\Route')); + $defaults = array(RouteObjectInterface::ROUTE_OBJECT => $this->buildMock('Symfony\Component\Routing\Route')); $this->assertEquals($defaults, $this->mapper->enhance($defaults, $this->request)); } } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteObject.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteObject.php index 86a2173df1a96a656c34add55bb6c218c79ac326..5b0a7379d29962ac2b757454c3e9cdd65b0131d4 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteObject.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Enhancer/RouteObject.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; use Symfony\Component\Routing\Route; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/NestedMatcherTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/NestedMatcherTest.php index bf58afdb5c6e4b3e916e20b286646211d576ad27..e7bf9ae0e6405fae4eb8fe2293b9aca1388fccd0 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/NestedMatcherTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/NestedMatcherTest.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\NestedMatcher; use Symfony\Component\HttpFoundation\Request; @@ -21,17 +31,17 @@ class NestedMatcherTest extends CmfUnitTestCase public function setUp() { - $this->provider = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface"); - $this->routeFilter1 = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\NestedMatcher\\RouteFilterInterface'); - $this->routeFilter2 = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\NestedMatcher\\RouteFilterInterface'); - $this->finalMatcher = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\NestedMatcher\\FinalMatcherInterface'); + $this->provider = $this->buildMock('Symfony\Cmf\Component\Routing\RouteProviderInterface'); + $this->routeFilter1 = $this->buildMock('Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface'); + $this->routeFilter2 = $this->buildMock('Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface'); + $this->finalMatcher = $this->buildMock('Symfony\Cmf\Component\Routing\NestedMatcher\FinalMatcherInterface'); } public function testNestedMatcher() { $request = Request::create('/path/one'); $routeCollection = new RouteCollection(); - $route = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock(); + $route = $this->getMockBuilder('Symfony\Component\Routing\Route')->disableOriginalConstructor()->getMock(); $routeCollection->add('route', $route); $this->provider->expects($this->once()) @@ -55,10 +65,9 @@ public function testNestedMatcher() ->will($this->returnValue(array('foo' => 'bar'))) ; - $matcher = new NestedMatcher($this->provider); + $matcher = new NestedMatcher($this->provider, $this->finalMatcher); $matcher->addRouteFilter($this->routeFilter1); $matcher->addRouteFilter($this->routeFilter2); - $matcher->setFinalMatcher($this->finalMatcher); $attributes = $matcher->matchRequest($request); @@ -72,10 +81,10 @@ public function testNestedMatcherPriority() { $request = Request::create('/path/one'); $routeCollection = new RouteCollection(); - $route = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock(); + $route = $this->getMockBuilder('Symfony\Component\Routing\Route')->disableOriginalConstructor()->getMock(); $routeCollection->add('route', $route); - $wrongProvider = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface"); + $wrongProvider = $this->buildMock('Symfony\Cmf\Component\Routing\RouteProviderInterface'); $wrongProvider->expects($this->never()) ->method('getRouteCollectionForRequest') ; @@ -96,11 +105,10 @@ public function testNestedMatcherPriority() ->method('finalMatch') ; - $matcher = new NestedMatcher($wrongProvider); + $matcher = new NestedMatcher($wrongProvider, $this->finalMatcher); $matcher->setRouteProvider($this->provider); $matcher->addRouteFilter($this->routeFilter2, 10); $matcher->addRouteFilter($this->routeFilter1, 20); - $matcher->setFinalMatcher($this->finalMatcher); try { $matcher->matchRequest($request); @@ -123,10 +131,9 @@ public function testProviderNoMatch() ->method('finalMatch') ; - $matcher = new NestedMatcher($this->provider); - $matcher->setFinalMatcher($this->finalMatcher); + $matcher = new NestedMatcher($this->provider, $this->finalMatcher); - $this->setExpectedException('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException'); + $this->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); $matcher->matchRequest($request); } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php index 7360a72464e86508ee82e87ea66e28d40725f690..6dc48548887ef559fc6012ac120b427f77314191 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/UrlMatcherTest.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\NestedMatcher; use Symfony\Component\HttpFoundation\Request; @@ -24,10 +34,10 @@ class UrlMatcherTest extends CmfUnitTestCase public function setUp() { - $this->routeDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'getRouteKey', 'compile')); - $this->routeCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); + $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'getRouteKey', 'compile')); + $this->routeCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); - $this->context = $this->buildMock('Symfony\\Component\\Routing\\RequestContext'); + $this->context = $this->buildMock('Symfony\Component\Routing\RequestContext'); $this->request = Request::create($this->url); $this->matcher = new UrlMatcher(new RouteCollection(), $this->context); @@ -51,7 +61,7 @@ public function doTestMatchRouteKey($routeKey) ; $this->routeCompiled->expects($this->atLeastOnce()) ->method('getRegex') - ->will($this->returnValue('#'.str_replace('/', '\\/', $this->url).'#')) + ->will($this->returnValue('#'.str_replace('/', '\/', $this->url).'#')) ; $this->routeDocument->expects($this->atLeastOnce()) ->method('compile') @@ -66,12 +76,12 @@ public function doTestMatchRouteKey($routeKey) ->will($this->returnValue(array('foo' => 'bar'))) ; - $mockCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); + $mockCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); $mockCompiled->expects($this->any()) ->method('getStaticPrefix') ->will($this->returnValue('/no/match')) ; - $mockRoute = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock(); + $mockRoute = $this->getMockBuilder('Symfony\Component\Routing\Route')->disableOriginalConstructor()->getMock(); $mockRoute->expects($this->any()) ->method('compile') ->will($this->returnValue($mockCompiled)) @@ -100,9 +110,9 @@ public function testMatchNoRouteObject() ; $this->routeCompiled->expects($this->atLeastOnce()) ->method('getRegex') - ->will($this->returnValue('#'.str_replace('/', '\\/', $this->url).'#')) + ->will($this->returnValue('#'.str_replace('/', '\/', $this->url).'#')) ; - $this->routeDocument = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock(); + $this->routeDocument = $this->getMockBuilder('Symfony\Component\Routing\Route')->disableOriginalConstructor()->getMock(); $this->routeDocument->expects($this->atLeastOnce()) ->method('compile') ->will($this->returnValue($this->routeCompiled)) @@ -115,12 +125,12 @@ public function testMatchNoRouteObject() ->will($this->returnValue(array('foo' => 'bar'))) ; - $mockCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); + $mockCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); $mockCompiled->expects($this->any()) ->method('getStaticPrefix') ->will($this->returnValue('/no/match')) ; - $mockRoute = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock(); + $mockRoute = $this->getMockBuilder('Symfony\Component\Routing\Route')->disableOriginalConstructor()->getMock(); $mockRoute->expects($this->any()) ->method('compile') ->will($this->returnValue($mockCompiled)) diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php index 893397d4632a9664bc645eed132e4e8015395539..d99e4a754d51f9e00e7d5e042d84767c8b92d469 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php @@ -1,7 +1,20 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Routing; +use Symfony\Component\Routing\Exception\MethodNotAllowedException; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\HttpFoundation\Request; @@ -13,7 +26,7 @@ class ChainRouterTest extends CmfUnitTestCase public function setUp() { $this->router = new ChainRouter($this->getMock('Psr\Log\LoggerInterface')); - $this->context = $this->getMock('Symfony\\Component\\Routing\\RequestContext'); + $this->context = $this->getMock('Symfony\Component\Routing\RequestContext'); } public function testPriority() @@ -42,7 +55,7 @@ public function testSortRouters() { list($low, $medium, $high) = $this->createRouterMocks(); // We're using a mock here and not $this->router because we need to ensure that the sorting operation is done only once. - $router = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\ChainRouter', array('sortRouters')); + $router = $this->buildMock('Symfony\Cmf\Component\Routing\ChainRouter', array('sortRouters')); $router ->expects($this->once()) ->method('sortRouters') @@ -75,7 +88,7 @@ public function testReSortRouters() list($low, $medium, $high) = $this->createRouterMocks(); $highest = clone $high; // We're using a mock here and not $this->router because we need to ensure that the sorting operation is done only once. - $router = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\ChainRouter', array('sortRouters')); + $router = $this->buildMock('Symfony\Cmf\Component\Routing\ChainRouter', array('sortRouters')); $router ->expects($this->at(0)) ->method('sortRouters') @@ -200,7 +213,7 @@ public function testMatchRequest() $url = '/test'; list($lower, $low, $high) = $this->createRouterMocks(); - $highest = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RequestMatcher'); + $highest = $this->getMock('Symfony\Cmf\Component\Routing\Tests\Routing\RequestMatcher'); $request = Request::create('/test'); @@ -245,7 +258,7 @@ public function testMatchWithRequestMatchers() list($low) = $this->createRouterMocks(); - $high = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RequestMatcher'); + $high = $this->getMock('Symfony\Cmf\Component\Routing\Tests\Routing\RequestMatcher'); $high ->expects($this->once()) @@ -267,7 +280,6 @@ public function testMatchWithRequestMatchers() $this->assertEquals(array('test'), $result); } - /** * If there is a method not allowed but another router matches, that one is used */ @@ -334,13 +346,13 @@ public function testMatchNotFound() ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ->will($this->throwException(new ResourceNotFoundException())) ; $low ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ->will($this->throwException(new ResourceNotFoundException())) ; $this->router->add($low, 10); $this->router->add($high, 100); @@ -360,13 +372,13 @@ public function testMatchRequestNotFound() ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ->will($this->throwException(new ResourceNotFoundException())) ; $low ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ->will($this->throwException(new ResourceNotFoundException())) ; $this->router->add($low, 10); $this->router->add($high, 100); @@ -388,13 +400,13 @@ public function testMatchMethodNotAllowed() ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\MethodNotAllowedException(array()))) + ->will($this->throwException(new MethodNotAllowedException(array()))) ; $low ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ->will($this->throwException(new ResourceNotFoundException())) ; $this->router->add($low, 10); $this->router->add($high, 100); @@ -416,13 +428,13 @@ public function testMatchRequestMethodNotAllowed() ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\MethodNotAllowedException(array()))) + ->will($this->throwException(new MethodNotAllowedException(array()))) ; $low ->expects($this->once()) ->method('match') ->with($url) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException)) + ->will($this->throwException(new ResourceNotFoundException())) ; $this->router->add($low, 10); $this->router->add($high, 100); @@ -441,7 +453,7 @@ public function testGenerate() ->expects($this->once()) ->method('generate') ->with($name, $parameters, false) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\RouteNotFoundException())) + ->will($this->throwException(new RouteNotFoundException())) ; $low ->expects($this->once()) @@ -466,7 +478,6 @@ public function testGenerate() */ public function testGenerateNotFound() { - $url = '/test'; $name = 'test'; $parameters = array('test' => 'value'); list($low, $high) = $this->createRouterMocks(); @@ -475,18 +486,71 @@ public function testGenerateNotFound() ->expects($this->once()) ->method('generate') ->with($name, $parameters, false) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\RouteNotFoundException())) + ->will($this->throwException(new RouteNotFoundException())) ; $low->expects($this->once()) ->method('generate') ->with($name, $parameters, false) - ->will($this->throwException(new \Symfony\Component\Routing\Exception\RouteNotFoundException())) + ->will($this->throwException(new RouteNotFoundException())) ; $this->router->add($low, 10); $this->router->add($high, 100); - $result = $this->router->generate($name, $parameters); - $this->assertEquals($url, $result); + $this->router->generate($name, $parameters); + } + + /** + * Route is an object but no versatile generator around to do the debug message. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException + */ + public function testGenerateObjectNotFound() + { + $name = new \stdClass(); + $parameters = array('test' => 'value'); + + $defaultRouter = $this->getMock('Symfony\Component\Routing\RouterInterface'); + + $defaultRouter + ->expects($this->never()) + ->method('generate') + ; + + $this->router->add($defaultRouter, 200); + + $this->router->generate($name, $parameters); + } + + /** + * A versatile router will generate the debug message. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException + */ + public function testGenerateObjectNotFoundVersatile() + { + $name = new \stdClass(); + $parameters = array('test' => 'value'); + + $chainedRouter = $this->getMock('Symfony\Cmf\Component\Routing\ChainedRouterInterface'); + $chainedRouter + ->expects($this->once()) + ->method('supports') + ->will($this->returnValue(true)) + ; + $chainedRouter->expects($this->once()) + ->method('generate') + ->with($name, $parameters, false) + ->will($this->throwException(new RouteNotFoundException())) + ; + $chainedRouter->expects($this->once()) + ->method('getRouteDebugMessage') + ->with($name, $parameters) + ->will($this->returnValue('message')) + ; + + $this->router->add($chainedRouter, 10); + + $this->router->generate($name, $parameters); } public function testGenerateObjectName() @@ -494,8 +558,8 @@ public function testGenerateObjectName() $name = new \stdClass(); $parameters = array('test' => 'value'); - $defaultRouter = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); - $chainedRouter = $this->getMock('Symfony\\Cmf\\Component\\Routing\\ChainedRouterInterface'); + $defaultRouter = $this->getMock('Symfony\Component\Routing\RouterInterface'); + $chainedRouter = $this->getMock('Symfony\Cmf\Component\Routing\ChainedRouterInterface'); $defaultRouter ->expects($this->never()) @@ -529,7 +593,7 @@ public function testWarmup() ->expects($this->never()) ->method('warmUp') ; - $high = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\WarmableRouterMock'); + $high = $this->getMock('Symfony\Cmf\Component\Routing\Tests\Routing\WarmableRouterMock'); $high ->expects($this->once()) ->method('warmUp') @@ -546,9 +610,9 @@ public function testRouteCollection() { list($low, $high) = $this->createRouterMocks(); $lowcol = new RouteCollection(); - $lowcol->add('low', $this->buildMock('Symfony\\Component\\Routing\\Route')); + $lowcol->add('low', $this->buildMock('Symfony\Component\Routing\Route')); $highcol = new RouteCollection(); - $highcol->add('high', $this->buildMock('Symfony\\Component\\Routing\\Route')); + $highcol->add('high', $this->buildMock('Symfony\Component\Routing\Route')); $low ->expects($this->once()) @@ -565,11 +629,11 @@ public function testRouteCollection() $this->router->add($high, 100); $collection = $this->router->getRouteCollection(); - $this->assertInstanceOf('Symfony\\Component\\Routing\\RouteCollection', $collection); + $this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $collection); $names = array(); foreach ($collection->all() as $name => $route) { - $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $route); + $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); $names[] = $name; } $this->assertEquals(array('high', 'low'), $names); @@ -602,9 +666,9 @@ public function testSupport() protected function createRouterMocks() { return array( - $this->getMock('Symfony\\Component\\Routing\\RouterInterface'), - $this->getMock('Symfony\\Component\\Routing\\RouterInterface'), - $this->getMock('Symfony\\Component\\Routing\\RouterInterface'), + $this->getMock('Symfony\Component\Routing\RouterInterface'), + $this->getMock('Symfony\Component\Routing\RouterInterface'), + $this->getMock('Symfony\Component\Routing\RouterInterface'), ); } } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php index 16d3605712ab21ba67fc4818b89f7db81997b976..58854e95bafaacdbb95f8278e00651ff9ac3f85a 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ContentAwareGeneratorTest.php @@ -1,8 +1,18 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Routing; -use Symfony\Cmf\Component\Routing\RouteAwareInterface; +use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface; use Symfony\Cmf\Component\Routing\ContentAwareGenerator; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; @@ -22,11 +32,11 @@ class ContentAwareGeneratorTest extends CmfUnitTestCase public function setUp() { - $this->contentDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\RouteAwareInterface'); - $this->routeDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile')); - $this->routeCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); - $this->provider = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface"); - $this->context = $this->buildMock('Symfony\\Component\\Routing\\RequestContext'); + $this->contentDocument = $this->buildMock('Symfony\Cmf\Component\Routing\RouteReferrersReadInterface'); + $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile')); + $this->routeCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); + $this->provider = $this->buildMock('Symfony\Cmf\Component\Routing\RouteProviderInterface'); + $this->context = $this->buildMock('Symfony\Component\Routing\RequestContext'); $this->generator = new TestableContentAwareGenerator($this->provider); } @@ -54,7 +64,7 @@ public function testGenerateFromContentId() ->method('getRouteByName') ; - $contentRepository = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\ContentRepositoryInterface", array('findById', 'getContentId')); + $contentRepository = $this->buildMock('Symfony\Cmf\Component\Routing\ContentRepositoryInterface', array('findById', 'getContentId')); $contentRepository->expects($this->once()) ->method('findById') ->with('/content/id') @@ -96,7 +106,7 @@ public function testGenerateEmptyRouteString() public function testGenerateRouteMultilang() { - $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile', 'getRouteContent')); + $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile', 'getContent')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -106,7 +116,7 @@ public function testGenerateRouteMultilang() ->will($this->returnValue(array($route_en, $route_de))) ; $route_en->expects($this->once()) - ->method('getRouteContent') + ->method('getContent') ->will($this->returnValue($this->contentDocument)) ; $route_en->expects($this->never()) @@ -120,9 +130,34 @@ public function testGenerateRouteMultilang() $this->assertEquals('result_url', $this->generator->generate($route_en, array('_locale' => 'de'))); } + public function testGenerateRouteMultilangDefaultLocale() + { + $route = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock'); + $route->expects($this->any()) + ->method('compile') + ->will($this->returnValue($this->routeCompiled)) + ; + $route->expects($this->any()) + ->method('getRequirement') + ->with('_locale') + ->will($this->returnValue('de|en')) + ; + $route->expects($this->any()) + ->method('getDefault') + ->with('_locale') + ->will($this->returnValue('en')) + ; + $this->routeCompiled->expects($this->any()) + ->method('getVariables') + ->will($this->returnValue(array())) + ; + + $this->assertEquals('result_url', $this->generator->generate($route, array('_locale' => 'en'))); + } + public function testGenerateRouteMultilangLocaleNomatch() { - $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile', 'getRouteContent')); + $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile', 'getContent')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -132,7 +167,7 @@ public function testGenerateRouteMultilangLocaleNomatch() ->will($this->returnValue(array($route_en, $route_de))) ; $route_en->expects($this->once()) - ->method('getRouteContent') + ->method('getContent') ->will($this->returnValue($this->contentDocument)) ; $route_en->expects($this->once()) @@ -148,7 +183,7 @@ public function testGenerateRouteMultilangLocaleNomatch() public function testGenerateNoncmfRouteMultilang() { - $route_en = $this->buildMock('Symfony\\Component\\Routing\\Route', array('getDefaults', 'compile', 'getRouteContent')); + $route_en = $this->buildMock('Symfony\Component\Routing\Route', array('getDefaults', 'compile', 'getContent')); $route_en->expects($this->once()) ->method('compile') @@ -161,7 +196,7 @@ public function testGenerateNoncmfRouteMultilang() public function testGenerateRoutenameMultilang() { $name = 'foo/bar'; - $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile', 'getRouteContent')); + $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile', 'getContent')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -176,7 +211,7 @@ public function testGenerateRoutenameMultilang() ->will($this->returnValue(array($route_en, $route_de))) ; $route_en->expects($this->once()) - ->method('getRouteContent') + ->method('getContent') ->will($this->returnValue($this->contentDocument)) ; $route_en->expects($this->never()) @@ -208,7 +243,7 @@ public function testGenerateRoutenameMultilangNotFound() public function testGenerateDocumentMultilang() { - $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile')); + $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -230,7 +265,7 @@ public function testGenerateDocumentMultilang() public function testGenerateDocumentMultilangLocaleNomatch() { - $route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile')); + $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -251,14 +286,19 @@ public function testGenerateDocumentMultilangLocaleNomatch() } /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate without any information. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateNoContent() { $this->generator->generate('', array()); } + /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate with an object that is neither a route nor route aware. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateInvalidContent() { @@ -266,7 +306,9 @@ public function testGenerateInvalidContent() } /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate with a content_id but there is no content repository. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateNoContentRepository() { @@ -278,7 +320,9 @@ public function testGenerateNoContentRepository() } /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate with content_id but the content is not found. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateNoContentFoundInRepository() { @@ -286,7 +330,7 @@ public function testGenerateNoContentFoundInRepository() ->method('getRouteByName') ; - $contentRepository = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\ContentRepositoryInterface", array('findById', 'getContentId')); + $contentRepository = $this->buildMock('Symfony\Cmf\Component\Routing\ContentRepositoryInterface', array('findById', 'getContentId')); $contentRepository->expects($this->once()) ->method('findById') ->with('/content/id') @@ -298,7 +342,9 @@ public function testGenerateNoContentFoundInRepository() } /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate with content_id but the object at id is not route aware. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateWrongContentClassInRepository() { @@ -306,7 +352,7 @@ public function testGenerateWrongContentClassInRepository() ->method('getRouteByName') ; - $contentRepository = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\ContentRepositoryInterface", array('findById', 'getContentId')); + $contentRepository = $this->buildMock('Symfony\Cmf\Component\Routing\ContentRepositoryInterface', array('findById', 'getContentId')); $contentRepository->expects($this->once()) ->method('findById') ->with('/content/id') @@ -318,7 +364,9 @@ public function testGenerateWrongContentClassInRepository() } /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate from a content that has no routes associated. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateNoRoutes() { @@ -329,7 +377,9 @@ public function testGenerateNoRoutes() $this->generator->generate($this->contentDocument); } /** - * @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException + * Generate from a content that returns something that is not a route as route. + * + * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testGenerateInvalidRoute() { @@ -340,6 +390,32 @@ public function testGenerateInvalidRoute() $this->generator->generate($this->contentDocument); } + public function testGetLocaleAttribute() + { + $this->generator->setDefaultLocale('en'); + + $attributes = array('_locale' => 'fr'); + $this->assertEquals('fr', $this->generator->getLocale($attributes)); + } + + public function testGetLocaleDefault() + { + $this->generator->setDefaultLocale('en'); + + $attributes = array(); + $this->assertEquals('en', $this->generator->getLocale($attributes)); + } + + public function testGetLocaleContext() + { + $this->generator->setDefaultLocale('en'); + + $this->generator->getContext()->setParameter('_locale', 'de'); + + $attributes = array(); + $this->assertEquals('de', $this->generator->getLocale($attributes)); + } + public function testSupports() { $this->assertTrue($this->generator->supports('')); @@ -351,7 +427,7 @@ public function testSupports() public function testGetRouteDebugMessage() { $this->assertContains('/some/content', $this->generator->getRouteDebugMessage(null, array('content_id' => '/some/content'))); - $this->assertContains('/some/content', $this->generator->getRouteDebugMessage(new RouteAware())); + $this->assertContains('Route aware content Symfony\Cmf\Component\Routing\Tests\Routing\RouteAware', $this->generator->getRouteDebugMessage(new RouteAware())); $this->assertContains('/some/content', $this->generator->getRouteDebugMessage('/some/content')); } } @@ -365,16 +441,18 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa { return 'result_url'; } + + // expose as public + public function getLocale($parameters) + { + return parent::getLocale($parameters); + } } -class RouteAware implements RouteAwareInterface +class RouteAware implements RouteReferrersReadInterface { public function getRoutes() { return array(); } - public function __toString() - { - return '/some/content'; - } } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/DynamicRouterTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/DynamicRouterTest.php index b205ee199b87ec5a62ca39ce27a026d3d21be86a..0a817e0c030437d6492287d90aa0b6ad1ebe8aa7 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/DynamicRouterTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/DynamicRouterTest.php @@ -1,7 +1,19 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Routing; +use Symfony\Cmf\Component\Routing\Event\Events; +use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouteCollection; @@ -18,19 +30,19 @@ class DynamicRouterTest extends CmfUnitTestCase /** @var DynamicRouter */ protected $router; protected $context; - protected $request; + public $request; protected $url = '/foo/bar'; public function setUp() { - $this->routeDocument = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults')); + $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults')); - $this->matcher = $this->buildMock('Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface'); - $this->generator = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\VersatileGeneratorInterface', array('supports', 'generate', 'setContext', 'getContext', 'getRouteDebugMessage')); - $this->enhancer = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Enhancer\\RouteEnhancerInterface', array('enhance')); + $this->matcher = $this->buildMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $this->generator = $this->buildMock('Symfony\Cmf\Component\Routing\VersatileGeneratorInterface', array('supports', 'generate', 'setContext', 'getContext', 'getRouteDebugMessage')); + $this->enhancer = $this->buildMock('Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface', array('enhance')); - $this->context = $this->buildMock('Symfony\\Component\\Routing\\RequestContext'); + $this->context = $this->buildMock('Symfony\Component\Routing\RequestContext'); $this->request = Request::create($this->url); $this->router = new DynamicRouter($this->context, $this->matcher, $this->generator); @@ -49,7 +61,7 @@ public function testContext() public function testRouteCollection() { $collection = $this->router->getRouteCollection(); - $this->assertInstanceOf('Symfony\\Component\\Routing\\RouteCollection', $collection); + $this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $collection); // TODO: once this is implemented, check content of collection } @@ -113,7 +125,7 @@ public function testGetMatcher() ->with($this->equalTo($this->context)); $matcher = $this->router->getMatcher(); - $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface', $matcher); + $this->assertInstanceOf('Symfony\Component\Routing\Matcher\UrlMatcherInterface', $matcher); $this->assertSame($this->matcher, $matcher); } @@ -152,7 +164,7 @@ public function testMatchRequestWithUrlMatcher() $this->enhancer->expects($this->once()) ->method('enhance') // somehow request object gets confused, check on instance only - ->with($this->equalTo($routeDefaults), $this->isInstanceOf('Symfony\\Component\\HttpFoundation\\Request')) + ->with($this->equalTo($routeDefaults), $this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) ->will($this->returnValue($expected)) ; @@ -165,7 +177,7 @@ public function testMatchRequest() { $routeDefaults = array('foo' => 'bar'); - $matcher = $this->buildMock('Symfony\\Component\\Routing\\Matcher\\RequestMatcherInterface', array('matchRequest', 'setContext', 'getContext')); + $matcher = $this->buildMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface', array('matchRequest', 'setContext', 'getContext')); $router = new DynamicRouter($this->context, $matcher, $this->generator); $matcher->expects($this->once()) @@ -177,7 +189,7 @@ public function testMatchRequest() $expected = array('this' => 'that'); $this->enhancer->expects($this->once()) ->method('enhance') - ->with($this->equalTo($routeDefaults), $this->equalTo($this->request)) // TODO: why do we not get the right thing? + ->with($this->equalTo($routeDefaults), $this->equalTo($this->request)) ->will($this->returnValue($expected)) ; @@ -210,7 +222,7 @@ public function testMatchFilter() */ public function testMatchRequestFilter() { - $matcher = $this->buildMock('Symfony\\Component\\Routing\\Matcher\\RequestMatcherInterface', array('matchRequest', 'setContext', 'getContext')); + $matcher = $this->buildMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface', array('matchRequest', 'setContext', 'getContext')); $router = new DynamicRouter($this->context, $matcher, $this->generator, '#/different/prefix.*#'); $router->addRouteEnhancer($this->enhancer); @@ -231,7 +243,7 @@ public function testMatchRequestFilter() */ public function testMatchUrlWithRequestMatcher() { - $matcher = $this->buildMock('Symfony\\Component\\Routing\\Matcher\\RequestMatcherInterface', array('matchRequest', 'setContext', 'getContext')); + $matcher = $this->buildMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface', array('matchRequest', 'setContext', 'getContext')); $router = new DynamicRouter($this->context, $matcher, $this->generator); $router->match($this->url); @@ -262,4 +274,50 @@ public function testRouteDebugMessageNonversatile() $router = new DynamicRouter($this->context, $this->matcher, $generator); $this->assertInternalType('string', $router->getRouteDebugMessage('test')); } + + public function testEventHandler() + { + $eventDispatcher = $this->buildMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $router = new DynamicRouter($this->context, $this->matcher, $this->generator, '', $eventDispatcher); + + $eventDispatcher->expects($this->once()) + ->method('dispatch') + ->with(Events::PRE_DYNAMIC_MATCH, $this->equalTo(new RouterMatchEvent())) + ; + + $routeDefaults = array('foo' => 'bar'); + $this->matcher->expects($this->once()) + ->method('match') + ->with($this->url) + ->will($this->returnValue($routeDefaults)) + ; + + $this->assertEquals($routeDefaults, $router->match($this->url)); + } + + public function testEventHandlerRequest() + { + $eventDispatcher = $this->buildMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $router = new DynamicRouter($this->context, $this->matcher, $this->generator, '', $eventDispatcher); + + $that = $this; + $eventDispatcher->expects($this->once()) + ->method('dispatch') + ->with(Events::PRE_DYNAMIC_MATCH_REQUEST, $this->callback(function($event) use ($that) { + $that->assertInstanceOf('Symfony\Cmf\Component\Routing\Event\RouterMatchEvent', $event); + $that->assertEquals($that->request, $event->getRequest()); + + return true; + })) + ; + + $routeDefaults = array('foo' => 'bar'); + $this->matcher->expects($this->once()) + ->method('match') + ->with($this->url) + ->will($this->returnValue($routeDefaults)) + ; + + $this->assertEquals($routeDefaults, $router->matchRequest($this->request)); + } } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ProviderBasedGeneratorTest.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ProviderBasedGeneratorTest.php index e2fb96781b8796c44d5ca9d91448e2ac22967694..17a28f444894c75b5bdbfe40a4e548803dd1a280 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ProviderBasedGeneratorTest.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ProviderBasedGeneratorTest.php @@ -1,8 +1,19 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Routing; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\Route; use Symfony\Cmf\Component\Routing\ProviderBasedGenerator; @@ -20,10 +31,10 @@ class ProviderBasedGeneratorTest extends CmfUnitTestCase public function setUp() { - $this->routeDocument = $this->buildMock('Symfony\\Component\\Routing\\Route', array('getDefaults', 'compile')); - $this->routeCompiled = $this->buildMock('Symfony\\Component\\Routing\\CompiledRoute'); - $this->provider = $this->buildMock("Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface"); - $this->context = $this->buildMock('Symfony\\Component\\Routing\\RequestContext'); + $this->routeDocument = $this->buildMock('Symfony\Component\Routing\Route', array('getDefaults', 'compile')); + $this->routeCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); + $this->provider = $this->buildMock('Symfony\Cmf\Component\Routing\RouteProviderInterface'); + $this->context = $this->buildMock('Symfony\Component\Routing\RequestContext'); $this->generator= new TestableProviderBasedGenerator($this->provider); } @@ -87,6 +98,30 @@ public function testGetRouteDebugMessage() $this->assertContains('/de/test', $this->generator->getRouteDebugMessage(new Route('/de/test'))); $this->assertContains('/some/route', $this->generator->getRouteDebugMessage('/some/route')); } + + /** + * Tests the generate method with passing in a route object into generate(). + * + * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException + */ + public function testGenerateByRoute() + { + $this->generator = new ProviderBasedGenerator($this->provider); + + // Setup a route with a numeric parameter, but pass in a string, so it + // fails and getRouteDebugMessage should be triggered. + $route = new Route('/test'); + $route->setPath('/test/{number}'); + $route->setRequirement('number', '\+d'); + + $this->generator->setStrictRequirements(true); + + $context = new RequestContext(); + $this->generator->setContext($context); + + $this->assertSame(null, $this->generator->generate($route, array('number' => 'string'))); + + } } /** @@ -107,7 +142,7 @@ public function getRouteKey() return '/some/key'; } - public function getRouteContent() + public function getContent() { return null; } diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/RouteMock.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/RouteMock.php index d92232c8fdef639fb425097e8849692d83db3ed0..b8da84f862886e0b24be8e7317724d4834f76c1d 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/RouteMock.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/RouteMock.php @@ -1,4 +1,15 @@ <?php + +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing\Tests\Routing; use Symfony\Component\Routing\Route as SymfonyRoute; @@ -13,10 +24,12 @@ public function setLocale($locale) { $this->locale = $locale; } - public function getRouteContent() + + public function getContent() { return null; } + public function getDefaults() { $defaults = array(); @@ -26,6 +39,7 @@ public function getDefaults() return $defaults; } + public function getRequirement($key) { if (! $key == '_locale') { @@ -34,6 +48,7 @@ public function getRequirement($key) return $this->locale; } + public function getRouteKey() { return null; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/bootstrap.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/bootstrap.php index 9f020f96a5a4cfa3573ed79f9faaa14d65506025..ae7e2d78fe44d43b7a79cce3da6ce37aae108a43 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/bootstrap.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/bootstrap.php @@ -8,7 +8,7 @@ require_once $file; spl_autoload_register(function($class) { - if (0 === strpos($class, 'Symfony\\Cmf\\Component\\Routing\\')) { + if (0 === strpos($class, 'Symfony\Cmf\Component\Routing\\')) { $path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 4)).'.php'; if (!stream_resolve_include_path($path)) { return false; diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/VersatileGeneratorInterface.php b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/VersatileGeneratorInterface.php index 24f8210ab6b009c96a13b27b2957ee2a2fe95cc1..cf011c256142f1861e68a58686838f3ea985fd35 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/VersatileGeneratorInterface.php +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/VersatileGeneratorInterface.php @@ -1,5 +1,15 @@ <?php +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2013 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Symfony\Cmf\Component\Routing; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -29,7 +39,7 @@ public function supports($name); * * @param mixed $name * @param array $parameters which should contain a content field containing - * a RouteAwareInterface object + * a RouteReferrersReadInterface object * * @return string */ diff --git a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json index 63cfa9b29386fcd5a51b2bd058615eb1dc69850e..f2220d342906b9ef39953977673b293da9ae578f 100644 --- a/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json +++ b/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/composer.json @@ -18,8 +18,13 @@ "symfony/http-kernel": "~2.2", "psr/log": "~1.0" }, + "require-dev": { + "symfony/dependency-injection": "~2.0", + "symfony/config": "~2.2", + "symfony/event-dispatcher": "~2.1" + }, "suggest": { - "symfony/http-foundation": "ChainRouter/DynamicRouter have optional support for Request instances, several enhancers require a Request instances, ~2.2" + "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1" }, "autoload": { "psr-0": { "Symfony\\Cmf\\Component\\Routing": "" }