resolve paths of migrations & seeds

@param String $name
@param String $directory
@return array
495798
protected function getPaths($name, $directory = 'migrations')
    {
        $package = $this->manager->getAvailableExtensions()->findByName($name);

        if ($package === null) {
            return [];
        }

        $basePath = $package->getPath();

        $paths = [
            "{$basePath}/resources/database/{$directory}/",
            "{$basePath}/resources/{$directory}/",
            "{$basePath}/src/{$directory}/",
        ];

        return $paths;
    }
1028128
protected function getPath($name)
    {
        $name = str_replace($this->laravel->getNamespace(), '', $name);
        $datePrefix = date('Y_m_d_His');

        return database_path('/migrations/') . $datePrefix . '_create_' . $name . '_table.php';
    }
574815
public static function path( $name, $time = null )
	{
		if ( is_null( $time ) )
		{
			$time = time();
		}
		
		$namespace = null;
		
		if ( strpos( $name, '::' ) !== false )
		{
			list( $namespace, $name ) = explode( '::', $name );
		}
		
		$name = explode( '/', $name );
		
		foreach( $name as $key => $value )
		{
			$name[$key] = \CCStr::clean_url( $value, '_' );
		}
		
		$name = implode( '/', $name );
		
		return \CCPath::get( ( $namespace ? $namespace.'::' : '' ) .$name.'_'.$time, \ClanCats::directory( 'migration' ), '.sql' );
	}
835879
public function getSeeders($database, $name)
    {
        $seeders = [];
        $basename = $name ? $this->seederFileBaseNameStrategy($name) : '*';
        foreach ($this->loader->find($this->application->config('directory.database.seed') . DS . $database) as $dir) {
            foreach ($this->finder->path($dir)->name($basename)->fileOnly()->find() as $file) {
                $class = $file->getClassName();
                $seeder = new $class();
                $seeder->setContainer($this->raikiri());
                $seeders[] = $seeder;
            }
        }
        return $seeders;
    }
308595
public function makeMigration($name)
  {
    $m = $this->getManager();
    $t = $m->getPrefix() . $this->getTable();

    $class = StaticStringy::upperCamelize($name);

    $head = "<?php\n\n"
      . "use Phinx\\Migration\\AbstractMigration;\n\n"
      . "class $class extends AbstractMigration\n"
      . "{\n";

    $pk       = $this->getPrimaryKey();
    $tbl_opts = 'array(\'id\' => ' . ($pk ? "'$pk'" : 'false') . ')';

    $tbl  = '    $tbl = $this->table(\'' . $t . '\', ' . $tbl_opts . ');' . "\n";
    $save = '    $tbl->save();' . "\n";
    $up   = $down = false;

    $drop = $upd = false;

    $tbl_exists = $this->checkTableExists();
    if ($tbl_exists) {
      $columns = $this->getActualColumns(true);

      $drop = array_diff($columns, array_keys($this->columns));
      $add  = array_diff(array_keys($this->columns), $columns);
    } else {
      $down = '    $tbl->drop();' . "\n";
      $add  = array_keys($this->columns);
    }

    if (!empty($add)) {
      foreach ($add as $col) {
        $up .= $this->makeAddExpr($col);
        if ($tbl_exists) {
          $down .= $this->makeDropExpr($col);
        }
      }
    }

    if (!empty($drop)) {
      foreach ($drop as $col) {
        if ($col != $this->getPrimaryKey()) {
          $up .= $this->makeDropExpr($col);
          $down .= "    // TODO: добавить инструкции для создания столбца $col\n";
        }
      }
    }

    foreach ($this->columns as $col => $arr) {
      if (empty($add) || !in_array($col, $add)) {
        $up .= $this->makeAddExpr($col, true);
      }
    }

    if (!empty($this->indexes)) {
      foreach ($this->indexes as $a) {
        $up .= $this->makeAddIndex($a, $tbl_exists);
      }
    }

    if (!empty($this->foreign_keys)) {
      foreach ($this->foreign_keys as $arr) {
        $up .= $this->makeFK($arr, $tbl_exists);
      }
    }

    return $head
    . "  public function up()\n"
    . "  {\n" . $tbl . $up . $save
    . "  }\n\n"
    . "  public function down()\n"
    . "  {\n" . $tbl . $down . ($tbl_exists ? $save : '')
    . "  }\n"
    . "}\n";
  }
41823
private function getDestinations($name, $location)
    {
        $selected     = ($isHome = $location === '/') ? $name : "{$location}/{$name}";
        $destinations = $this->media->directories($location)
            ->pluck('path')
            ->reject(function ($path) use ($selected) {
                return $path === $selected;
            })
            ->values();

        if ( ! $isHome)
            $destinations->prepend('..');

        return $destinations;
    }
