Symfony2 - checking if file exists

前端 未结 6 1235
执笔经年
执笔经年 2020-12-05 05:59

I have a loop in Twig template, which returns multiple values. Most important - an ID of my entry. When I didn\'t use any framework nor template engine, I used simply

6条回答
  •  無奈伤痛
    2020-12-05 06:16

    Just add a little comment to the contribution of Sybio:

    The Twig_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.

    We must change the class Twig_Function_Function by Twig_SimpleFunction:

     new \Twig_Function_Function('file_exists'), // Old class
                'file_exists' => new \Twig_SimpleFunction('file_exists', 'file_exists'), // New class
            );
        }
    
        public function getName()
        {
            return 'twig_extension';
        }
    }
    

    The rest of code still works exactly as said Sybio.

提交回复
热议问题