Twig_Environment::getCompiler PHP Method

getCompiler() public method

Gets the Compiler instance.
public getCompiler ( ) : Twig_CompilerInterface
return Twig_CompilerInterface A Twig_CompilerInterface instance
    public function getCompiler()
    {
        if (null === $this->compiler) {
            $this->compiler = new Twig_Compiler($this);
        }

        return $this->compiler;
    }

Same methods

Twig_Environment::getCompiler ( )

Usage Example

 public function testCompileClassConstant()
 {
     $expression = new StaticConstantExpression('\\StaticConstantExpressionTest::SOME_VALUE', 1);
     $this->assertEquals('\\StaticConstantExpressionTest::SOME_VALUE', $this->environment->getCompiler()->compile($expression)->getSource());
 }