Exemplo n.º 1
0
 /**
  * @param string $path
  * @param string $find
  * @param int $depth
  */
 public function addAutoloadConfig($path, $find = 'config.neon', $depth = -1)
 {
     // Development
     if (!$this->cacheConfig && $this->isDevelopment()) {
         foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
             $this->addConfig((string) $file);
         }
         return;
     }
     // Production
     $directory = $this->parameters['tempDir'] . '/cache/configs';
     $cachePath = $directory . '/' . Strings::webalize(str_replace(dirname($this->parameters['appDir']), '', $path)) . '.neon';
     if (file_exists($cachePath)) {
         $this->addConfig($cachePath);
         return;
     }
     $encoder = new Encoder();
     $decoder = new Decoder();
     @mkdir($directory);
     $content = [];
     foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
         $content = Helpers::merge($content, $decoder->decode(file_get_contents($file)));
     }
     file_put_contents($cachePath, $encoder->encode($content));
     $this->addConfig($cachePath);
 }
Exemplo n.º 2
0
 /**
  * @return array
  */
 private function getConfigData()
 {
     if ($this->data) {
         return $this->data;
     }
     $decoder = new Nette\Neon\Decoder();
     return $this->data = $decoder->decode($this->getContentsConfig());
 }
Exemplo n.º 3
0
 private function readFile($file)
 {
     $neonDecoder = new Decoder();
     if (!is_file($file)) {
         throw new ContainerFactoryException("Config file '{$file}' not found.");
     }
     if (!is_readable($file)) {
         throw new ContainerFactoryException("Config file '{$file}' not readable.");
     }
     return $neonDecoder->decode(file_get_contents($file));
 }
Exemplo n.º 4
0
 /**
  * Decodes a NEON string.
  * @param  string
  * @return mixed
  */
 public static function decode($input)
 {
     $decoder = new Decoder();
     return $decoder->decode($input);
 }
Exemplo n.º 5
0
 /**
  * Parse a NEON string.
  *
  * @param  string
  * @return mixed
  */
 public function parse($input)
 {
     return Neon\Decoder::decode($input);
 }