Skip to content

Commit

Permalink
linting form alter
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak authored and pwtyler committed Nov 14, 2024
1 parent acc1ff6 commit 0fa29c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"ext-curl": "*",
"ext-json": "*",
"ext-zip": "*",
"drupal/pluginformalter": "^1",
"drupal/search_api_solr": "^4.3",
"guzzlehttp/guzzle": "^6.5.7|^7.5",
"http-interop/http-factory-guzzle": "^1.0",
Expand Down
24 changes: 14 additions & 10 deletions src/Plugin/FormAlter/SolrReloadFormAlter.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php

namespace Drupal\search_api_pantheon\Plugin\FormAlter;
use \Drupal\Core\StringTranslation\StringTranslationTrait;
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\pluginformalter\Plugin\FormAlterInterface;
use Drupal\pluginformalter\Plugin\FormAlterBase;
use Drupal\Core\Form\FormStateInterface;

/**
* Class SolrReloadFormAlter.
* Alter the reload form for the pantheon environment.
*
* @FormAlter(
* id = "search_api_pantheon_reload_form_alter",
Expand All @@ -17,25 +22,24 @@
*
* @package Drupal\search_api_pantheon\Plugin\FormAlter
*/
class SolrReloadFormAlter {
class SolrReloadFormAlter extends FormAlterBase implements FormAlterInterface {
use StringTranslationTrait;
use DependencySerializationTrait;

/**
* {@inheritdoc}
*/
public function formAlter(array &$form, FormStateInterface $form_state, $form_id) {
// do something here, for example add submit handler.
print_r($form_state->getValues());
$submit_handler = __CLASS__ . '::formSubmit';
array_unshift($form['actions']['submit']['#submit'], $submit_handler);
// override the default form submit and use ours.
$form['#submit'][] = __CLASS__ . '::formSubmit';
}

/**
* Custom form submit.
*/
public static function formSubmit($form, FormStateInterface $form_state) {
print_r($form_state->getValues());
exit(1);
$rl = \Drupal::service("search_api_pantheon.reload");
$rl->reloadServer();
}

}
}

0 comments on commit 0fa29c5

Please sign in to comment.