/** * @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)); }
/** * @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); }
/** * Returns the NEON representation of a value. * @param mixed * @param int * @return string */ public static function encode($var, $options = NULL) { $encoder = new Encoder(); return $encoder->encode($var, $options); }