function OperationFactory::createAppendOp
Same name in other branches
- 9 composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::createAppendOp()
- 8.9.x composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::createAppendOp()
- 11.x composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::createAppendOp()
Creates an 'append' (or 'prepend') scaffold op.
Parameters
\Composer\Package\PackageInterface $package: The package that relative paths will be relative from.
OperationData $operation_data: The parameter data for this operation object, i.e. the relative 'path'.
Return value
\Drupal\Composer\Plugin\Scaffold\Operations\OperationInterface A scaffold replace operation object.
1 call to OperationFactory::createAppendOp()
- OperationFactory::create in composer/
Plugin/ Scaffold/ Operations/ OperationFactory.php - Creates a scaffolding operation object as determined by the metadata.
File
-
composer/
Plugin/ Scaffold/ Operations/ OperationFactory.php, line 99
Class
- OperationFactory
- Create Scaffold operation objects based on provided metadata.
Namespace
Drupal\Composer\Plugin\Scaffold\OperationsCode
protected function createAppendOp(PackageInterface $package, OperationData $operation_data) {
$package_name = $package->getName();
$package_path = $this->getPackagePath($package);
$prepend_source_file = NULL;
$append_source_file = NULL;
$default_data_file = NULL;
if ($operation_data->hasPrepend()) {
$prepend_source_file = ScaffoldFilePath::sourcePath($package_name, $package_path, $operation_data->destination(), $operation_data->prepend());
}
if ($operation_data->hasAppend()) {
$append_source_file = ScaffoldFilePath::sourcePath($package_name, $package_path, $operation_data->destination(), $operation_data->append());
}
if ($operation_data->hasDefault()) {
$default_data_file = ScaffoldFilePath::sourcePath($package_name, $package_path, $operation_data->destination(), $operation_data->default());
}
if (!$this->hasContent($prepend_source_file) && !$this->hasContent($append_source_file)) {
$message = ' - Keep <info>[dest-rel-path]</info> unchanged: no content to prepend / append was provided.';
return new SkipOp($message);
}
return new AppendOp($prepend_source_file, $append_source_file, $operation_data->forceAppend(), $default_data_file);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.