decode() 공개 메소드

Decodes a NEON string.
public decode ( $input ) : mixed
리턴 mixed
예제 #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);
 }
예제 #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());
 }
예제 #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));
 }
예제 #4
0
 /**
  * Decodes a NEON string.
  * @param  string
  * @return mixed
  */
 public static function decode($input)
 {
     $decoder = new Decoder();
     return $decoder->decode($input);
 }
예제 #5
0
 /**
  * Parse a NEON string.
  *
  * @param  string
  * @return mixed
  */
 public function parse($input)
 {
     return Neon\Decoder::decode($input);
 }