Gc\Core\Updater\Script::execute PHP Method

execute() public method

Execute script, need to be execute here in order to isolate all variables.
public execute ( string $filename ) : string
$filename string Filename
return string
    public function execute($filename)
    {
        ob_start();
        include $filename;
        return ob_get_clean();
    }

Usage Example

Beispiel #1
0
 /**
  * Update database
  *
  * @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;
 }
Script