hotfix = $hotfix; $this->facts = $facts; } public function apply() { $head = file_get_contents(__DIR__.self::BASH_STUB); $body = $this->hotfix->getBody(); $hash = $this->hotfix->getHash(); $facts = $this->facts->getFlat(); $head .= 'function fact {'.PHP_EOL; $head .= ' case "$1" in'.PHP_EOL; foreach ($facts as $key=>$fact) { $head .= ' "'.$key.'") echo "'.$fact.'";;'.PHP_EOL; } $head .= ' esac'.PHP_EOL; $head .= '}'.PHP_EOL; // Create temporary filename based on the hash of the hotfix $tmpfile = sys_get_temp_dir()."/hotfix_".$hash; file_put_contents($tmpfile, $head."\n".$body."\n"); // Execute the hotfix and clean up passthru("bash {$tmpfile}"); unlink($tmpfile); } }