Return data from WebformHandler to Controller I created WebformHandler where I need to get data entered in the form on submit. It's something like this:

&lt;?php

namespace Drupal\xxx\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Form submission handler.
 *
 *
 * @WebformHandler(
 *   id = "xxx",
 *   label = @Translation("xxxx"),
 *   category = @Translation("xxx"),
 *   description = @Translation("xxx"),
 *   cardinality =
 *       \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *   results =
 *    \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */
class XxXx extends WebformHandlerBase {

  public function confirmForm(array &amp;$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

    $values = $webform_submission-&gt;getData();
    // Get data here
  }
}


I also have the Controller and defined route with template file. Controller looks like this:

&lt;?php

namespace Drupal\xxx\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\xxx\Plugin\WebformHandler;

/**
 * Class SearchFlightsController.
 */
class XxXController extends ControllerBase {

  /**
   * xXx.
   *
   * @return array
   *   Return search parameters string.
   */
  public function xXx() {

    return [
      '#theme' =&gt; 'xxx',
      '#search_query' =&gt; $this-&gt;t('Test Value'),
    ];

  }

}


My question is how to pass the data that I get in WebformHandler on form submit to Controller that need to show the page with defined route?
I don't know why you want to pass the data to the controller, you can do anything with the data in the webformhandler code. or you can pass the data using the namespace declared on the controller. please check the following code.
Inside the controller file place the below code that I have added new function to handle the webform data.


  

namespace Drupal\xxx\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\xxx\Plugin\WebformHandler;

/**
 * Class SearchFlightsController.
 */
class XxXController extends ControllerBase {

  /**
   * xXx.
   *
   * @return array
   *   Return search parameters string.
   */
  public function xXx() {

    return [
      '#theme' =&gt; 'xxx',
      '#search_query' =&gt; $this-&gt;t('Test Value'),
    ];

  }

  public function getwebform($formdata){
      /** place your code what want to do with $formdata*/
  }

}     



//After that inside the webformhandler code write the following code 
 /** take the data from webform and save in an array variable $formdata then pass to the function defined inside the controller */ 

use Drupal\xxx\Controller\XxXController;
$webfrmdata = new  XxXController;
$webfrmdata->getwebform($formdata);

I have not tested but hope this code can help you