Neos\Flow\Core\Migrations\AbstractMigration::applyFileOperations PHP Method

applyFileOperations() protected method

Applies all registered moveFile operations.
protected applyFileOperations ( ) : void
return void
    protected function applyFileOperations()
    {
        foreach ($this->operations['moveFile'] as $operation) {
            $oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
            $newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
            if (substr($oldPath, -1) === '*') {
                $oldPath = substr($oldPath, 0, -1);
                if (!file_exists($oldPath)) {
                    continue;
                }
                if (!file_exists($newPath)) {
                    Files::createDirectoryRecursively($newPath);
                }
                if (!is_dir($newPath)) {
                    continue;
                }
                foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
                    if (substr_compare($pathAndFilename, $oldPath, 0, strlen($oldPath)) === 0) {
                        $relativePathAndFilename = substr($pathAndFilename, strlen($oldPath));
                        if (!is_dir(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))))) {
                            Files::createDirectoryRecursively(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))));
                        }
                        Git::move($pathAndFilename, Files::concatenatePaths(array($newPath, $relativePathAndFilename)));
                    }
                }
            } else {
                $oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
                $newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
                Git::move($oldPath, $newPath);
            }
        }
        foreach ($this->operations['deleteFile'] as $operation) {
            $filename = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
            if (file_exists($filename)) {
                Git::remove($filename);
            }
        }
    }