function AppendOp::generateContents
Same name in other branches
- 8.9.x composer/Plugin/Scaffold/Operations/AppendOp.php \Drupal\Composer\Plugin\Scaffold\Operations\AppendOp::generateContents()
- 10 composer/Plugin/Scaffold/Operations/AppendOp.php \Drupal\Composer\Plugin\Scaffold\Operations\AppendOp::generateContents()
- 11.x composer/Plugin/Scaffold/Operations/AppendOp.php \Drupal\Composer\Plugin\Scaffold\Operations\AppendOp::generateContents()
Overrides AbstractOperation::generateContents
File
-
composer/
Plugin/ Scaffold/ Operations/ AppendOp.php, line 82
Class
- AppendOp
- Scaffold operation to add to the beginning and/or end of a scaffold file.
Namespace
Drupal\Composer\Plugin\Scaffold\OperationsCode
protected function generateContents() {
// Fetch the prepend contents, if provided.
$prepend_contents = '';
if (!empty($this->prepend)) {
$prepend_contents = file_get_contents($this->prepend
->fullPath()) . "\n";
}
// Fetch the append contents, if provided.
$append_contents = '';
if (!empty($this->append)) {
$append_contents = "\n" . file_get_contents($this->append
->fullPath());
}
// Get the original contents, or the default data if the original is empty.
$original_contents = $this->originalContents;
if (empty($original_contents) && !empty($this->default)) {
$original_contents = file_get_contents($this->default
->fullPath());
}
// Attach it all together.
return $prepend_contents . $original_contents . $append_contents;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.