예제 #1
0
파일: ResMan.php 프로젝트: DTForce/resman
 /**
  * @param string $file
  *
  * @return Configuration
  */
 private function readConfiguration($file)
 {
     $definition = Neon::decode(file_get_contents($file));
     $dir = dirname($file);
     assert(isset($definition['namespace']));
     assert(isset($definition['output']));
     $this->constants = isset($definition['constants']) ? $definition['constants'] : [];
     $this->values = isset($definition['values']) ? $definition['values'] : [];
     Helper::rmDirRec($dir . DIRECTORY_SEPARATOR . $definition['output'], true);
     return new Configuration($definition['output'], $definition['namespace'], $dir);
 }
예제 #2
0
 /**
  * @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]));
 }
예제 #3
0
 /**
  * @param $versions
  * @param $actualDir
  *
  * @return array
  */
 private function loadCsvVersions($versions, $actualDir)
 {
     $result = [];
     foreach ($versions as $name => $version) {
         $dir = new DirectoryIterator($actualDir . DIRECTORY_SEPARATOR . $version);
         foreach ($dir as $file) {
             if (!$file->isDir()) {
                 $tableName = $file->getBasename(".csv");
                 $result[$name][$tableName] = Helper::readCsvValues($file->getRealPath());
             }
         }
     }
     return $result;
 }