Microweber\Providers\UpdateManager::install_module PHP Метод

install_module() публичный Метод

public install_module ( $module_name )
    public function install_module($module_name)
    {
        $params = array();
        $params['module'] = $module_name;
        $params['add_new'] = $module_name;
        $result = $this->call('get_download_link', $params);
        if (isset($result['modules'])) {
            foreach ($result['modules'] as $mod_k => $value) {
                $fname = basename($value);
                $dir_c = mw_cache_path() . '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 module' . $fname);
                    $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();
                    $this->_log_msg('Unziping module' . $fname);
                    $target_dir = MW_ROOTPATH;
                    $result = $unzip->extract($dl_file, $target_dir, $preserve_filepath = true);
                }
            }
            $params = array();
            $params['skip_cache'] = true;
            $data = $this->app->modules->get($params);
            $this->app->cache_manager->delete('update/global');
            $this->app->cache_manager->delete('db');
            $this->app->cache_manager->delete('modules');
            $this->app->modules->scan_for_modules();
        }
        return $result;
    }