public function updateGeneratedResources() { foreach ($this->constants as $value) { $this->constantGenerator->generateFromNeonFile($this->configuration->getDir() . DIRECTORY_SEPARATOR . $value); } foreach ($this->values as $value) { $this->valueGenerator->generateFromNeonFile($this->configuration->getDir() . DIRECTORY_SEPARATOR . $value); } }
/** * @param string $path */ public function generateFromNeonFile($path) { $definition = Neon::decode(file_get_contents($path)); assert(isset($definition['class'])); assert(isset($definition['type'])); assert($definition['type'] === 'in-place'); $data = $definition['data']; $output = $this->configuration->getDir() . DIRECTORY_SEPARATOR . $this->configuration->getOutputFolder() . DIRECTORY_SEPARATOR . $definition['class'] . '.php'; $consts = Helper::createStringConstants($data); $node = $this->createClassFromData($definition['class'], $this->configuration->getNamespace(), $consts); $prettyPrinter = new PrettyPrinter\Standard(); file_put_contents($output, $prettyPrinter->prettyPrintFile([$node])); }
/** * @param array $definition * * @param string|null $addNamespace * * @return array */ private function getNamespace(array $definition, $addNamespace = null) { if (isset($definition['addNamespace'])) { $addNamespace = $addNamespace === null ? $definition['addNamespace'] : $definition['addNamespace'] . '\\' . $addNamespace; } $namespace = $addNamespace === null ? $this->configuration->getNamespace() : $this->configuration->getNamespace() . '\\' . $addNamespace; return $namespace; }