class OperationFactory (View source)

internal  
 

Create Scaffold operation objects based on provided metadata.

Properties

protected Composer $composer

The Composer service.

Methods

__construct(Composer $composer)

OperationFactory constructor.

create(PackageInterface $package, OperationData $operation_data)

Creates a scaffolding operation object as determined by the metadata.

createReplaceOp(PackageInterface $package, OperationData $operation_data)

Creates a 'replace' scaffold op.

createAppendOp(PackageInterface $package, OperationData $operation_data)

Creates an 'append' (or 'prepend') scaffold op.

bool
hasContent(ScaffoldFilePath $file = NULL)

Checks to see if the specified scaffold file exists and has content.

string
getPackagePath(PackageInterface $package)

Gets the file path of a package.

Details

__construct(Composer $composer)

OperationFactory constructor.

Parameters

Composer $composer

Reference to the 'Composer' object, since the Scaffold Operation Factory is also responsible for evaluating relative package paths as it creates scaffold operations.

OperationInterface create(PackageInterface $package, OperationData $operation_data)

Creates a scaffolding operation object as determined by the metadata.

Parameters

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

OperationInterface

The scaffolding operation object (skip, replace, etc.)

Exceptions

RuntimeException

protected OperationInterface createReplaceOp(PackageInterface $package, OperationData $operation_data)

Creates a 'replace' scaffold op.

Replace ops may copy or symlink, depending on settings.

Parameters

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

OperationInterface

A scaffold replace operation object.

protected OperationInterface createAppendOp(PackageInterface $package, OperationData $operation_data)

Creates an 'append' (or 'prepend') scaffold op.

Parameters

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

OperationInterface

A scaffold replace operation object.

protected bool hasContent(ScaffoldFilePath $file = NULL)

Checks to see if the specified scaffold file exists and has content.

Parameters

ScaffoldFilePath $file

Scaffold file to check.

Return Value

bool

True if the file exists and has content.

protected string getPackagePath(PackageInterface $package)

Gets the file path of a package.

Note that if we call getInstallPath on the root package, we get the wrong answer (the installation manager thinks our package is in vendor). We therefore add special checking for this case.

Parameters

PackageInterface $package

The package.

Return Value

string

The file path.