class AbstractOperation

Same name in other branches
  1. 8.9.x composer/Plugin/Scaffold/Operations/AbstractOperation.php \Drupal\Composer\Plugin\Scaffold\Operations\AbstractOperation
  2. 10 composer/Plugin/Scaffold/Operations/AbstractOperation.php \Drupal\Composer\Plugin\Scaffold\Operations\AbstractOperation
  3. 11.x composer/Plugin/Scaffold/Operations/AbstractOperation.php \Drupal\Composer\Plugin\Scaffold\Operations\AbstractOperation

Provides default behaviors for operations.

@internal

Hierarchy

Expanded class hierarchy of AbstractOperation

File

composer/Plugin/Scaffold/Operations/AbstractOperation.php, line 12

Namespace

Drupal\Composer\Plugin\Scaffold\Operations
View source
abstract class AbstractOperation implements OperationInterface {
    
    /**
     * Cached contents of scaffold file to be written to disk.
     *
     * @var string
     */
    protected $contents;
    
    /**
     * {@inheritdoc}
     */
    public final function contents() {
        if (!isset($this->contents)) {
            $this->contents = $this->generateContents();
        }
        return $this->contents;
    }
    
    /**
     * Load the scaffold contents or otherwise generate what is needed.
     *
     * @return string
     *   The contents of the scaffold file.
     */
    protected abstract function generateContents();
    
    /**
     * {@inheritdoc}
     */
    public function scaffoldOverExistingTarget(OperationInterface $existing_target) {
        return $this;
    }
    
    /**
     * {@inheritdoc}
     */
    public function scaffoldAtNewLocation(ScaffoldFilePath $destination) {
        return $this;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AbstractOperation::$contents protected property Cached contents of scaffold file to be written to disk.
AbstractOperation::contents final public function Returns the exact data that will be written to the scaffold files. Overrides OperationInterface::contents
AbstractOperation::generateContents abstract protected function Load the scaffold contents or otherwise generate what is needed. 3
AbstractOperation::scaffoldAtNewLocation public function Determines what to do if operation is used without a previous operation. Overrides OperationInterface::scaffoldAtNewLocation 1
AbstractOperation::scaffoldOverExistingTarget public function Determines what to do if operation is used at same path as a previous op. Overrides OperationInterface::scaffoldOverExistingTarget 1
OperationInterface::process public function Process this scaffold operation. 3

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