You are here

class HostingPlatformGitForm in Aegir Deploy 7.3

@file The HostingPlatformGitForm class.

Hierarchy

Expanded class hierarchy of HostingPlatformGitForm

File

modules/platform_git/includes/HostingPlatformGitForm.inc, line 6
The HostingPlatformGitForm class.

View source
class HostingPlatformGitForm extends HostingForm {

  // Fields managed by this module.
  protected $fields = [
    'field_git_repository_url',
    'field_git_repository_path',
    'field_git_reference',
    'field_git_docroot',
  ];
  public function __construct(&$form, &$form_state, &$node = FALSE) {
    parent::__construct($form, $form_state, $node);
    if ($this->node->type == 'platform') {
      $this->platform = new HostingPlatformGitNode($node);
    }
  }
  public function alter() {
    $this
      ->disableField('field_git_repository_path');
    $this
      ->lockFields();
    $this
      ->moveFieldsIntoFieldset('platform_git', $this->fields);
    $this->form['platform_git']['#title'] = 'Deploy from Git';
    $this->form['platform_git']['#description'] = 'You may deploy this platform from a Git repository. This strategy is appropriate for hosting scenarios where multiple sites will share common platforms.';
    $this
      ->addSubmitHandler('hosting_platform_git_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
      ->setRepositoryPath();
    $this
      ->setPublishPath();
  }
  protected function setRepositoryPath() {
    if ($this
      ->isANewNode() && !empty($this
      ->getFormStateValue('field_git_repository_url'))) {
      $this
        ->setFormStateValue('field_git_repository_path', $this
        ->getFormStateValue('publish_path'));
    }
  }
  protected function setPublishPath() {
    if (!empty($this
      ->getFormStateValue('field_git_docroot'))) {
      $publish_path = $this
        ->getFormStateValue('field_git_repository_path') . '/' . $this
        ->getFormStateValue('field_git_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
HostingPlatformGitForm::$fields protected property
HostingPlatformGitForm::alter public function
HostingPlatformGitForm::lockFields protected function
HostingPlatformGitForm::setPublishPath protected function
HostingPlatformGitForm::setRepositoryPath protected function
HostingPlatformGitForm::submit public function
HostingPlatformGitForm::__construct public function Contructor method. Overrides HostingForm::__construct