1
私が書いたTwig Extention関数へのアクセスを試みます。TwigビューのTwig Extention関数へのアクセス
// AppBundle/Twig/AppExtention.php
namespace AppBundle\Twig;
class AppExtension extends \Twig_Extension
{
public function getFunctions() {
return [
new \Twig_Function('testMethod', 'testMethod'),
];
}
public function testMethod() {
return 'blubb';
}
}
今私は{{ testMethod() }}
によって目的球にアクセスしようと、私は次のエラーを取得する:
UndefinedFunctionException in <Hex for cached view>.php line 68: Attempted to call function "testMethod" from the global namespace.
私はキャッシュをクリアしてエラーを検索してみましたが、私はそれは何も見つかりませんでした助けて頂きました。多分ここに誰かを助けることができます。
OKああ、はい、私の場合、私が '' Twig_SimpleFunction''を使用する必要があります。ありがとうございました! – mgluesenkamp