twig - Symfony2: How to set the root path in a Symfony CLI command -
edit: cut short: there way call $kernel->getrootdir(); within twig extension? or maybe di container?
original question:
i try scale images on server using imagine. works fine log don't try trigger rendering via command line: in case looks there wrong path set- i'm getting error:
[twig_error_runtime]
an exception has been thrown during rendering of template ("file ../web/documents/4f59ef3f76e74_test3.jpg doesn't exist") in "....:detail.html.twig" @ line 72.
i'm using twig tag wrote myself:
public function thumbnail($path,$width,$maxheight=0,$alt="",$absolute=false){ /* @var $imagine \imagine\gd\imagine */ $imagine = $this->container->get('imagine'); //$box = new \imagine\image\box($width, $height); /* @var $image \imagine\image\imageinterface */ $image = $imagine->open("../web/".$path); ...
i tried (both works when render template via browser request)
$image = $imagine->open($path);
$path set "documents/4f59ef3f76e74_test3.jpg" "documents/" sub directory of "web"
any ideas?
ha- found it! retrieves absolute system file path of web folder:
$webroot = $this->container->get('kernel')->getrootdir()."/../web";
Comments
Post a Comment