Look for code migration files in the given package path and register them
for further action.

@param string $packagePath
@return void
357678
protected function registerMigrationFiles($packagePath)
    {
        $packagePath = rtrim($packagePath, '/');
        $packageKey = substr($packagePath, strrpos($packagePath, '/') + 1);
        $migrationsDirectory = Files::concatenatePaths(array($packagePath, 'Migrations/Code'));
        if (!is_dir($migrationsDirectory)) {
            return;
        }

        foreach (Files::getRecursiveDirectoryGenerator($migrationsDirectory, '.php') as $filenameAndPath) {
            /** @noinspection PhpIncludeInspection */
            require_once($filenameAndPath);
            $baseFilename = basename($filenameAndPath, '.php');
            $className = '\\Neos\\Flow\\Core\\Migrations\\' . $baseFilename;
            /** @var AbstractMigration $migration */
            $migration = new $className($this, $packageKey);
            $this->migrations[$migration->getVersionNumber()] = $migration;
        }
    }
327047
private function performFindAndReplaceInFile(
        string $path
    ): void {
        $this->findAndReplaceHelper->findReplace(
            'use ' . RelationsGenerator::FIND_ENTITIES_NAMESPACE . '\\' . RelationsGenerator::FIND_ENTITY_NAME,
            "use {$this->entityFqn}",
            $path
        );
        $this->findAndReplaceHelper->findReplace(
            'use ' .
            RelationsGenerator::FIND_ENTITY_INTERFACE_NAMESPACE .
            '\\' .
            RelationsGenerator::FIND_ENTITY_INTERFACE_NAME,
            "use {$this->entityInterfaceFqn}",
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%use(.+?)Relations\\\TemplateEntity(.+?);%',
            'use ${1}Relations\\' . $this->singularNamespace . '${2};',
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%use(.+?)Relations\\\TemplateEntity(.+?);%',
            'use ${1}Relations\\' . $this->pluralNamespace . '${2};',
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%(Has|Reciprocates)(Required|)TemplateEntity%',
            '${1}${2}' . $this->singularNamespacedName,
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%(Has|Reciprocates)(Required|)TemplateEntities%',
            '${1}${2}' . $this->pluralNamespacedName,
            $path
        );
        $this->findAndReplaceHelper->findReplace(
            RelationsGenerator::FIND_ENTITY_INTERFACE_NAME,
            $this->namespaceHelper->basename($this->entityInterfaceFqn),
            $path
        );
        $this->findAndReplaceHelper->replaceName($this->singularNamespacedName, $path);
        $this->findAndReplaceHelper->replacePluralName($this->pluralNamespacedName, $path);
        $this->findAndReplaceHelper->replaceProjectNamespace($this->projectRootNamespace, $path);
    }
447606
protected function replaceTemplates($packagePath, $variables)
    {
        $phpEngine = app()->make(PhpEngine::class);

        foreach (File::allFiles($packagePath, true) as $filePath) {
            $filePath = realpath($filePath);

            if (! Str::endsWith($filePath, '.tpl')) {
                continue;
            }

            try {
                $newFileContent = $phpEngine->get($filePath, $variables);
            } catch (Exception $e) {
                $this->error("Template [$filePath] contains syntax errors");
                $this->error($e->getMessage());
                continue;
            }

            $filePathWithoutTplExt = Str::replaceLast(
                '.tpl', '', $filePath
            );

            File::put($filePathWithoutTplExt, $newFileContent);
            File::delete($filePath);
        }
    }
1063371
public function moveTo($targetPath)
    {
        if ($this->error !== UPLOAD_ERR_OK) {
            throw new \RuntimeException('Unable to move file due to upload error: ' . $this->error);
        }
        if (!move_uploaded_file($this->tempFilename, $targetPath)) {
            throw new \RuntimeException('Unable to move uploaded file.');
        }
    }
249488
protected function registerDiscover()
    {
        $this->app->singleton('manifest', function () {
            return new PackageManifest($this->app['files'], $this->app->basePath(), $this->app->basePath('app/packages.php'));
        });
        $this->app->alias('manifest', 'Nano7\Foundation\Discover\PackageManifest');

        $this->command('\Nano7\Foundation\Discover\Console\PackageDiscoverCommand');
    }
777867
public function setClasspath(Path $classpath): void
    {
        if ($this->classpath === null) {
            $this->classpath = $classpath;
        } else {
            $this->classpath->append($classpath);
        }
    }
307645
protected function registerPackageAssets($package, $namespace, $path)
    {
        $assets = $path .DS .'Assets';

        if ($this->app['files']->isDirectory($assets)) {
            $namespace = 'modules/' .str_replace('_', '-', $namespace);

            $this->app['assets.dispatcher']->package($package, $assets, $namespace);
        }
    }
719463
public function add(Package $package)
    {
        $name = $package->getName();
        if (isset($this->packages[$name])) {
            return;
        }

        $this->packages[$name] = $package;
    }
729376
public function runMigrationList($path, $migrations, Extension $extension = null)
    {
        // First we will just make sure that there are any migrations to run. If there
        // aren't, we will just make a note of it to the developer so they're aware
        // that all of the migrations have been run against this database system.
        if (count($migrations) == 0) {
            $this->note('<info>Nothing to migrate.</info>');

            return;
        }

        // Once we have the array of migrations, we will spin through them and run the
        // migrations "up" so the changes are made to the databases. We'll then log
        // that the migration was run so we don't repeat it next time we execute.
        foreach ($migrations as $file) {
            $this->runUp($path, $file, $extension);
        }
    }
