From 0b2885ac5b77821d8418aa2c2290678a3be22a00 Mon Sep 17 00:00:00 2001
From: Qiangjun Ran <ranqiangjun@gmail.com>
Date: Tue, 23 Apr 2024 11:40:06 +0800
Subject: [PATCH 1/2] Inject the vefl.layout service in ::create()

---
 .../src/Plugin/views/exposed_form/VeflBef.php | 43 ++-----------------
 1 file changed, 3 insertions(+), 40 deletions(-)

diff --git a/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php b/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php
index f843703..dbcc4fb 100644
--- a/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php
+++ b/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php
@@ -50,50 +50,13 @@ class VeflBef extends BetterExposedFilters {
    */
   protected $vefl;
 
-  /**
-   * BetterExposedFilters constructor.
-   *
-   * @param array $configuration
-   *   A configuration array containing information about the plugin instance.
-   * @param string $plugin_id
-   *   The plugin_id for the plugin instance.
-   * @param mixed $plugin_definition
-   *   The plugin implementation definition.
-   * @param \Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetManager $filter_widget_manager
-   *   The better exposed filter widget manager for filter widgets.
-   * @param \Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetManager $pager_widget_manager
-   *   The better exposed filter widget manager for pager widgets.
-   * @param \Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetManager $sort_widget_manager
-   *   The better exposed filter widget manager for sort widgets.
-   * @param \Drupal\vefl\Vefl $vefl
-   *   The vefl layout helper.
-   */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, BetterExposedFiltersWidgetManager $filter_widget_manager, BetterExposedFiltersWidgetManager $pager_widget_manager, BetterExposedFiltersWidgetManager $sort_widget_manager, Vefl $vefl) {
-    parent::__construct(
-      $configuration,
-      $plugin_id,
-      $plugin_definition,
-      $this->filterWidgetManager = $filter_widget_manager,
-      $this->pagerWidgetManager = $pager_widget_manager,
-      $this->sortWidgetManager = $sort_widget_manager
-    );
-
-    $this->vefl = $vefl;
-  }
-
   /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
-    return new static(
-      $configuration,
-      $plugin_id,
-      $plugin_definition,
-      $container->get('plugin.manager.better_exposed_filters_filter_widget'),
-      $container->get('plugin.manager.better_exposed_filters_pager_widget'),
-      $container->get('plugin.manager.better_exposed_filters_sort_widget'),
-      $container->get('vefl.layout')
-    );
+    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+    $instance->vefl = $container->get('vefl.layout');
+    return $instance;
   }
 
   /**
-- 
GitLab


From cd3da0d673d69462ed4cd0630abbb1dd17ccc1c2 Mon Sep 17 00:00:00 2001
From: Joseph Descalzota <joseph.descalzota@portlandwebworks.com>
Date: Thu, 22 Aug 2024 21:26:42 -0400
Subject: [PATCH 2/2] BEF 7.0 types.

---
 .../src/Plugin/views/exposed_form/VeflBef.php        |  8 ++++----
 src/Plugin/views/exposed_form/VeflTrait.php          | 12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php b/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php
index dbcc4fb..8359b77 100644
--- a/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php
+++ b/modules/vefl_bef/src/Plugin/views/exposed_form/VeflBef.php
@@ -27,21 +27,21 @@ class VeflBef extends BetterExposedFilters {
    *
    * @var \Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetManager
    */
-  public $filterWidgetManager;
+  public BetterExposedFiltersWidgetManager $filterWidgetManager;
 
   /**
    * BEF pager widget plugin manager.
    *
    * @var \Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetManager
    */
-  public $pagerWidgetManager;
+  public BetterExposedFiltersWidgetManager $pagerWidgetManager;
 
   /**
    * BEF sort widget plugin manager.
    *
    * @var \Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetManager
    */
-  public $sortWidgetManager;
+  public BetterExposedFiltersWidgetManager $sortWidgetManager;
 
   /**
    * The vefl layout helper.
@@ -53,7 +53,7 @@ class VeflBef extends BetterExposedFilters {
   /**
    * {@inheritdoc}
    */
-  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): static {
     $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
     $instance->vefl = $container->get('vefl.layout');
     return $instance;
diff --git a/src/Plugin/views/exposed_form/VeflTrait.php b/src/Plugin/views/exposed_form/VeflTrait.php
index 1f7684b..099a7dc 100644
--- a/src/Plugin/views/exposed_form/VeflTrait.php
+++ b/src/Plugin/views/exposed_form/VeflTrait.php
@@ -12,7 +12,7 @@ trait VeflTrait {
   /**
    * {@inheritdoc}
    */
-  protected function defineOptions() {
+  protected function defineOptions(): array {
     $options = parent::defineOptions();
     $options['layout'] = [
       'contains' => [
@@ -27,7 +27,7 @@ trait VeflTrait {
   /**
    * {@inheritdoc}
    */
-  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+  public function buildOptionsForm(&$form, FormStateInterface $form_state): void {
     parent::buildOptionsForm($form, $form_state);
 
     $layout_id = $this->options['layout']['layout_id'];
@@ -65,7 +65,7 @@ trait VeflTrait {
    * @return array
    *   Form elements.
    */
-  private function getRegionElements($layout_id, array $layouts = []) {
+  private function getRegionElements($layout_id, array $layouts = []): array {
     $element = [
       '#prefix' => '<div id="edit-block-region-wrapper">',
       '#suffix' => '</div>',
@@ -120,7 +120,7 @@ trait VeflTrait {
    *
    * Takes care of content translation deletion.
    */
-  public function updateRegions($form, FormStateInterface $form_state) {
+  public function updateRegions($form, FormStateInterface $form_state): void {
     $view = $form_state->get('view');
     $display_id = $form_state->get('display_id');
 
@@ -139,7 +139,7 @@ trait VeflTrait {
    *
    * @inheritdoc
    */
-  public function exposedFormAlter(&$form, FormStateInterface $form_state) {
+  public function exposedFormAlter(&$form, FormStateInterface $form_state): void {
     parent::exposedFormAlter($form, $form_state);
 
     $view = $form_state->get('view');
@@ -179,7 +179,7 @@ trait VeflTrait {
    * @return array
    *   Form element.
    */
-  private function createSelectElementForVeflForm($element_id, $label, array $regions) {
+  private function createSelectElementForVeflForm($element_id, $label, array $regions): array {
     $element = [
       '#type' => 'select',
       '#title' => $label,
-- 
GitLab

