Exemplo n.º 1
0
 public function testRenderPHPTemplate()
 {
     $root = dirname(__FILE__) . '/fixtures';
     $result = render_php_template($root . '/template1.php', array('firstname' => 'Darth', 'lastname' => 'Vader'));
     $this->assertEquals('Hello Darth Vader', $result);
     $outfile = $root . '/out.txt';
     render_php_template($root . '/template1.php', array('firstname' => 'Luke', 'lastname' => 'Skywalker'), $outfile);
     $this->assertEquals('Hello Luke Skywalker', file_get_contents($outfile));
     unlink($outfile);
 }
 /**
  * Builds the settings file
  */
 public function build()
 {
     /**
      * To get a clean PHP source code from the getLocalDateTimeFormat()
      * We use the var_export(...) function
      */
     $header = "<?php ";
     $settings = var_export(array('datetimeFormat' => $this->config->getLocalDateTimeFormat()), true);
     $tmpFile = TEMP_DIR . '/' . uniqid() . '.php';
     file_put_contents($tmpFile, $header . $settings);
     $settings = php_strip_whitespace($tmpFile);
     unlink($tmpFile);
     render_php_template(dirname(__FILE__) . '/Template/datetime.php', ['settings' => trim(str_replace($header, '', $settings)), 'namespace' => $this->config->getApplicationNamespace() . '\\' . $this->config->getModelRootNamespace()], $this->config->getTargetRootFolder() . '/Database/DateTimeConversion.php', false);
 }
Exemplo n.º 3
0
 public function render($view, array $parameters = array())
 {
     return render_php_template($view, $this->normalizeParameters($parameters), null, $this->trimOutput);
 }
Exemplo n.º 4
0
 /**
  * Builds one or more classes based on the build definition
  * @param boolean $allowCustomize
  */
 public function build($allowCustomize)
 {
     $classes = $this->createBuildDefinition($allowCustomize);
     foreach ($classes as $def) {
         $targetFolder = $this->createTargetFolder($def);
         $targetFile = "{$targetFolder}/{$def['className']}.php";
         $def['appNamespace'] = $this->applicationNamespace;
         $def['classFQRN'] = $this->relation->getFQRN();
         render_php_template($this->template, $this->preparBuildDefinition($def), $targetFile, false);
     }
 }
Exemplo n.º 5
0
 /**
  * Render of copy the file to the correct location
  * @param Filesystem $fs
  * @param string $relativeName
  * @param SplFileInfo $source
  * @param string $dest
  * @param OutputInterface $output
  */
 private function processFile($fs, $relativeName, $source, $dest, OutputInterface $output)
 {
     if (in_array($relativeName, $this->renderTable)) {
         $output->writeln("Rendering " . $relativeName);
         render_php_template($source, $this->renderContext, $dest);
         if ($relativeName === 'bin/app') {
             chmod($dest, 0750);
         }
     } else {
         $output->writeln("Processing " . $relativeName);
         $fs->copy($source, $dest);
     }
 }