class ReplaceOp extends AbstractOperation (View source)

internal  
 

Scaffold operation to copy or symlink from source to destination.

Constants

ID

Identifies Replace operations.

Properties

protected string $contents

Cached contents of scaffold file to be written to disk.

from  AbstractOperation
protected ScaffoldFilePath $source

The relative path to the source file.

protected bool $overwrite

Whether to overwrite existing files.

Methods

string
contents()

Returns the exact data that will be written to the scaffold files.

string
generateContents()

Load the scaffold contents or otherwise generate what is needed.

scaffoldOverExistingTarget(OperationInterface $existing_target)

Determines what to do if operation is used at same path as a previous op.

scaffoldAtNewLocation(ScaffoldFilePath $destination)

Determines what to do if operation is used without a previous operation.

__construct(ScaffoldFilePath $sourcePath, bool $overwrite = TRUE)

Constructs a ReplaceOp.

process(ScaffoldFilePath $destination, IOInterface $io, ScaffoldOptions $options)

Process this scaffold operation.

copyScaffold(ScaffoldFilePath $destination, IOInterface $io)

Copies the scaffold file.

symlinkScaffold(ScaffoldFilePath $destination, IOInterface $io)

Symlinks the scaffold file.

Details

final string contents()

Returns the exact data that will be written to the scaffold files.

Return Value

string

Data to be written to the scaffold location.

protected string generateContents()

Load the scaffold contents or otherwise generate what is needed.

Return Value

string

The contents of the scaffold file.

OperationInterface scaffoldOverExistingTarget(OperationInterface $existing_target)

Determines what to do if operation is used at same path as a previous op.

Default behavior is to scaffold this operation at the specified destination, ignoring whatever was there before.

Parameters

OperationInterface $existing_target

Existing file at the destination path that we should combine with.

Return Value

OperationInterface

The op to use at this destination.

OperationInterface scaffoldAtNewLocation(ScaffoldFilePath $destination)

Determines what to do if operation is used without a previous operation.

Default behavior is to scaffold this operation at the specified destination. Most operations overwrite rather than modify existing files, and therefore do not need to do anything special when there is no existing file.

Parameters

ScaffoldFilePath $destination

Scaffold file's destination path.

Return Value

OperationInterface

The op to use at this destination.

__construct(ScaffoldFilePath $sourcePath, bool $overwrite = TRUE)

Constructs a ReplaceOp.

Parameters

ScaffoldFilePath $sourcePath

The relative path to the source file.

bool $overwrite

Whether to allow this scaffold file to overwrite files already at the destination. Defaults to TRUE.

ScaffoldResult process(ScaffoldFilePath $destination, IOInterface $io, ScaffoldOptions $options)

Process this scaffold operation.

Parameters

ScaffoldFilePath $destination

Scaffold file's destination path.

IOInterface $io

IOInterface to write to.

ScaffoldOptions $options

Various options that may alter the behavior of the operation.

Return Value

ScaffoldResult

Result of the scaffolding operation.

protected ScaffoldResult copyScaffold(ScaffoldFilePath $destination, IOInterface $io)

Copies the scaffold file.

Parameters

ScaffoldFilePath $destination

Scaffold file to process.

IOInterface $io

IOInterface to writing to.

Return Value

ScaffoldResult

The scaffold result.

protected ScaffoldResult symlinkScaffold(ScaffoldFilePath $destination, IOInterface $io)

Symlinks the scaffold file.

Parameters

ScaffoldFilePath $destination

Scaffold file to process.

IOInterface $io

IOInterface to writing to.

Return Value

ScaffoldResult

The scaffold result.