public function install(): OperationResult
    {
        $result = new OperationResult();

        $sourcePath = "{$this->packageInstallDir}/.installer/%s/files";
        foreach ($this->projectType->getProjectDirs() as $projectDir) {
            if (is_dir(sprintf($sourcePath, $projectDir))) {
                /** @var \RecursiveDirectoryIterator $iterator */
                $iterator = new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator(
                        sprintf($sourcePath, $projectDir),
                        \RecursiveDirectoryIterator::SKIP_DOTS
                    ),
                    \RecursiveIteratorIterator::SELF_FIRST
                );

                /** @var \SplFileInfo $file */
                foreach ($iterator as $file) {
                    $target = "{$this->projectRootDir}/{$iterator->getSubPathname()}";
                    if ($file->isDir()) {
                        if (!is_dir($target)) {
                            if (!mkdir($target)) {
                                $result->addErrorMessage("<error>Could not create target directory '${target}'</error>");
                            }
                        }
                    } elseif (!file_exists($target)) {
                        assert(is_string($file->getRealPath()));
                        if (!copy($file->getRealPath(), $target)) {
                            $result->addErrorMessage("<error>Could not copy file to '${target}'</error>");
                        }
                    }
                }
            }
        }

        if (!$result->isFailure()) {
            $result->addStatusMessage("Successfully copied files from package {$this->packageName}");
        }

        return $result;
    }
public function install(): OperationResult
    {
        $result = new OperationResult();

        $sourcePath = "{$this->packageInstallDir}/.installer/%s/files";
        foreach ($this->projectType->getProjectDirs() as $projectDir) {
            if (is_dir(sprintf($sourcePath, $projectDir))) {
                /** @var \RecursiveDirectoryIterator $iterator */
                $iterator = new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator(
                        sprintf($sourcePath, $projectDir),
                        \RecursiveDirectoryIterator::SKIP_DOTS
                    ),
                    \RecursiveIteratorIterator::SELF_FIRST
                );

                /** @var \SplFileInfo $file */
                foreach ($iterator as $file) {
                    $target = "{$this->projectRootDir}/{$iterator->getSubPathname()}";
                    if ($file->isDir()) {
                        if (!is_dir($target)) {
                            if (!mkdir($target)) {
                                $result->addErrorMessage("<error>Could not create target directory '${target}'</error>");
                            }
                        }
                    } elseif (!file_exists($target)) {
                        assert(is_string($file->getRealPath()));
                        if (!copy($file->getRealPath(), $target)) {
                            $result->addErrorMessage("<error>Could not copy file to '${target}'</error>");
                        }
                    }
                }
            }
        }

        if (!$result->isFailure()) {
            $result->addStatusMessage("Successfully copied files from package {$this->packageName}");
        }

        return $result;
    }
public function install ( ) : OperationResult { $ result = new OperationResult ( ) ; $ sourcePath = "{$this->packageInstallDir}/.installer/%s/files" ; foreach ( $ this -> projectType -> getProjectDirs ( ) as $ projectDir ) { if ( is_dir ( sprintf ( $ sourcePath , $ projectDir ) ) ) { /** @var \RecursiveDirectoryIterator $iterator */ $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( sprintf ( $ sourcePath , $ projectDir ) , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; /** @var \SplFileInfo $file */ foreach ( $ iterator as $ file ) { $ target = "{$this->projectRootDir}/{$iterator->getSubPathname()}" ; if ( $ file -> isDir ( ) ) { if ( ! is_dir ( $ target ) ) { if ( ! mkdir ( $ target ) ) { $ result -> addErrorMessage ( "<error>Could not create target directory '${target}'</error>" ) ; } } } elseif ( ! file_exists ( $ target ) ) { assert ( is_string ( $ file -> getRealPath ( ) ) ) ; if ( ! copy ( $ file -> getRealPath ( ) , $ target ) ) { $ result -> addErrorMessage ( "<error>Could not copy file to '${target}'</error>" ) ; } } } } } if ( ! $ result -> isFailure ( ) ) { $ result -> addStatusMessage ( "Successfully copied files from package {$this->packageName}" ) ; } return $ result ; }
Copies all files from package to target directory in project root
- files that already exist are not copied

@return OperationResult
Copies all files from package to target directory in project root - files that already exist are not copied