class GenericFrontendEnvironment in Build Hooks 8.2
Same name and namespace in other branches
- 3.x src/Plugin/FrontendEnvironment/GenericFrontendEnvironment.php \Drupal\build_hooks\Plugin\FrontendEnvironment\GenericFrontendEnvironment
Provides a 'Generic' frontend environment type.
Plugin annotation
@FrontendEnvironment(
id = "generic",
label = "Generic",
description = "Use this type for any environment that supports build hooks."
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\build_hooks\Plugin\FrontendEnvironmentBase implements FrontendEnvironmentInterface, PluginWithFormsInterface uses PluginWithFormsTrait, StringTranslationTrait
- class \Drupal\build_hooks\Plugin\FrontendEnvironment\GenericFrontendEnvironment
- class \Drupal\build_hooks\Plugin\FrontendEnvironmentBase implements FrontendEnvironmentInterface, PluginWithFormsInterface uses PluginWithFormsTrait, StringTranslationTrait
Expanded class hierarchy of GenericFrontendEnvironment
File
- src/
Plugin/ FrontendEnvironment/ GenericFrontendEnvironment.php, line 18
Namespace
Drupal\build_hooks\Plugin\FrontendEnvironmentView source
class GenericFrontendEnvironment extends FrontendEnvironmentBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function frontEndEnvironmentForm($form, FormStateInterface $form_state) {
// For this type of plugin, we only need the build hook url:
$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;
}
/**
* {@inheritdoc}
*/
public function frontEndEnvironmentSubmit($form, FormStateInterface $form_state) {
$this->configuration['build_hook_url'] = $form_state
->getValue('build_hook_url');
}
/**
* {@inheritdoc}
*/
public function getBuildHookDetails() {
$buildHookDetails = new BuildHookDetails();
$buildHookDetails
->setUrl($this->configuration['build_hook_url']);
$buildHookDetails
->setMethod('POST');
return $buildHookDetails;
}
/**
* {@inheritdoc}
*/
public function getAdditionalDeployFormElements(FormStateInterface $form_state) {
// No additional form elements for the deploy form for this type of plugin.
return [];
}
}