Ejemplo n.º 1
0
 /**
  * Build the template file indicated by key into string. Use data in
  * the dictionary as scope
  *
  * @param   string  $key    template file identifier
  * @param   array   $data   used for private scope
  * @return  string
  */
 public function build()
 {
     $file = $this->getFile();
     $finder = new FileFinder('resource');
     $absolute = $finder->getPath($file);
     if (!$finder->fileExists($absolute, false)) {
         $err = "template file not found at -({$absolute})";
         throw new DomainException($err, 404);
     }
     $data = $this->getAll();
     $compositor = new SqlFileCompositor();
     $compositor->setDbMap($this->getDbMap());
     return $compositor->compose($absolute, $data);
 }
Ejemplo n.º 2
0
 /**
  * Here we use a file that is known to exist. At the following location:
  * <base-path>/test/resource/testfuel/test-file.txt is a file added to 
  * so that we could test file level operation. 
  *
  * @test
  * @return	null
  */
 public function fileExistsBasePath()
 {
     $root = 'test/resource/testfuel';
     $finder = new FileFinder($root);
     $this->assertTrue($finder->fileExists('test-file.txt'));
     $this->assertFalse($finder->fileExists('does-not-exist'));
     $absolute = $this->getBasePath() . '/' . $root . '/test-file.txt';
     $this->assertTrue($finder->fileExists($absolute, false));
 }