1059771
function move( $dstPath )
    {
        $dstPath = self::cleanPath( $dstPath );
        $srcPath = $this->filePath;

        eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::fileMove( '$srcPath', '$dstPath' )" );

        self::$dbbackend->_rename( $srcPath, $dstPath );

        $this->metaData = null;
    }
115456
public function restoreModifiedFiles($installPath)
    {
        DebugPrinter::log('Restoring modified items');
        $tmpRoot = sys_get_temp_dir() . DIRECTORY_SEPARATOR;
        $installPath = trim($installPath, '\\/') . DIRECTORY_SEPARATOR;
        $fsm = new Filesystem;
        DebugPrinter::log(
            'Items to search: %s',
            implode(', ', $this->modifiableFiles)
        );
        foreach ($this->modifiableFiles as $file) {
            $target = $installPath . $file;
            $source = $tmpRoot . md5($target);
            if (!$fsm->exists($source)) {
                DebugPrinter::log('Item `%s` is missing, skipping it', $source);
                continue;
            }
            $args = array($source, $target,);
            DebugPrinter::log('Restoring `%s` to `%s`', $args);
            if ($fsm->exists($target)) {
                $fsm->remove($target);
            }
            $fsm->rename($source, $target, true);
        }
        DebugPrinter::log('Finished restoring modified items');
    }
321459
protected function registerPackagesFromConfiguration($packageStatesConfiguration)
    {
        foreach ($packageStatesConfiguration['packages'] as $composerName => $packageStateConfiguration) {
            $this->registerPackageFromStateConfiguration($composerName, $packageStateConfiguration);
        }
    }
280375
protected function copyStubs($packagePath, $package, $packageFolderName)
    {
        $facadeFilePath = $this->packageBaseDir.'/stubs/Facade.php.tpl';
        $mainClassFilePath = $this->packageBaseDir.'/stubs/MainClass.php.tpl';
        $mainClassTestFilePath = $this->packageBaseDir.'/stubs/MainClassTest.php.tpl';
        $configFilePath = $this->packageBaseDir.'/stubs/config.php';

        $filePaths = [
            $facadeFilePath => "$packagePath/src/Facades/$package.php.tpl",
            $mainClassFilePath => "$packagePath/src/$package.php.tpl",
            $mainClassTestFilePath => "$packagePath/tests/{$package}Test.php.tpl",
            $configFilePath => "$packagePath/config/$packageFolderName.php",
        ];

        foreach ($filePaths as $filePath => $destFilePath) {
            $this->copyFileWithDirsCreating($filePath, $destFilePath);
        }
    }
651138
protected function getSource($packagePath)
    {
        $sources = [
            "{$packagePath}/resources/database/migrations",
            "{$packagePath}/resources/migrations",
            "{$packagePath}/migrations",
        ];

        // iterate through all possible locations
        foreach ($sources as $source) {
            if ($this->files->isDirectory($source)) {
                $paths = [];

                // get all files of the current directory
                $files = $this->getSourceFiles($source);

                // iterate through all files
                foreach ($files as $file) {
                    // if the destination doesn't exist we can add the file to the queue
                    if (!class_exists($this->getClassFromFile($file))) {
                        $paths[$file] = $this->getDestinationPath('migrations', [
                            date('Y_m_d_His', time()), $this->getFileName($file),
                        ]);
                    }
                }

                return $paths;
            }
        }

        throw new InvalidArgumentException('Migrations not found.');
    }
1278591
protected function processPackage(Package $package)
    {
        $extra = $package->getExtra();
        $files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
        $this->originalFiles[$package->getPrettyName()] = $files;

        if (is_array($files)) {
            $this->addFiles($package, $files);
        }
        if ($package->isRoot()) {
            $this->loadDotEnv($package);
            if (!empty($extra[self::EXTRA_DEV_OPTION_NAME])) {
                $this->addFiles($package, $extra[self::EXTRA_DEV_OPTION_NAME]);
            }
        }

        $aliases = $package->collectAliases();

        $this->builder->mergeAliases($aliases);
        $this->builder->setPackage($package->getPrettyName(), array_filter([
            'name' => $package->getPrettyName(),
            'version' => $package->getVersion(),
            'reference' => $package->getSourceReference() ?: $package->getDistReference(),
            'aliases' => $aliases,
        ]));
    }
22608
protected function runMigrationByPaths($migrationPaths, $command)
    {
        $app = $this->mockApplication();

        $this->validateMigrationPaths($migrationPaths);

        /* @todo: since version 2.0.12 you may also specify an array of migration paths. */
        foreach ($migrationPaths as $migrationPath) {
            $migrateController = $this->buildMigration($app);
            $migrateController->migrationPath = $migrationPath;

            $this->runMigration($migrateController, $command);
        }

        $this->destroyApplication();
    }
1315045
protected function registerPackageMigrateCommand()
    {
        $this->app->singleton('command.package.migrate', function ($app)
        {
            return new PackageMigrateCommand($app['migrator'], $app['packages']);
        });

        $this->commands('command.package.migrate');
    }