Skip to content
Snippets Groups Projects
Commit bb11089f authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Improve readability with null coalescing operator.

parent fbc377c4
No related merge requests found
...@@ -102,7 +102,7 @@ class CombinedController extends AbstractSearch ...@@ -102,7 +102,7 @@ class CombinedController extends AbstractSearch
$settings['view'] = $this->forwardTo($controller, $action); $settings['view'] = $this->forwardTo($controller, $action);
// Should we suppress content due to emptiness? // Should we suppress content due to emptiness?
if (isset($settings['hide_if_empty']) && $settings['hide_if_empty'] if (($settings['hide_if_empty'] ?? false)
&& $settings['view']->results->getResultTotal() == 0 && $settings['view']->results->getResultTotal() == 0
) { ) {
$html = ''; $html = '';
...@@ -117,8 +117,7 @@ class CombinedController extends AbstractSearch ...@@ -117,8 +117,7 @@ class CombinedController extends AbstractSearch
'showCartControls' => $currentOptions->supportsCart() 'showCartControls' => $currentOptions->supportsCart()
&& $cart->isActive(), && $cart->isActive(),
'showBulkOptions' => $currentOptions->supportsCart() 'showBulkOptions' => $currentOptions->supportsCart()
&& isset($general->Site->showBulkOptions) && ($general->Site->showBulkOptions ?? false)
&& $general->Site->showBulkOptions
]; ];
// Load custom CSS, if necessary: // Load custom CSS, if necessary:
$html = $this->getViewRenderer()->plugin('headLink')->__invoke(); $html = $this->getViewRenderer()->plugin('headLink')->__invoke();
...@@ -175,10 +174,9 @@ class CombinedController extends AbstractSearch ...@@ -175,10 +174,9 @@ class CombinedController extends AbstractSearch
$combinedResults[$current]['domId'] $combinedResults[$current]['domId']
= 'combined_' . str_replace(':', '____', $current); = 'combined_' . str_replace(':', '____', $current);
$combinedResults[$current]['view'] $combinedResults[$current]['view'] = ($settings['ajax'] ?? false)
= (!isset($settings['ajax']) || !$settings['ajax']) ? $this->createViewModel(['results' => $results])
? $this->forwardTo($controller, $action) : $this->forwardTo($controller, $action);
: $this->createViewModel(['results' => $results]);
// Special case: include appropriate "powered by" message: // Special case: include appropriate "powered by" message:
if (strtolower($searchClassId) == 'summon') { if (strtolower($searchClassId) == 'summon') {
...@@ -190,10 +188,9 @@ class CombinedController extends AbstractSearch ...@@ -190,10 +188,9 @@ class CombinedController extends AbstractSearch
// Run the search to obtain recommendations: // Run the search to obtain recommendations:
$results->performAndProcessSearch(); $results->performAndProcessSearch();
$columns = isset($config['Layout']['columns']) $actualMaxColumns = count($combinedResults);
&& intval($config['Layout']['columns']) <= count($combinedResults) $columnConfig = intval($config['Layout']['columns'] ?? $actualMaxColumns);
? intval($config['Layout']['columns']) $columns = min($columnConfig, $actualMaxColumns);
: count($combinedResults);
$placement = $config['Layout']['stack_placement'] $placement = $config['Layout']['stack_placement']
?? 'distributed'; ?? 'distributed';
if (!in_array($placement, ['distributed', 'left', 'right'])) { if (!in_array($placement, ['distributed', 'left', 'right'])) {
...@@ -301,9 +298,7 @@ class CombinedController extends AbstractSearch ...@@ -301,9 +298,7 @@ class CombinedController extends AbstractSearch
// Always leave noresults active (useful for 0-hit searches) and // Always leave noresults active (useful for 0-hit searches) and
// side inactive (no room to display) but display or hide top based // side inactive (no room to display) but display or hide top based
// on include_recommendations setting. // on include_recommendations setting.
if (isset($settings['include_recommendations']) if ($settings['include_recommendations'] ?? false) {
&& $settings['include_recommendations']
) {
$query->noRecommend = 'side'; $query->noRecommend = 'side';
if (is_array($settings['include_recommendations'])) { if (is_array($settings['include_recommendations'])) {
$query->recommendOverride $query->recommendOverride
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment