function OperationFactory::create

Same name in other branches
  1. 9 composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::create()
  2. 10 composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::create()
  3. 11.x composer/Plugin/Scaffold/Operations/OperationFactory.php \Drupal\Composer\Plugin\Scaffold\Operations\OperationFactory::create()

Creates a scaffolding operation object as determined by the metadata.

Parameters

\Composer\Package\PackageInterface $package: The package that relative paths will be relative from.

OperationData $operation_data: The parameter data for this operation object; varies by operation type.

Return value

\Drupal\Composer\Plugin\Scaffold\Operations\OperationInterface The scaffolding operation object (skip, replace, etc.)

Throws

\RuntimeException Exception thrown when parameter data does not identify a known scaffol operation.

File

composer/Plugin/Scaffold/Operations/OperationFactory.php, line 50

Class

OperationFactory
Create Scaffold operation objects based on provided metadata.

Namespace

Drupal\Composer\Plugin\Scaffold\Operations

Code

public function create(PackageInterface $package, OperationData $operation_data) {
    switch ($operation_data->mode()) {
        case SkipOp::ID:
            return new SkipOp();
        case ReplaceOp::ID:
            return $this->createReplaceOp($package, $operation_data);
        case AppendOp::ID:
            return $this->createAppendOp($package, $operation_data);
    }
    throw new \RuntimeException("Unknown scaffold operation mode <comment>{$operation_data->mode()}</comment>.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.