Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Расширение для twig (Twig_Extension) - error 500


Recommended Posts

Добрый день форумчане, не спрашивайте почему мне это понадобилось,но мне нужно написать небольшое расширение для twig.(а в твиге я особо не шарю)
для этого system/library/template/Twig/Extension/ создал файл RrequestUrl.php с наследуемым классом Twig_Extension вот содержимое.


 * This file is part of Twig.
 * (c) 2012 Fabien Potencier
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
class Twig_Extension_RequestUrl extends Twig_Extension
    public function getFunctions()
        return array(
            new Twig_SimpleFunction('request_uri',  'request_uri'),

    public function getName()
        return 'request_uri';

function request_uri()
    return $_SERVER['request_uri'];

Далее я подключаю данное расширение вот тут system/library/template/Twig/Environment.php 

 $this->addExtension(new Twig_Extension_Core());
 $this->addExtension(new Twig_Extension_Debug());
 $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
 $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
 $this->addExtension(new Twig_Extension_RequestUrl());//мое расширение

и вот тут я получаю ошибку HTTP ERROR 500 

и так вопрос как правильно соз
дается расширение для twig

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.