/**
  * Builds the settings file
  */
 public function build()
 {
     /**
      * To get a clean PHP source code from the getLocalDateTimeFormat()
      * We use the var_export(...) function
      */
     $header = "<?php ";
     $settings = var_export(array('datetimeFormat' => $this->config->getLocalDateTimeFormat()), true);
     $tmpFile = TEMP_DIR . '/' . uniqid() . '.php';
     file_put_contents($tmpFile, $header . $settings);
     $settings = php_strip_whitespace($tmpFile);
     unlink($tmpFile);
     render_php_template(dirname(__FILE__) . '/Template/datetime.php', ['settings' => trim(str_replace($header, '', $settings)), 'namespace' => $this->config->getApplicationNamespace() . '\\' . $this->config->getModelRootNamespace()], $this->config->getTargetRootFolder() . '/Database/DateTimeConversion.php', false);
 }
Esempio n. 2
0
 /**
  * Load the Schema information from the database that is configured in the
  * config.json
  * @return boolean
  */
 protected function loadDatabaseSchema()
 {
     $database = $this->createDatabaseInstance();
     $schemaReader = new SchemaReader($database);
     $schemas = $schemaReader->load();
     if (is_null($this->config->getSchemaListToGenerate())) {
         $this->schemas = $schemas;
     } else {
         foreach ($this->config->getSchemaListToGenerate() as $name) {
             if (isset($schemas[$name])) {
                 $this->schemas[$name] = $schemas[$name];
             } else {
                 $this->output->writeln("<error>There is no [{$name}] schema in this database.</error>");
             }
         }
     }
     if (!isset($this->schemas['public'])) {
         $this->output->writeln("<warn>WARNING: The [public] schema from your database was not selected!</warn>");
     }
     return true;
 }