Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "application"

Change app by routing class

Create a file into lib/routing/sfChangeAppRoute.class.php and paste :

<?php
 
class sfChangeAppRoute extends sfRoute{
 
    public function generate($params, $context = array(), $absolute = true)
  {
 
    if(!array_key_exists('app',$params))
        return parent::generate($params, $context, $absolute);
 
 
    $app_name=sfContext::getInstance()->getConfiguration()->getApplication();
    $env_name=sfContext::getInstance()->getConfiguration()->getEnvironment();
    if($env_name=='prod')
        $env='';
    else
        $env='_'.$env_name;
 
    $url='/../'.$params['app'].$env.'.php';
 
    return $url;
  }
 
}
 
?>
 

Now into your routing.yml

app:
  url: /application/:app
  params: {  }
  class:  sfChangeAppRoute
 

And after that you could use the route @app?app=MY_other_app

by excessive demon on 2009-08-26, tagged application  routing  url 
(1 comment)

baseurl_for with an external application

Here is a usefull helper to calculate url for another application :

function baseurl_for($application, $absolute = false)
{
    $url = $absolute ? 'http://' . $_SERVER["HTTP_HOST"] : '';
    $url .= '/' . $application . (SF_ENVIRONMENT != 'prod' ? '_' . SF_ENVIRONMENT : '') . '.php/';
    return $url;
}

in the action :

<?php echo link_to('Whatever', baseurl_for('application', true) . 'module/action') ?>

I really feel like this feature is missing, hope this could added soon ;) ... example corrected (but sadly not so usefull) according to francois's comment.

by brikou on 2006-11-24, tagged application  base  helper  url 
(4 comments)