Gc\Core\Updater\Adapter\Basic::update PHP Method

update() public method

Update
public update ( ) : boolean
return boolean
    public function update()
    {
        $filename = $this->getTmpPath() . '/v' . $this->getLatestVersion() . '.zip';
        if (file_exists($filename)) {
            unlink($filename);
        }
        file_put_contents($filename, fopen('https://github.com/GotCms/GotCms/archive/' . $this->getLatestVersion() . '.zip', 'r'));
        $zip = new ZipArchive();
        if ($zip->open($filename)) {
            $directoryName = $zip->getNameIndex(0);
            $zip->extractTo($this->getTmpPath());
            $zip->close();
            if (is_dir($this->getTmpPath() . '/v' . $this->getLatestVersion())) {
                File::removeDirectory($this->getTmpPath() . '/v' . $this->getLatestVersion());
            }
            rename($this->getTmpPath() . '/' . $directoryName, $this->getTmpPath() . '/v' . $this->getLatestVersion());
            unlink($filename);
            return true;
        }
        return false;
    }