808103
protected function _mkdir($path, $name) {
		return $this->make($path, $name, 'directory') ? $this->_joinPath($path, $name) : false;
	}
185826
protected function getPathFromExtensionName(string $name): array
    {
        $extension = $this->app->make('orchestra.extension');
        $finder = $this->app->make('orchestra.extension.finder');

        if ($name === 'app') {
            $basePath = $sourcePath = $this->app->basePath();
        } else {
            $basePath = $finder->resolveExtensionPath(rtrim($extension->option($name, 'path'), '/'));
            $sourcePath = $finder->resolveExtensionPath(rtrim($extension->option($name, 'source-path'), '/'));
        }

        return [$basePath, $sourcePath];
    }
792425
protected function makeFromPath($name, $path)
    {
        if (!$this->get($name)) {

            $params = [
                'name' => $name,
                'path' => rtrim($path, '/') . '/' . $name
            ];

            $module = IOC::resolve('Module', $params);
            $this->add($module->getName(), $module->create());

            return $module;
        }

        return null;
    }
369529
private static function getFilename($name, $directory)
    {
        $filename = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $filename .= str_replace('.phar', '', $name) . '.phar';

        return $filename;
    }
863179
public static function file( $name, & $exists = false )
	{
		if( !defined("APP_DIR") )
		{
			return [];
		}

		$file = APP_DIR . "config" . DIRECTORY_SEPARATOR . $name . '.php';
		if( file_exists( $file ) )
		{
			$data = Helper::includeImport($file);
			$exists = true;
		}

		if( ! isset( $data ) || ! is_array( $data ) )
		{
			$data = [];
		}

		return $data;
	}
647090
public function move($directory, $name = null)
    {
        $target = $this->getTargetFile($directory, $name);

        if (!@rename($this->getPathname(), $target)) {
            $error = error_get_last();
            throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
        }

        @chmod($target, 0666 & ~umask());

        return $target;
    }
23836
static function read($name)
    {
        if (!isset(self::$loaded[$name])) {
            self::$loaded[$name] = [];
            foreach (self::$dirs as $dir) {
                try {
                    $c = include $dir . $name . '.php';
                    self::$loaded[$name] = array_merge_recursive(self::$loaded[$name], $c);
                } catch (\Exception $e) {
                }
            }
        }
        return self::$loaded[$name];
    }
1130178
protected function migrate($name)
    {
        $module = $this->module->findOrFail($name);
        
        $this->call('migrate', [
            '--path' => $this->getPath($module),
            '--database' => $this->option('database'),
            '--pretend' => $this->option('pretend'),
            '--force' => $this->option('force'),
        ]);

        if ($this->option('seed')) {
            $this->call('module:seed', ['module' => $name]);
        }
    }
947967
public function resolve($name)
    {
    	if (preg_match('#\.\.[\\\/]#', $name)) {
            throw new Exception\DomainException(
                'Requested asset may not include parent directory traversal ("../", "..\\" notation)'
            );
        }
        
    	// Check if we have paths
        if (!count($this->paths)) {
            //$this->lastLookupFailure = static::FAILURE_NO_PATHS;
            return null;
        }
        
        // TODO: Check cache!!!
        
        $files = array();
        foreach ($this->paths as $path) {
            $file = new SplFileInfo($path . $name);
            if ($file->isReadable()) {
                // Found! Return it.
                if (($filePath = $file->getRealPath()) === false && substr($path, 0, 7) === 'phar://') {
                    // Do not try to expand phar paths (realpath + phars == fail)
                    $filePath = $path . $name;
                    if (!file_exists($filePath)) {
                        break;
                    }
                }
                
                $files[] = $filePath;
            }
        }

        $count = count($files);
        if ($count > 1) {
        	$canAppend = $this->canAppend($name);
        	if ($canAppend) {
        		$content = '';
        		foreach ($files as $file) {
        			$fileContent = file_get_contents($file);
        			if ($fileContents) {
        				$content .= $fileContent;
        			}
        		}
        		return $content;
        	} else {
        		// TODO: Create an exception
        		throw new \Exception("Too many assets found.");
        	}
        } elseif($count === 1) {
        	$content = file_get_contents($files[0]);
        	if ($content) {
        		return $content;
        	}
        }
        
        return null;
    }
1217137
public function getFiles(string $name = null) : array
    {
        if ($name === null) {
            return $this->files;
        }

        $files = $this->resolvePath($this->files, $name);

        if ($files instanceof UploadedFile) {
            return [$files];
        }

        if (is_array($files)) {
            return array_filter($files, static function ($file) {
                return $file instanceof UploadedFile;
            });
        }

        return [];
    }
1345652
private function bakeDatabaseConfig(string $name) : void
    {
        $options = [
            'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'db' . DS,
            'ext' => 'json'
        ];

        $this->bake('migration.dist', 'Module/db/migration', [], '', $options);
    }