2013-02-01 25 views

cevap

36

kullanmayı deneyin:

{{ app.request.uri }} 
1

dal son sürümünde artık {{app.request.uri}}

yerine {{global.request.uri}} deneyin işe değildir.

1

Alt sorgularla ilgili sorunlarınız olabilir (denetleyiciden $this->forward veya bir görünümden {{ render(controller('...')) }}), bunun için bir Twig uzantısı kullanmayı tercih ediyorum. Yukarıda sözü edildiği gibi

<?php 

namespace AppBundle\Twig\Extension; 

// ...  

class MyExtension extends \Twig_Extension 
{ 
    // ... 

    public function getFunctions() 
    { 
     return [ 
      new \Twig_SimpleFunction('current_locale', [$this, 'currentLocale']), 
      new \Twig_SimpleFunction('current_uri', [$this, 'currentUri']), 
     ]; 
    } 

    public function currentLocale() 
    { 
     return $this->get('request_stack')->getMasterRequest()->getLocale(); 
    } 

    public function currentUri() 
    { 
     return $this->get('request_stack')->getMasterRequest()->getUri(); 
    } 

    public function getName() 
    { 
     return 'my'; 
    } 
} 
1

, bazı yanıtlar artık geçerli değildir. 2017'09 itibariyle benim için çalıştı Ne

Bunu işlemek gerekir bu

{{ url('<current>') }} 
+0

olduğunu. –

İlgili konular