Gc\Core\Updater::executeScripts PHP Method

executeScripts() public method

Update database
public executeScripts ( ) : boolean
return boolean
    public function executeScripts()
    {
        if (empty($this->adapter)) {
            return false;
        }
        $files = array();
        $updatePath = GC_APPLICATION_PATH . '/data/update';
        $path = glob($updatePath . '/*');
        foreach ($path as $file) {
            $version = str_replace($updatePath . '/', '', $file);
            if (version_compare($version, Version::VERSION, '>')) {
                $fileList = glob($file . '/*.php');
                if (!empty($fileList)) {
                    $files[] = $fileList;
                }
            }
        }
        if (empty($files)) {
            return true;
        }
        $script = new Script();
        foreach ($files as $fileList) {
            foreach ($fileList as $filename) {
                try {
                    $this->adapter->addMessage($script->execute($filename));
                } catch (\Exception $e) {
                    ob_get_clean();
                    $this->setError($e->getMessage());
                }
            }
        }
        return true;
    }

Usage Example

Example #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testExecuteScripts()
 {
     file_put_contents($this->fileName, '<?php echo "test";');
     $this->object->load('git');
     $this->assertTrue($this->object->executeScripts());
     unlink($this->fileName);
 }
All Usage Examples Of Gc\Core\Updater::executeScripts