2011-12-19 14 views
8

symfony routing.yml ile frontend güzel url yaptım. önyüzdeki i örneğin kullanabilirsiniz:url_for frontend için arka ucunda - Symfony

http://mysite.com/frontend_dev.php/news/nice-title/1 

ama arka uç bu kullanırsanız i var:

url_for('@news', $news); 

bu benim için üretmek

http://mysite.com/backend_dev.php/news/nice-title/1 

mümkündür

bu bağlantı oluşturmak ön uç için arka uç? uygulamalarda

cevap

10

/kullanıcı arayüzü/config/frontendConfiguration.class.php böyle bir şey kullanın:

class frontendConfiguration extends sfApplicationConfiguration 
{ 
    protected $backendRouting = null; 

    public function generateBackendUrl($name, $parameters = array(), $absolute = false) 
    { 
    return sfConfig::get('app_site_url').$this->getBackendRouting()->generate($name, $parameters, $absolute); 
    } 

    public function getBackendRouting() 
    { 
    if (!$this->backendRouting) 
    { 
     $this->backendRouting = new sfPatternRouting(new sfEventDispatcher()); 

     $config = new sfRoutingConfigHandler(); 
     $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir').'/backend/config/routing.yml')); 

     $this->backendRouting->setRoutes($routes); 
    } 

    return $this->backendRouting; 
    } 
} 

bu gibi kullanmak:

$sf_context->getConfiguration()->generateBackendUrl('my_custom_route', array('id' => 1), true) 
burada

fazla bilgi: http://symfony.com/blog/cross-application-links