/** * Returns a route instance for a given route name. * * @static * @param string $routeName Name of the route * @param sfProjectConfiguration $configuration Optionally pass a project configuration (i.e. when called from a task) * * @return sfRoute */ public static function getRoute($routeName, sfProjectConfiguration $configuration = null) { if (is_null($configuration)) { $configuration = sfProjectConfiguration::getActive(); } $routing = sfRoutingConfigHandler::getConfiguration($configuration->getConfigPaths('config/routing.yml')); if (!array_key_exists($routeName, $routing)) { throw new sfImageTransformExtraPluginConfigurationException('Route "' . $routeName . '" could not be found!'); } $route = $routing[$routeName]; return new $route['class']($route['url'], $route['param'], $route['requirements'], $route['options']); }
/** * @see sfConfigHandler */ public static function getConfiguration(array $configFiles) { // merge two arrays but put custom routes at the beginning // so that they are matched first $systemRoutes = self::getDmConfiguration(); $userRoutes = parent::getConfiguration($configFiles); foreach ($userRoutes as $key => $value) { if (array_key_exists($key, $systemRoutes)) { $systemRoutes[$key] = $value; } else { $systemRoutes = array_reverse($systemRoutes, true); $systemRoutes[$key] = $value; $systemRoutes = array_reverse($systemRoutes, true); } } return $systemRoutes; }
/** * @see sfConfigHandler */ public static function getConfiguration(array $configFiles) { return array_merge(self::getDmConfiguration(), parent::getConfiguration($configFiles)); }