Microweber\Providers\UpdateManager::install_version PHP Method

install_version() public method

public install_version ( $new_version )
    public function install_version($new_version)
    {
        if (defined('MW_API_CALL')) {
            only_admin_access();
        }
        $params = array();
        if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'ini_set')) {
            ini_set('set_time_limit', 0);
        }
        if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
            set_time_limit(0);
        }
        $params['mw_version'] = MW_VERSION;
        $params['core_update'] = $new_version;
        $params['mw_update_check_site'] = $this->app->url_manager->site();
        $result = $this->call('get_download_link', $params);
        if (isset($result['core_update'])) {
            $value = trim($result['core_update']);
            $fname = basename($value);
            $dir_c = mw_cache_path() . 'update/downloads' . DS;
            if (!is_dir($dir_c)) {
                mkdir_recursive($dir_c);
            }
            $dl_file = $dir_c . $fname;
            if (!is_file($dl_file)) {
                $this->_log_msg('Downloading core update');
                $get = $this->app->url_manager->download($value, $post_params = false, $save_to_file = $dl_file);
            }
            if (is_file($dl_file)) {
                $unzip = new \Microweber\Utils\Unzip();
                $target_dir = MW_ROOTPATH;
                $this->_log_msg('Preparing to unzip core update');
                $result = $unzip->extract($dl_file, $target_dir, $preserve_filepath = true);
                $this->_log_msg('Core update unzipped');
                $new_composer = $target_dir . 'composer.json.merge';
                if (is_file($new_composer)) {
                    //     $this->composer_merge($new_composer);
                }
                $this->post_update();
                return $result;
            }
        }
    }