protected function editSettings()
    {
        $multiSiteSettingsFile = sprintf(
            '%s/sites/'.$this->explodeDirectory[0].'/settings.php',
            $this->appRoot
        );
        if (!$this->fs->exists($multiSiteSettingsFile)) {
            $multiSiteSettingsFile = sprintf(
                '%s/sites/'.$this->directory.'/settings.php',
                $this->appRoot
            );
        }

        $databases = [];
        $config_directories = [];

        if (file_exists($multiSiteSettingsFile)) {
            include $multiSiteSettingsFile;
        }

        try {
            if (!empty($databases) || !empty($config_directories)) {
                //Replace $databases['default']['default']['database']
                $line = explode('/', $databases['default']['default']['database']);
                $string_to_replace= $databases['default']['default']['database'];
                $replace_with="sites/".$this->explodeDirectory[0]."/files/".end($line);
                $content=file_get_contents($multiSiteSettingsFile);
                $content_chunks=explode($string_to_replace, $content);
                $content=implode($replace_with, $content_chunks);

                //Replace $config_directories['sync']
                $string_to_replace= $config_directories['sync'];
                $replace_with=str_replace($this->uri, $this->directory, $config_directories['sync']);
                $content_chunks=explode($string_to_replace, $content);
                $content=implode($replace_with, $content_chunks);
                file_put_contents($multiSiteSettingsFile, $content);
            }
        } catch (IOExceptionInterface $e) {
            $this->getIo()->error(
                sprintf(
                    $this->trans('commands.multisite.update.messages.write-fail'),
                    $multiSiteSettingsFile
                )
            );
            return 1;
        }
    }
protected function editSettings()
    {
        $multiSiteSettingsFile = sprintf(
            '%s/sites/'.$this->explodeDirectory[0].'/settings.php',
            $this->appRoot
        );
        if (!$this->fs->exists($multiSiteSettingsFile)) {
            $multiSiteSettingsFile = sprintf(
                '%s/sites/'.$this->directory.'/settings.php',
                $this->appRoot
            );
        }

        $databases = [];
        $config_directories = [];

        if (file_exists($multiSiteSettingsFile)) {
            include $multiSiteSettingsFile;
        }

        try {
            if (!empty($databases) || !empty($config_directories)) {
                //Replace $databases['default']['default']['database']
                $line = explode('/', $databases['default']['default']['database']);
                $string_to_replace= $databases['default']['default']['database'];
                $replace_with="sites/".$this->explodeDirectory[0]."/files/".end($line);
                $content=file_get_contents($multiSiteSettingsFile);
                $content_chunks=explode($string_to_replace, $content);
                $content=implode($replace_with, $content_chunks);

                //Replace $config_directories['sync']
                $string_to_replace= $config_directories['sync'];
                $replace_with=str_replace($this->uri, $this->directory, $config_directories['sync']);
                $content_chunks=explode($string_to_replace, $content);
                $content=implode($replace_with, $content_chunks);
                file_put_contents($multiSiteSettingsFile, $content);
            }
        } catch (IOExceptionInterface $e) {
            $this->getIo()->error(
                sprintf(
                    $this->trans('commands.multisite.update.messages.write-fail'),
                    $multiSiteSettingsFile
                )
            );
            return 1;
        }
    }
protected function editSettings ( ) { $ multiSiteSettingsFile = sprintf ( '%s/sites/' . $ this -> explodeDirectory [ 0 ] . '/settings.php' , $ this -> appRoot ) ; if ( ! $ this -> fs -> exists ( $ multiSiteSettingsFile ) ) { $ multiSiteSettingsFile = sprintf ( '%s/sites/' . $ this -> directory . '/settings.php' , $ this -> appRoot ) ; } $ databases = [ ] ; $ config_directories = [ ] ; if ( file_exists ( $ multiSiteSettingsFile ) ) { include $ multiSiteSettingsFile ; } try { if ( ! empty ( $ databases ) || ! empty ( $ config_directories ) ) { //Replace $databases['default']['default']['database'] $ line = explode ( '/' , $ databases [ 'default' ] [ 'default' ] [ 'database' ] ) ; $ string_to_replace = $ databases [ 'default' ] [ 'default' ] [ 'database' ] ; $ replace_with = "sites/" . $ this -> explodeDirectory [ 0 ] . "/files/" . end ( $ line ) ; $ content = file_get_contents ( $ multiSiteSettingsFile ) ; $ content_chunks = explode ( $ string_to_replace , $ content ) ; $ content = implode ( $ replace_with , $ content_chunks ) ; //Replace $config_directories['sync'] $ string_to_replace = $ config_directories [ 'sync' ] ; $ replace_with = str_replace ( $ this -> uri , $ this -> directory , $ config_directories [ 'sync' ] ) ; $ content_chunks = explode ( $ string_to_replace , $ content ) ; $ content = implode ( $ replace_with , $ content_chunks ) ; file_put_contents ( $ multiSiteSettingsFile , $ content ) ; } } catch ( IOExceptionInterface $ e ) { $ this -> getIo ( ) -> error ( sprintf ( $ this -> trans ( 'commands.multisite.update.messages.write-fail' ) , $ multiSiteSettingsFile ) ) ; return 1 ; } }
Edit the settings.php file to change the database parameters, because the settings.php file was moved.
Edit the settings . php file to change the database parameters because the settings . php file was moved .