Esempio n. 1
0
 /**
  * @param array $data
  */
 private function setConfigData(array $data)
 {
     $encoder = new Nette\Neon\Encoder();
     $file = new File($this->getConfig() . self::LOCAL);
     $file->createNewFile();
     $file->rewriteSafe($encoder->encode($data));
 }
Esempio n. 2
0
 protected function compile()
 {
     $contents = $this->content ?: $this->file->read();
     $contents = str_replace(array_keys($this->phpTags), array_values($this->phpTags), $contents);
     // Escape php tags
     $contents = '<?php set_error_handler($_errorHandler);unset($_errorHandler); ?>' . $contents . '<?php restore_error_handler(); ?>';
     $replace = [];
     preg_match_all('#\\{(!?\\$[\\w]+)\\}#', $contents, $matches);
     // {[!]$var}
     foreach ($matches[1] as $match) {
         $full = '{' . $match . '}';
         $var = str_replace(['!'], '', $match);
         if (!in_array($var, $this->forbidden)) {
             $replace[$full] = $this->echoVar($var, !$this->autoEscape ? FALSE : !Strings::startsWith($match, '!'));
         }
     }
     $contents = str_replace(array_keys($replace), array_values($replace), $contents);
     $this->createCache($contents);
 }