You are here

public function BitbucketFrontendEnvironment::frontEndEnvironmentForm in Build Hooks 8.2

Same name and namespace in other branches
  1. 3.x modules/build_hooks_bitbucket/src/Plugin/FrontendEnvironment/BitbucketFrontendEnvironment.php \Drupal\build_hooks_bitbucket\Plugin\FrontendEnvironment\BitbucketFrontendEnvironment::frontEndEnvironmentForm()

Overrides FrontendEnvironmentBase::frontEndEnvironmentForm

File

modules/build_hooks_bitbucket/src/Plugin/FrontendEnvironment/BitbucketFrontendEnvironment.php, line 77

Class

BitbucketFrontendEnvironment
Provides a 'Bitbucket pipelines' frontend environment type.

Namespace

Drupal\build_hooks_bitbucket\Plugin\FrontendEnvironment

Code

public function frontEndEnvironmentForm($form, FormStateInterface $form_state) {
  $form['repo'] = [
    '#type' => 'fieldset',
  ];
  $form['repo']['workspace'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Repo workspace'),
    '#maxlength' => 255,
    '#default_value' => isset($this->configuration['repo']['workspace']) ? $this->configuration['repo']['workspace'] : '',
    '#required' => TRUE,
  ];
  $form['repo']['slug'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Repo Slug'),
    '#maxlength' => 255,
    '#default_value' => isset($this->configuration['repo']['slug']) ? $this->configuration['repo']['slug'] : '',
    '#description' => $this
      ->t('Found in the URL https://bitbucket.org/{workspace}/{repo_slug}'),
    '#required' => TRUE,
  ];
  $form['ref'] = [
    '#type' => 'fieldset',
  ];
  $form['ref']['type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Reference type'),
    '#options' => [
      'branch' => 'Branch',
      'tag' => 'Tag',
    ],
    '#default_value' => isset($this->configuration['ref']['type']) ? $this->configuration['ref']['type'] : '',
    '#description' => $this
      ->t('The type of thing we want bitbucket to build.'),
    '#required' => TRUE,
  ];
  $form['ref']['name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Reference name'),
    '#default_value' => isset($this->configuration['ref']['name']) ? $this->configuration['ref']['name'] : '',
    '#description' => $this
      ->t('The name of the branch or tag to build.'),
    '#required' => TRUE,
  ];
  $form['selector'] = [
    '#type' => 'fieldset',
  ];
  $form['selector']['type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Pipeline type'),
    '#options' => [
      'custom' => $this
        ->t('Custom'),
      'pull-requests' => $this
        ->t('Pull Request'),
    ],
    '#default_value' => isset($this->configuration['selector_type']) ? $this->configuration['selector_type'] : '',
    '#description' => $this
      ->t('The type of pipeline.'),
    '#required' => TRUE,
  ];
  $form['selector']['name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Pipeline name'),
    '#default_value' => isset($this->configuration['selector']['name']) ? $this->configuration['selector']['name'] : '',
    '#description' => $this
      ->t('The name of the pipeline to trigger for this branch.'),
    '#required' => TRUE,
  ];
  return $form;
}