コード例 #1
0
 /**
  * Render template.
  *
  * @access public
  * @param  string $template
  * @param  array  $context  (default: array())
  * @return string
  */
 public function render($template, array $context = array())
 {
     $hash = hash('md5', $template);
     $file = $hash . '.twig';
     if (!$this->cacheHandler->exists($file)) {
         $this->cacheHandler->save($file, $template);
     }
     return $this->twig->render($file, $context);
 }
コード例 #2
0
 /**
  * Compile partials into procedure.
  *
  * @access public
  * @param  \JonnyW\PhantomJs\Procedure\ProcedureInterface $procedure
  * @param  \JonnyW\PhantomJs\Procedure\InputInterface     $input
  * @return void
  */
 public function compile(ProcedureInterface $procedure, InputInterface $input)
 {
     $cacheKey = sprintf('phantomjs_%s_%s', $input->getType(), md5($procedure->getTemplate()));
     if ($this->cacheEnabled && $this->cacheHandler->exists($cacheKey)) {
         $template = $this->cacheHandler->fetch($cacheKey);
     }
     if (empty($template)) {
         $template = $this->renderer->render($procedure->getTemplate(), array('engine' => $this, 'procedure_type' => $input->getType()));
         $test = clone $procedure;
         $test->setTemplate($template);
         $compiled = $test->compile($input);
         $this->procedureValidator->validate($compiled);
         if ($this->cacheEnabled) {
             $this->cacheHandler->save($cacheKey, $template);
         }
     }
     $procedure->setTemplate($template);
 }
コード例 #3
0
ファイル: Procedure.php プロジェクト: greut/php-phantomjs
 /**
  * Write compiled procedure to cache.
  *
  * @access protected
  * @param  string $compiled
  * @return string
  */
 protected function write($compiled)
 {
     return $this->cacheHandler->save(uniqid(), $compiled);
 }
コード例 #4
0
ファイル: Procedure.php プロジェクト: sibds/study_functions
 /**
  * Write procedure script cache.
  *
  * @access protected
  * @param  string $procedure
  * @return string
  */
 protected function write($procedure)
 {
     $executable = $this->cacheHandler->save(uniqid(), $procedure);
     return $executable;
 }