Skip to content

Commit

Permalink
#69 Prepends site base URL to site-relative search page URL
Browse files Browse the repository at this point in the history
  • Loading branch information
timurtripp committed Oct 23, 2024
1 parent 375188d commit 1bc3736
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/SiteConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RequestContext;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
Expand Down Expand Up @@ -57,6 +58,13 @@ class SiteConfiguration {
*/
protected $entityTypeRepository;

/**
* The request context.
*
* @var \Drupal\Core\Routing\RequestContext
*/
protected $requestContext;

/**
* The current route match.
*
Expand Down Expand Up @@ -86,6 +94,8 @@ class SiteConfiguration {
* The entity type manager.
* @param \Drupal\Core\Entity\EntityTypeRepositoryInterface $entity_type_repository
* The entity type repository.
* @param \Drupal\Core\Routing\RequestContext $request_context
* The request context.
* @param \Drupal\Core\Routing\RouteMatchInterface $current_route_match
* The current route match.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
Expand All @@ -98,6 +108,7 @@ public function __construct(
TranslationManager $string_translation,
EntityTypeManagerInterface $entity_type_manager,
EntityTypeRepositoryInterface $entity_type_repository,
RequestContext $request_context,
RouteMatchInterface $current_route_match,
MessengerInterface $messenger,
) {
Expand All @@ -107,6 +118,7 @@ public function __construct(
$this->stringTranslation = $string_translation;
$this->entityTypeManager = $entity_type_manager;
$this->entityTypeRepository = $entity_type_repository;
$this->requestContext = $request_context;
$this->currentRouteMatch = $current_route_match;
$this->messenger = $messenger;
}
Expand Down Expand Up @@ -349,7 +361,7 @@ public function attachSiteInformation(array &$variables) {
}
$searchUrl = $settings->get('site_search_url');
if ($searchUrl) {
$siteSearchOption['url'] = $searchUrl;
$siteSearchOption['url'] = $this->requestContext->getCompleteBaseUrl() . $searchUrl;
}
}
$variables['site_search'][] = $siteSearchOption;
Expand Down
2 changes: 1 addition & 1 deletion ucb_site_configuration.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CU Boulder Site Configuration
description: 'Allows CU Boulder site administrators to configure site-specific settings.'
core_version_requirement: ^9 || ^10
type: module
version: '2.8.5'
version: '2.8.6'
package: CU Boulder
dependencies:
- block
Expand Down
1 change: 1 addition & 0 deletions ucb_site_configuration.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ services:
- '@string_translation'
- '@entity_type.manager'
- '@entity_type.repository'
- '@router.request_context'
- '@current_route_match'
- '@messenger'

0 comments on commit 1bc3736

Please sign in to comment.