Exemplo n.º 1
0
 public function putContent(ContentEntity $entity)
 {
     // This can potentially not work
     $folder = realpath($this->location);
     if (is_writable($folder) === false) {
         throw new \RuntimeException('Cannot find static templates location: ' . $this->location);
     }
     $filename = $folder . '/' . $entity->getName() . '.html.twig';
     $template = $this->twig->render('JadeITApplicationBundle:Content:static.html.twig.twig', array('content' => trim($entity->getContent())));
     // All code except the return can be replace by this one line once it's live
     // in Symfony
     //$this->fileSystem->dumpFile($filename, $template. 0644);
     if (is_writable(dirname($filename)) === false) {
         throw new \RuntimeException('Cannot write to static templates location: ' . dirname($filename));
     }
     $result = file_put_contents($filename, $template);
     return $template;
 }