You are here

class GenericFrontendEnvironment in Build Hooks 3.x

Same name and namespace in other branches
  1. 8.2 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

Expanded class hierarchy of GenericFrontendEnvironment

File

src/Plugin/FrontendEnvironment/GenericFrontendEnvironment.php, line 18

Namespace

Drupal\build_hooks\Plugin\FrontendEnvironment
View source
class GenericFrontendEnvironment extends FrontendEnvironmentBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'build_hook_url' => '',
    ] + 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 [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrontendEnvironmentBase::$transliteration protected property The transliteration service.
FrontendEnvironmentBase::baseConfigurationDefaults protected function Returns generic default configuration for frontend environment plugins.
FrontendEnvironmentBase::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm
FrontendEnvironmentBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies
FrontendEnvironmentBase::deploymentWasTriggered public function Determine if the deployment was triggered successfully. Overrides FrontendEnvironmentInterface::deploymentWasTriggered 2
FrontendEnvironmentBase::frontEndEnvironmentFormValidate public function 1
FrontendEnvironmentBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
FrontendEnvironmentBase::getMachineNameSuggestion public function
FrontendEnvironmentBase::label public function
FrontendEnvironmentBase::preDeploymentTrigger public function React before a build is triggered. Overrides FrontendEnvironmentInterface::preDeploymentTrigger 1
FrontendEnvironmentBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
FrontendEnvironmentBase::setConfigurationValue public function
FrontendEnvironmentBase::setTransliteration public function Sets the transliteration service.
FrontendEnvironmentBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
FrontendEnvironmentBase::transliteration protected function Wraps the transliteration service.
FrontendEnvironmentBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
FrontendEnvironmentBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct 4
GenericFrontendEnvironment::defaultConfiguration public function Gets default configuration for this plugin. Overrides FrontendEnvironmentBase::defaultConfiguration
GenericFrontendEnvironment::frontEndEnvironmentForm public function Overrides FrontendEnvironmentBase::frontEndEnvironmentForm
GenericFrontendEnvironment::frontEndEnvironmentSubmit public function Overrides FrontendEnvironmentBase::frontEndEnvironmentSubmit
GenericFrontendEnvironment::getAdditionalDeployFormElements public function Allows the plugin to add elements to the deployment form. Overrides FrontendEnvironmentInterface::getAdditionalDeployFormElements
GenericFrontendEnvironment::getBuildHookDetails public function Get the info to trigger the hook based on the configuration of the plugin. Overrides FrontendEnvironmentInterface::getBuildHookDetails
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginWithFormsTrait::getFormClass public function Implements \Drupal\Core\Plugin\PluginWithFormsInterface::getFormClass().
PluginWithFormsTrait::hasFormClass public function Implements \Drupal\Core\Plugin\PluginWithFormsInterface::hasFormClass().
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.