You are here

class HostingPlatformComposerForm in Aegir Deploy 7.3

@file The HostingPlatformComposerForm class.

Hierarchy

Expanded class hierarchy of HostingPlatformComposerForm

File

modules/platform_composer/includes/HostingPlatformComposerForm.inc, line 6
The HostingPlatformComposerForm class.

View source
class HostingPlatformComposerForm extends HostingForm {

  // Fields managed by this module.
  protected $fields = [
    'field_composer_project_docroot',
    'field_composer_project_package',
    'field_composer_project_path',
    'field_composer_project_version',
  ];
  public function __construct(&$form, &$form_state, &$node = FALSE) {
    parent::__construct($form, $form_state, $node);
    if ($this->node->type == 'platform') {
      $this->platform = new HostingPlatformComposerNode($node);
    }
  }
  public function alter() {
    $this
      ->disableField('field_composer_project_path');
    $this
      ->lockFields();
    $this
      ->moveFieldsIntoFieldset('platform_composer', $this->fields);
    $this->form['platform_composer']['#title'] = 'Deploy a Composer project from a Packagist repository';
    $this->form['platform_composer']['#description'] = '
<p>You may deploy this platform from a Composer package hosted on <a href="https://packagist.org/">Packagist</a>, the PHP package repository.</p>

<p>To provision a clean Drupal 8+ core codebase for Aegir, one would typically enter <em>web</em> for the Docroot, <em>aegir/drupal-project-composer</em> for the Composer Package Name, and <em>dev-aegir3-8.x</em> for the Composer Package Version.  For more information on that project, see <a href="https://packagist.org/packages/aegir/drupal-project-composer">the project page on Packagist</a>.</p>

<p>However, you will probably want to customize your installation after starting with this project as template, and then adding contributed and custom modules and themes.  To do that, use the <em>Deploy a Composer project from a Git repository</em> option instead, which allows you to clone from your own Git repository (once you\'ve created it).</p>

<p>It should be noted that this option is not currently working with repositories requiring Drush 9 due to <a href="https://www.drupal.org/project/provision/issues/2953349">Including Drush 9 in a Composer-based platform breaks Provision\'s Verify</a>.  Either fork the repository and remove the requirement (or move it to <em>require-dev</em> as the suggested-above repository does), or do this in your own Git repository using the <em>Deploy a Composer project from a Git repository</em> option instead of this one.</p>

<p><strong>Note:</strong> This activity will recalculate all dependencies, and thus, it is very resource-intensive. It requires a miminum of 4G of RAM; we advise against performing this activity in production.</p>
    ';
    $this
      ->addSubmitHandler('hosting_platform_composer_platform_submit');
  }
  protected function lockFields() {
    if (isset($this->node->platform_status) && $this->node->platform_status != HOSTING_PLATFORM_QUEUED) {
      foreach ($this->fields as $field) {
        $this
          ->makeFieldReadOnly($field);
      }
    }
  }
  public function submit() {
    $this
      ->setProjectPath();
    $this
      ->setPublishPath();
  }
  protected function setProjectPath() {
    if ($this
      ->isANewNode() && !empty($this
      ->getFormStateValue('field_composer_project_package'))) {
      $this
        ->setFormStateValue('field_composer_project_path', $this
        ->getFormStateValue('publish_path'));
    }
  }
  protected function setPublishPath() {
    if (!empty($this
      ->getFormStateValue('field_composer_project_docroot'))) {
      $publish_path = $this
        ->getFormStateValue('field_composer_project_path') . '/' . $this
        ->getFormStateValue('field_composer_project_docroot');
      $this
        ->setFormStateValue('publish_path', $publish_path);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HostingForm::$form public property
HostingForm::$form_state public property
HostingForm::$node public property
HostingForm::addSubmitHandler public function Register a form submit handler.
HostingForm::addValidateHandler public function Register a form validate handler.
HostingForm::closeOverlay function Properly close dialogs, or re-direct back to source node, depending on whether overlay.module is enabled.
HostingForm::disableField protected function Hide a form field.
HostingForm::error public function
HostingForm::getFormStateValue public function
HostingForm::isAField protected function
HostingForm::isANewNode protected function Determine whether we're creating a new node, or editing an existing one.
HostingForm::language protected function
HostingForm::makeFieldReadOnly public function Render a form field un-editable.
HostingForm::makeFieldsetsIntoRadios protected function
HostingForm::moveFieldsIntoFieldset protected function
HostingForm::setFieldListOptions protected function
HostingForm::setFormDefaultValue protected function
HostingForm::setFormStateValue public function
HostingPlatformComposerForm::$fields protected property
HostingPlatformComposerForm::alter public function
HostingPlatformComposerForm::lockFields protected function
HostingPlatformComposerForm::setProjectPath protected function
HostingPlatformComposerForm::setPublishPath protected function
HostingPlatformComposerForm::submit public function
HostingPlatformComposerForm::__construct public function Contructor method. Overrides HostingForm::__construct