Esempio n. 1
0
 protected function setUp()
 {
     $cluster = new Cluster();
     $schema = $this->getSchema();
     $cluster->addSchema($schema);
     $this->generator = new Generator();
 }
Esempio n. 2
0
 public function __construct(Config $config, $db)
 {
     $outputDir = $config->getParameter('output-dir');
     if (!$outputDir) {
         $console = Console::getInstance();
         $console->write("Unknown output dir. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     if (!is_dir($outputDir) || !is_writeable($outputDir)) {
         $console = Console::getInstance();
         $console->write("Unknown output dir not exists or not writable. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     $this->setOutDir($outputDir);
     $this->cluster = new Cluster();
     $this->cluster->addSchema((new Schema($db))->init());
     $configPath = $config->getParameter('config', __DIR__ . '/models.json');
     if (!is_file($configPath) || !is_readable($configPath)) {
         $console = Console::getInstance();
         $console->write("Config file not exists or not readable. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     $generatorConfig = json_decode(file_get_contents($configPath), true);
     if (!$generatorConfig) {
         $console = Console::getInstance();
         $console->write("Bad config file. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     $this->setGeneratorConfig($generatorConfig);
     // Register plugins
     $plugins = isset($generatorConfig['plugins']) ? $generatorConfig['plugins'] : array();
     if (!empty($plugins)) {
         $this->registerPlugins($plugins);
     }
     $this->config = $config;
 }
Esempio n. 3
0
 protected function setUp()
 {
     $this->cluster = new \Model\Cluster();
     $schema = $this->getSchema();
     $this->cluster->addSchema($schema);
 }