diff --git a/src/Utility/FieldsHelper.php b/src/Utility/FieldsHelper.php index 33d9a293..819245fd 100644 --- a/src/Utility/FieldsHelper.php +++ b/src/Utility/FieldsHelper.php @@ -81,16 +81,21 @@ class FieldsHelper implements FieldsHelperInterface { * The entity type bundle info service. * @param \Drupal\search_api\Utility\DataTypeHelperInterface $dataTypeHelper * The data type helper service. - * @param \Drupal\search_api\Utility\ThemeSwitcherInterface $themeSwitcher - * The theme switcher service. + * @param \Drupal\search_api\Utility\ThemeSwitcherInterface|null $themeSwitcher + * (optional) The theme switcher service. */ public function __construct( EntityTypeManagerInterface $entityTypeManager, EntityFieldManagerInterface $entityFieldManager, EntityTypeBundleInfoInterface $entityBundleInfo, DataTypeHelperInterface $dataTypeHelper, - ThemeSwitcherInterface $themeSwitcher + ?ThemeSwitcherInterface $themeSwitcher = NULL, ) { + if (!$themeSwitcher) { + @trigger_error('Constructing \Drupal\search_api\Utility\FieldsHelper without the $themeSwitcher parameter is deprecated in search_api:8.x-1.31 and it will be required in search_api:2.0.0. See https://www.drupal.org/node/3320841', + E_USER_DEPRECATED); + $themeSwitcher = \Drupal::service('search_api.theme_switcher'); + } $this->entityTypeManager = $entityTypeManager; $this->entityFieldManager = $entityFieldManager; $this->entityBundleInfo = $entityBundleInfo;