Extends
lithium\console\Command
Helper method for `console\command\Library::extract()` to perform after-extract string
replacements.
In the current implementation, it only sets the correct `LITHIUM_LIBRARY_PATH` when the
app.phar.gz archive was extracted. If you get any errors, please make sure that the console
script has read and write permissions to the extracted directory.
Parameters
- string $extracted contains the path to the extracted archive.
Returns
booleanSource
protected function _replaceAfterExtract($extracted) {
$replacements = array(
'config/bootstrap/libraries.php' => array(
'define(\'LITHIUM_LIBRARY_PATH\', dirname(LITHIUM_APP_PATH) . \'/libraries\');' =>
'define(\'LITHIUM_LIBRARY_PATH\', \'' . LITHIUM_LIBRARY_PATH . '\');'
)
);
foreach ($replacements as $filename => $definitions) {
$filepath = $extracted . '/' . $filename;
if (file_exists($filepath)) {
$content = file_get_contents($filepath);
foreach ($definitions as $original => $replacement) {
$content = str_replace($original, $replacement, $content);
}
if (!file_put_contents($filepath, $content)) {
$this->error("Could not replace content in {$filepath}");
return false;
}
}
}
return true;
}