GenericFrontendEnvironment.php in Build Hooks 8.2
File
src/Plugin/FrontendEnvironment/GenericFrontendEnvironment.php
View source
<?php
namespace Drupal\build_hooks\Plugin\FrontendEnvironment;
use Drupal\build_hooks\BuildHookDetails;
use Drupal\build_hooks\Plugin\FrontendEnvironmentBase;
use Drupal\Core\Form\FormStateInterface;
class GenericFrontendEnvironment extends FrontendEnvironmentBase {
public function defaultConfiguration() {
return [] + parent::defaultConfiguration();
}
public function frontEndEnvironmentForm($form, FormStateInterface $form_state) {
$form['build_hook_url'] = [
'#type' => 'url',
'#title' => $this
->t('Build hook url'),
'#maxlength' => 255,
'#default_value' => isset($this->configuration['build_hook_url']) ? $this->configuration['build_hook_url'] : '',
'#description' => $this
->t("Build hook url for this environment."),
'#required' => TRUE,
];
return $form;
}
public function frontEndEnvironmentSubmit($form, FormStateInterface $form_state) {
$this->configuration['build_hook_url'] = $form_state
->getValue('build_hook_url');
}
public function getBuildHookDetails() {
$buildHookDetails = new BuildHookDetails();
$buildHookDetails
->setUrl($this->configuration['build_hook_url']);
$buildHookDetails
->setMethod('POST');
return $buildHookDetails;
}
public function getAdditionalDeployFormElements(FormStateInterface $form_state) {
return [];
}
}