Skip to content
Snippets Groups Projects
Commit c693dd13 authored by Demian Katz's avatar Demian Katz
Browse files

Smarter handler matching.

parent 55644673
No related merge requests found
...@@ -133,7 +133,7 @@ abstract class SearchObject implements RecommendInterface ...@@ -133,7 +133,7 @@ abstract class SearchObject implements RecommendInterface
$params->setLimit($this->limit); $params->setLimit($this->limit);
$params->setBasicSearch( $params->setBasicSearch(
$lookfor, $lookfor,
$params->getOptions()->getBasicHandlerForLabel($typeLabel) $params->getOptions()->getHandlerForLabel($typeLabel)
); );
// Perform the search: // Perform the search:
......
...@@ -159,17 +159,25 @@ abstract class Options implements TranslatorAwareInterface ...@@ -159,17 +159,25 @@ abstract class Options implements TranslatorAwareInterface
/** /**
* Given a label from the configuration file, return the name of the matching * Given a label from the configuration file, return the name of the matching
* basic handler; return the default handler if no match is found. * handler (basic checked first, then advanced); return the default handler
* if no match is found.
* *
* @param string $label Label to search for * @param string $label Label to search for
* *
* @return string * @return string
*/ */
public function getBasicHandlerForLabel($label) public function getHandlerForLabel($label)
{ {
$label = $this->translate($label);
$targetHandler = false; $targetHandler = false;
foreach ($this->getBasicHandlers() as $id => $currentLabel) { foreach ($this->getBasicHandlers() as $id => $currentLabel) {
if ($currentLabel == $label) { if ($this->translate($currentLabel) == $label) {
return $id;
}
}
foreach ($this->getAdvancedHandlers() as $id => $currentLabel) {
if ($this->translate($currentLabel) == $label) {
return $id; return $id;
} }
} }
......
...@@ -142,7 +142,7 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper ...@@ -142,7 +142,7 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper
$options = $results->getOptions(); $options = $results->getOptions();
// Find matching handler for new query (and use default if no match): // Find matching handler for new query (and use default if no match):
$targetHandler = $options->getBasicHandlerForLabel( $targetHandler = $options->getHandlerForLabel(
$activeOptions->getLabelForBasicHandler($handler) $activeOptions->getLabelForBasicHandler($handler)
); );
......
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