/**
  * Load table registry map
  *
  * @param Event $event
  *
  * @throws \Rad\Core\Exception\MissingBundleException
  */
 public function loadTableRegistryMap(Event $event)
 {
     foreach (Bundles::getLoaded() as $bundleName) {
         $mapDir = Bundles::getPath($bundleName) . DS . 'Domain' . DS . 'map';
         if (is_file($mapDir . DS . 'table_registry_config.php')) {
             require_once $mapDir . DS . 'table_registry_config.php';
         }
     }
 }
 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @return Phinx\Config\Config
  */
 public function getConfig()
 {
     if ($this->configuration) {
         return $this->configuration;
     }
     $dir = APP_DIR . DS . 'Resource' . DS . 'migrations';
     $migrationTable = 'phinxlog';
     if ($bundleName = $this->input->getOption('bundle')) {
         $dir = Bundles::getPath($bundleName) . DS . 'Resource' . DS . 'migrations';
     }
     return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $migrationTable, 'default_database' => getenv('RAD_ENVIRONMENT'), getenv('RAD_ENVIRONMENT') => \Rad\Configure\Config::get('migrations.environments.' . getenv('RAD_ENVIRONMENT'))]]);
 }
Example #3
0
 /**
  * Dump model classes
  *
  * @param CLImate $climate
  * @param string  $bundle
  */
 protected function dumpModelClasses(CLImate $climate, $bundle)
 {
     if (is_array($this->tablesModel[$bundle])) {
         foreach ($this->tablesModel[$bundle] as $tableSpec) {
             $alias = $tableSpec['alias'];
             if ($tableSpec['tableClass']) {
                 $tableClassPath = SRC_DIR . DS . str_replace('\\', '/', $tableSpec['tableClass']) . '.php';
                 $tableClassDir = dirname($tableClassPath);
                 $tableClassName = trim(substr($tableSpec['tableClass'], strrpos($tableSpec['tableClass'], '\\')), '\\');
                 $tableClassNamespace = trim(substr($tableSpec['tableClass'], 0, strrpos($tableSpec['tableClass'], '\\')), '\\');
                 if (!is_file($tableClassPath)) {
                     if (!is_dir($tableClassDir)) {
                         mkdir($tableClassDir, 0777, true);
                     }
                     ob_start();
                     echo '<?php';
                     include Bundles::getPath('CakeOrm') . '/Resource/config/table_template.php';
                     $content = ob_get_contents();
                     ob_end_clean();
                     file_put_contents($tableClassPath, $content);
                     $climate->lightGray(sprintf('Create table class "%s".', $tableSpec['tableClass']));
                 } else {
                     $climate->lightMagenta(sprintf('Table class "%s" exists.', $tableSpec['tableClass']));
                 }
             }
             //if ($tableSpec['entityClass']) {
             //    $entityClassPath = SRC_DIR . DS . str_replace('\\', '/', $tableSpec['entityClass']);
             //    $entityClassName = trim(
             //        substr($tableSpec['entityClass'], strrpos($tableSpec['entityClass'], '\\')),
             //        '\\'
             //    );
             //}
         }
     }
 }