From 18efe8ef0f51a75a412678600ad8422c74ba82cd Mon Sep 17 00:00:00 2001
From: Lily Yan <l26yan@uwaterloo.ca>
Date: Thu, 7 Nov 2024 10:45:59 -0500
Subject: [PATCH] ISTWCMS-7182 Remove validation of quote text field in
 UwCblBlockquoteEventSubscriber.php due to this field is set to required in UI

---
 .../UwCblBlockquoteEventSubscriber.php        | 51 -------------------
 1 file changed, 51 deletions(-)

diff --git a/src/EventSubscriber/UwCblBlockquoteEventSubscriber.php b/src/EventSubscriber/UwCblBlockquoteEventSubscriber.php
index 537992c8..5f90c639 100644
--- a/src/EventSubscriber/UwCblBlockquoteEventSubscriber.php
+++ b/src/EventSubscriber/UwCblBlockquoteEventSubscriber.php
@@ -2,9 +2,6 @@
 
 namespace Drupal\uw_custom_blocks\EventSubscriber;
 
-use Drupal\Core\Form\FormStateInterface;
-use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
-use Drupal\core_event_dispatcher\FormHookEvents;
 use Drupal\preprocess_event_dispatcher\Event\BlockPreprocessEvent;
 use Drupal\uw_custom_blocks\CustomBlocks\UwCblBase;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -14,53 +11,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  */
 class UwCblBlockquoteEventSubscriber extends UwCblBase implements EventSubscriberInterface {
 
-  /**
-   * Alter form.
-   *
-   * @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
-   *   The event.
-   */
-  public function alterForm(FormAlterEvent $event): void {
-
-    if ($this->checkLayoutBuilder($event, 'Blockquote')) {
-
-      // Get the form from the event.
-      $form = &$event->getForm();
-
-      // Add the validation for blockquote.
-      $form['#validate'][] = [$this, 'validateBlockquote'];
-    }
-  }
-
-  /**
-   * Form validation for blockquote.
-   *
-   * @param array $form
-   *   The complete form structure.
-   * @param \Drupal\Core\Form\FormStateInterface $form_state
-   *   The form state.
-   */
-  public function validateBlockquote(array &$form, FormStateInterface $form_state) {
-
-    // Get the settings from the form.
-    $settings = $form_state->getValue('settings', NULL);
-
-    // If there are settings, continue to process.
-    if ($settings) {
-
-      // If there is a block, continue to process.
-      if ($block = $settings['block_form']) {
-
-        // If there is no text in the quote text, set error.
-        if ($block['field_uw_bq_quote_text'][0]['value'] == '') {
-
-          // Set the form error for not having any quote text.
-          $form_state->setErrorByName('settings][block_form][field_uw_bq_quote_text', 'You must enter quote text.');
-        }
-      }
-    }
-  }
-
   /**
    * Preprocess blocks with blockquote and set variables.
    *
@@ -104,7 +54,6 @@ class UwCblBlockquoteEventSubscriber extends UwCblBase implements EventSubscribe
    */
   public static function getSubscribedEvents() {
     return [
-      FormHookEvents::FORM_ALTER => 'alterForm',
       BlockPreprocessEvent::name() => 'preprocessBlock',
     ];
   }
-- 
GitLab