Пример #1
0
 /**
  * Based on the 'type', determines the correct migration path.
  *
  * @param $type
  * @param bool $create
  *
  * @return null|string
  */
 public function determine_migration_path($type, $create = false)
 {
     $type = strtolower($type);
     // Is it a module?
     if (strpos($type, 'mod:') === 0) {
         $module = str_replace('mod:', '', $type);
         $path = \Myth\Modules::path($module, 'migrations');
         // Should we return a 'created' module?
         // Use the first module path.
         if (empty($path) && $create === true) {
             $folders = config_item('modules_locations');
             if (is_array($folders) && count($folders)) {
                 $path = $folders[0] . $module . '/migrations';
             }
         }
         return rtrim($path, '/') . '/';
     }
     // Look in our predefined groups.
     if (!empty($this->_migration_paths[$type])) {
         return rtrim($this->_migration_paths[$type], '/') . '/';
     }
     return null;
 }
Пример #2
0
 public function testFilesReturnsValidListWithOnlyFolder()
 {
     $expected = ['database' => ['controllers/' => ['Database.php']]];
     $this->assertEquals($expected, Modules::files('database', 'controllers'));
 }