All pastes #1082525 Raw Edit

Untitled

public php v1 · immutable
#1082525 ·published 2008-07-25 12:50 UTC
rendered paste body
function cross_app_link_to($app, $route, $args=null){  /**   * Don't try to generate routes for the current app   */  $currentApp = sfConfig::get('sf_app') ;  sfConfig::set('foo', 'bar') ;  $currentConfig = sfConfig::getAll() ;    if ($app != $currentApp)   {    sfContext::getInstance()->switchTo($app);    $currentRoutes = sfContext::getInstance()->getRouting()->getRoutes() ;  }  $uri = $route ;  if (is_array($args))  {    foreach($args as $k => $v)    {      $uri .= ($uri == $route) ?  '?' : '&' ;      $uri .= $k . '=' . $v ;    }  }  /** we need a little hack because url_for() returns the url only for the    * current app. It's not a problem in prod mode because the script name   * is hidden but in dev mode, the link doesn't point to the good app    * controller*/  if (!function_exists('url_for'))  {    require(sfConfig::get('sf_symfony_lib_dir') . DIRECTORY_SEPARATOR . 'helper' .      DIRECTORY_SEPARATOR . 'UrlHelper.php') ;  }  $url = url_for($uri, true) ;  if (sfConfig::get('sf_environment') == 'dev')  {    $url = str_replace($currentApp . '_', $app . '_', $url) ;  }  /**   * Reset the app switch if needed    */  if ($app != $currentApp)   {    sfContext::getInstance()->switchTo($currentApp);    $currentRoutes = sfContext::getInstance()->getRouting()->getRoutes() ;  }  foreach($currentConfig as $k => $v)  {    sfConfig::set($k, $v) ;  }  return $url ;} // cross_app_link_to