You are here

class Provision_ComposerCreateProject in Aegir Deploy 7.3

@file The Provision_ComposerCreateProject class.

Hierarchy

Expanded class hierarchy of Provision_ComposerCreateProject

File

modules/platform_composer/drush/Provision/ComposerCreateProject.php, line 7
The Provision_ComposerCreateProject class.

View source
class Provision_ComposerCreateProject extends Provision_ShellCommand {

  // The prefix used for properties in Aegir contexts.
  protected $context_prefix = 'composer_project_';

  // List of properties to load from the Aegir context.
  protected $context_properties = [
    'path',
    'package',
    'version',
  ];

  // The local path in which we'll deploy the project.
  protected $path = FALSE;

  // The Composer package to use to create the project.
  protected $package = FALSE;

  // The version of the Composer package to use.
  protected $version = FALSE;
  public function validateProvisionVerify() {
    if ($this
      ->pathExists($this->path)) {
      return $this
        ->notice(dt('Composer project path already exists. Aborting.'));
    }
    else {
      return $this
        ->deployPlatform();
    }
  }
  protected function deployPlatform() {
    $this
      ->notice(dt('Deploying platform.'));
    return $this
      ->createProject();
  }
  protected function createProject() {
    $this
      ->notice(dt('Creating project from package `:package` at `:path`', [
      ':package' => $this->package,
      ':path' => $this->path,
    ]));
    return $this
      ->execCommand($this
      ->buildCreateProjectCommand());
  }
  protected function buildCreateProjectCommand() {
    $command = 'composer create-project --no-dev --no-interaction --no-progress';
    $command .= ' ' . escapeshellarg(trim($this->package));
    $command .= ' ' . escapeshellarg(trim($this->path));
    $command .= ' ' . escapeshellarg(trim($this->version));
    return $command;
  }
  public function postProvisionDelete() {
    if ($this->path != d()->root) {
      $this
        ->notice(dt('Deleting Composer project path at: ') . d()->composer_project_path);
      _provision_recursive_delete($this->path);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Provision_ComposerCreateProject::$context_prefix protected property Overrides Provision_ShellCommand::$context_prefix
Provision_ComposerCreateProject::$context_properties protected property Overrides Provision_ShellCommand::$context_properties
Provision_ComposerCreateProject::$package protected property
Provision_ComposerCreateProject::$path protected property
Provision_ComposerCreateProject::$version protected property
Provision_ComposerCreateProject::buildCreateProjectCommand protected function
Provision_ComposerCreateProject::createProject protected function
Provision_ComposerCreateProject::deployPlatform protected function
Provision_ComposerCreateProject::postProvisionDelete public function
Provision_ComposerCreateProject::validateProvisionVerify public function
Provision_ShellCommand::abort protected function
Provision_ShellCommand::error protected function
Provision_ShellCommand::execCommand protected function Run a command in a subprocess, and stream the output.
Provision_ShellCommand::log protected function
Provision_ShellCommand::notice protected function
Provision_ShellCommand::pathExists protected function
Provision_ShellCommand::runCommand protected function Run a command in a subshell, and post the output once complete.
Provision_ShellCommand::setProperty protected function
Provision_ShellCommand::success protected function
Provision_ShellCommand::warning protected function
Provision_ShellCommand::__construct public function Initialize properties from the current Aegir context.