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

        $sourcePath = "{$this->packageInstallDir}/.installer/%s/bundles.php";
        foreach ($this->projectType->getProjectDirs() as $projectDir) {
            $bundleFile = sprintf($sourcePath, $projectDir);
            if (is_file($bundleFile)) {
                $data = require $bundleFile;
                if (!is_array($data)) {
                    $result->addErrorMessage('<error>The bundles.php file in installer must return an array</error>');
                    break;
                }

                $installedBundlesFile = "{$this->projectRootDir}/config/bundles.php";
                if (file_exists($installedBundlesFile)) {
                    $installedBundles = require $installedBundlesFile;
                    if (is_array($installedBundles)) {
                        $resultingBundleData = array_merge($installedBundles, $data);

                        $export = $this->dumpConfig($resultingBundleData);
                        if (!file_put_contents($installedBundlesFile, $export, LOCK_EX)) {
                            $result->addErrorMessage("<error>Could not copy bundle content from {$this->packageName}</error>");
                        }
                    }
                }
            }
        }

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

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

        $sourcePath = "{$this->packageInstallDir}/.installer/%s/bundles.php";
        foreach ($this->projectType->getProjectDirs() as $projectDir) {
            $bundleFile = sprintf($sourcePath, $projectDir);
            if (is_file($bundleFile)) {
                $data = require $bundleFile;
                if (!is_array($data)) {
                    $result->addErrorMessage('<error>The bundles.php file in installer must return an array</error>');
                    break;
                }

                $installedBundlesFile = "{$this->projectRootDir}/config/bundles.php";
                if (file_exists($installedBundlesFile)) {
                    $installedBundles = require $installedBundlesFile;
                    if (is_array($installedBundles)) {
                        $resultingBundleData = array_merge($installedBundles, $data);

                        $export = $this->dumpConfig($resultingBundleData);
                        if (!file_put_contents($installedBundlesFile, $export, LOCK_EX)) {
                            $result->addErrorMessage("<error>Could not copy bundle content from {$this->packageName}</error>");
                        }
                    }
                }
            }
        }

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

        return $result;
    }
public function install ( ) : OperationResult { $ result = new OperationResult ( ) ; $ sourcePath = "{$this->packageInstallDir}/.installer/%s/bundles.php" ; foreach ( $ this -> projectType -> getProjectDirs ( ) as $ projectDir ) { $ bundleFile = sprintf ( $ sourcePath , $ projectDir ) ; if ( is_file ( $ bundleFile ) ) { $ data = require $ bundleFile ; if ( ! is_array ( $ data ) ) { $ result -> addErrorMessage ( '<error>The bundles.php file in installer must return an array</error>' ) ; break ; } $ installedBundlesFile = "{$this->projectRootDir}/config/bundles.php" ; if ( file_exists ( $ installedBundlesFile ) ) { $ installedBundles = require $ installedBundlesFile ; if ( is_array ( $ installedBundles ) ) { $ resultingBundleData = array_merge ( $ installedBundles , $ data ) ; $ export = $ this -> dumpConfig ( $ resultingBundleData ) ; if ( ! file_put_contents ( $ installedBundlesFile , $ export , LOCK_EX ) ) { $ result -> addErrorMessage ( "<error>Could not copy bundle content from {$this->packageName}</error>" ) ; } } } } } if ( ! $ result -> isFailure ( ) ) { $ result -> addStatusMessage ( "Successfully copied Bundle information from {$this->packageName}" ) ; } return $ result ; }
Handle installation for given operation

@return OperationResult
Handle installation for given operation