Skip to content

Commit

Permalink
CuBoulder/tiamat-theme#266 exposes site_search to theme; adds minor…
Browse files Browse the repository at this point in the history
… cleanup
  • Loading branch information
timurtripp committed Oct 26, 2023
1 parent 890f36b commit 7155de5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 34 deletions.
14 changes: 1 addition & 13 deletions src/Form/GeneralForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\ucb_site_configuration\SiteConfiguration;
use Symfony\Component\DependencyInjection\ContainerInterface;

Expand All @@ -14,13 +13,6 @@
*/
class GeneralForm extends ConfigFormBase {

/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $user;

/**
* The request context.
*
Expand All @@ -40,14 +32,11 @@ class GeneralForm extends ConfigFormBase {
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Session\AccountInterface $user
* The current user.
* @param \Drupal\ucb_site_configuration\SiteConfiguration $service
* The site configuration service defined in this module.
*/
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $user, SiteConfiguration $service) {
public function __construct(ConfigFactoryInterface $config_factory, SiteConfiguration $service) {
parent::__construct($config_factory);
$this->user = $user;
$this->service = $service;
}

Expand All @@ -62,7 +51,6 @@ public function __construct(ConfigFactoryInterface $config_factory, AccountInter
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('current_user'),
$container->get('ucb_site_configuration')
);
}
Expand Down
14 changes: 1 addition & 13 deletions src/Form/PagesForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Path\PathValidatorInterface;
use Drupal\Core\Routing\RequestContext;
use Drupal\Core\Session\AccountInterface;
use Drupal\path_alias\AliasManagerInterface;
use Drupal\ucb_site_configuration\SiteConfiguration;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -17,13 +16,6 @@
*/
class PagesForm extends ConfigFormBase {

/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $user;

/**
* The path alias manager.
*
Expand Down Expand Up @@ -57,8 +49,6 @@ class PagesForm extends ConfigFormBase {
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Session\AccountInterface $user
* The current user.
* @param \Drupal\path_alias\AliasManagerInterface $alias_manager
* The path alias manager.
* @param \Drupal\Core\Path\PathValidatorInterface $path_validator
Expand All @@ -68,9 +58,8 @@ class PagesForm extends ConfigFormBase {
* @param \Drupal\ucb_site_configuration\SiteConfiguration $service
* The site configuration service defined in this module.
*/
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $user, AliasManagerInterface $alias_manager, PathValidatorInterface $path_validator, RequestContext $request_context, SiteConfiguration $service) {
public function __construct(ConfigFactoryInterface $config_factory, AliasManagerInterface $alias_manager, PathValidatorInterface $path_validator, RequestContext $request_context, SiteConfiguration $service) {
parent::__construct($config_factory);
$this->user = $user;
$this->aliasManager = $alias_manager;
$this->pathValidator = $path_validator;
$this->requestContext = $request_context;
Expand All @@ -88,7 +77,6 @@ public function __construct(ConfigFactoryInterface $config_factory, AccountInter
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('current_user'),
$container->get('path_alias.manager'),
$container->get('path.validator'),
$container->get('router.request_context'),
Expand Down
22 changes: 22 additions & 0 deletions src/SiteConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,28 @@ public function attachSiteInformation(array &$variables) {
'url' => '',
]);
$variables['site_affiliation'] = array_merge(['id' => $siteAffiliationId], $siteAffiliationAttribs);
$siteSearchOptions = $configuration->get('site_search_options');
$siteSearchEnabled = $settings->get('site_search_enabled');
$variables['site_search'] = [];
foreach ($siteSearchEnabled as $name) {
$siteSearchOption = $siteSearchOptions[$name];
$siteSearchOption['name'] = $name;
if ('custom' == $name) {
$searchLabel = $settings->get('site_search_label');
if ($searchLabel) {
$siteSearchOption['label'] = $searchLabel;
}
$searchPlaceholder = $settings->get('site_search_placeholder');
if ($searchPlaceholder) {
$siteSearchOption['placeholder'] = $searchPlaceholder;
}
$searchUrl = $settings->get('site_search_url');
if ($searchUrl) {
$siteSearchOption['url'] = $searchUrl;
}
}
$variables['site_search'][] = $siteSearchOption;
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions ucb_site_configuration.links.menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ ucb_site_configuration:

ucb_site_configuration.general_form:
title: General
description: 'Modify general settings or information about the site.'
description: 'Modify the site name, type, or affiliation.'
route_name: ucb_site_configuration.general_form
parent: ucb_site_configuration
weight: 0
ucb_site_configuration.appearance_form:
title: Appearance
description: 'Change the appearance, layout, and formatting of the site theme.'
title: Appearance and layout
description: 'Change the appearance, layout, or formatting options of the site.'
route_name: ucb_site_configuration.appearance_form
parent: ucb_site_configuration
weight: 1
ucb_site_configuration.pages_form:
title: Pages & search
title: Pages and search
description: 'Change the site home page or search options.'
route_name: ucb_site_configuration.pages_form
parent: ucb_site_configuration
Expand Down
4 changes: 2 additions & 2 deletions ucb_site_configuration.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ ucb_site_configuration.general_form:
weight: 0
ucb_site_configuration.appearance_form:
route_name: ucb_site_configuration.appearance_form
title: 'Appearance'
title: 'Appearance and layout'
base_route: ucb_site_configuration
weight: 1
ucb_site_configuration.pages_form:
route_name: ucb_site_configuration.pages_form
title: 'Pages & search'
title: 'Pages and search'
base_route: ucb_site_configuration
weight: 2
ucb_site_configuration.contact_info_form:
Expand Down
4 changes: 2 additions & 2 deletions ucb_site_configuration.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ucb_site_configuration.appearance_form:
path: '/admin/config/cu-boulder/appearance'
defaults:
_form: '\Drupal\ucb_site_configuration\Form\AppearanceForm'
_title: Appearance
_title: Appearance and layout
requirements:
_permission: edit ucb site appearance
options:
Expand All @@ -34,7 +34,7 @@ ucb_site_configuration.pages_form:
path: '/admin/config/cu-boulder/pages'
defaults:
_form: '\Drupal\ucb_site_configuration\Form\PagesForm'
_title: Pages & search
_title: Pages and search
requirements:
_permission: edit ucb site pages
options:
Expand Down

0 comments on commit 7155de5

Please sign in to comment.