You are here

public function NewRelicRpmDeploy::submitForm in New Relic 8

Same name and namespace in other branches
  1. 2.x src/Form/NewRelicRpmDeploy.php \Drupal\new_relic_rpm\Form\NewRelicRpmDeploy::submitForm()
  2. 2.0.x src/Form/NewRelicRpmDeploy.php \Drupal\new_relic_rpm\Form\NewRelicRpmDeploy::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/NewRelicRpmDeploy.php, line 91

Class

NewRelicRpmDeploy
Provides a form to allow marking deployments on the New Relic interface.

Namespace

Drupal\new_relic_rpm\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $deployment = $this->newRelicClient
    ->createDeployment($form_state
    ->getValue([
    'revision',
  ]), $form_state
    ->getValue([
    'description',
  ]), $form_state
    ->getValue([
    'user',
  ]), $form_state
    ->getValue([
    'changelog',
  ]));
  if ($deployment) {
    $this
      ->messenger()
      ->addStatus($this
      ->t('New Relic deployment created successfully.'));
  }
  else {
    $this
      ->messenger()
      ->addError($this
      ->t('New Relic deployment failed.'));
  }
}