Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Query often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Query, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 42 | class Query |
||
| 43 | { |
||
| 44 | /** @var string */ |
||
| 45 | private $query; |
||
| 46 | /** @var int */ |
||
| 47 | private $skip = 0; |
||
| 48 | /** @var int */ |
||
| 49 | private $pageSize = 10; |
||
| 50 | /** @var string */ |
||
| 51 | private $collection; |
||
| 52 | /** @var string */ |
||
| 53 | private $area; |
||
| 54 | /** @var string */ |
||
| 55 | private $biasingProfile; |
||
| 56 | /** @var string */ |
||
| 57 | private $language; |
||
| 58 | /** @var MSort[] */ |
||
| 59 | private $sort; |
||
| 60 | /** @var CustomUrlParam[] */ |
||
| 61 | private $customUrlParams = array(); |
||
| 62 | /** @var Navigation[] */ |
||
| 63 | private $navigations = array(); |
||
| 64 | /** @var string[] */ |
||
| 65 | private $includedNavigations = array(); |
||
| 66 | /** @var string[] */ |
||
| 67 | private $excludedNavigations = array(); |
||
| 68 | /** @var string[] */ |
||
| 69 | private $fields = array(); |
||
| 70 | /** @var string[] */ |
||
| 71 | private $orFields = array(); |
||
| 72 | /** @var bool */ |
||
| 73 | private $pruneRefinements = true; |
||
| 74 | /** @var bool */ |
||
| 75 | private $disableAutocorrection = false; |
||
| 76 | /** @var bool */ |
||
| 77 | private $wildcardSearchEnabled = false; |
||
| 78 | // Removed until CBOR support for serialization / de-serialization improves |
||
| 79 | // /** @var bool */ |
||
| 80 | // private $returnBinary = false; |
||
| 81 | /** @var RestrictNavigation */ |
||
| 82 | private $restrictNavigation; |
||
| 83 | /** @var MBiasing */ |
||
| 84 | private $biasing; |
||
| 85 | |||
| 86 | /** @var Serializer */ |
||
| 87 | private $serializer; |
||
| 88 | |||
| 89 | const TILDE_REGEX = "/~((?=[\\w]*[=:]))/"; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param mixed $request |
||
| 93 | * |
||
| 94 | * @return string |
||
| 95 | */ |
||
| 96 | private function requestToJson($request) |
||
| 97 | { |
||
| 98 | $jsonRequest = null; |
||
| 99 | try { |
||
| 100 | $jsonRequest = $this->serializer->serialize($request, 'json'); |
||
| 101 | } catch (RuntimeException $e) { |
||
| 102 | throw new RuntimeException('Unable to serialize request ' . var_dump($request)); |
||
|
|
|||
| 103 | } |
||
| 104 | |||
| 105 | return $jsonRequest; |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @param string $clientKey Your client key. |
||
| 110 | * |
||
| 111 | * @return string JSON representation of request to Bridge. |
||
| 112 | */ |
||
| 113 | public function getBridgeJson($clientKey) |
||
| 114 | { |
||
| 115 | $data = $this->populateRequest($clientKey); |
||
| 116 | return $this->requestToJson($data); |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @param string $clientKey Your client key. |
||
| 121 | * @param string $navigationName Name of the navigation to get refinements for |
||
| 122 | * |
||
| 123 | * @return string JSON representation of request to Bridge. |
||
| 124 | */ |
||
| 125 | public function getBridgeRefinementsJson($clientKey, $navigationName) |
||
| 126 | { |
||
| 127 | $data = new RefinementsRequest(); |
||
| 128 | $data->originalQuery = $this->populateRequest($clientKey); |
||
| 129 | $data->navigationName = $navigationName; |
||
| 130 | return $this->requestToJson($data); |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @param string $clientKey |
||
| 135 | * |
||
| 136 | * @return Request |
||
| 137 | */ |
||
| 138 | private function populateRequest($clientKey) |
||
| 139 | { |
||
| 140 | $request = new Request(); |
||
| 141 | $request->clientKey = $clientKey; |
||
| 142 | $request->area = $this->area; |
||
| 143 | $request->collection = $this->collection; |
||
| 144 | $request->query = $this->query; |
||
| 145 | $request->fields = $this->fields; |
||
| 146 | $request->orFields = $this->orFields; |
||
| 147 | $request->language = $this->language; |
||
| 148 | $request->biasingProfile = $this->biasingProfile; |
||
| 149 | $request->pageSize = $this->pageSize; |
||
| 150 | $request->skip = $this->skip; |
||
| 151 | $request->customUrlParams = $this->customUrlParams; |
||
| 152 | $request->refinements = $this->generateSelectedRefinements($this->navigations); |
||
| 153 | $request->restrictNavigation = $this->restrictNavigation; |
||
| 154 | |||
| 155 | if (!empty($this->biasing)) { |
||
| 156 | $request->biasing = self::convertBiasing($this->biasing); |
||
| 157 | } |
||
| 158 | |||
| 159 | if (!empty($this->includedNavigations)) { |
||
| 160 | $request->includedNavigations = $this->includedNavigations; |
||
| 161 | } |
||
| 162 | |||
| 163 | if (!empty($this->excludedNavigations)) { |
||
| 164 | $request->excludedNavigations = $this->excludedNavigations; |
||
| 165 | } |
||
| 166 | |||
| 167 | $pruneRefinements = $this->pruneRefinements; |
||
| 168 | if (isset($pruneRefinements) && $pruneRefinements === false) { |
||
| 169 | $request->pruneRefinements = false; |
||
| 170 | } |
||
| 171 | |||
| 172 | $disableAutocorrection = $this->disableAutocorrection; |
||
| 173 | if (isset($disableAutocorrection) && $disableAutocorrection === true) { |
||
| 174 | $request->disableAutocorrection = true; |
||
| 175 | } |
||
| 176 | |||
| 177 | $wildcardSearchEnabled = $this->wildcardSearchEnabled; |
||
| 178 | if (isset($wildcardSearchEnabled) && $wildcardSearchEnabled === true) { |
||
| 179 | $request->wildcardSearchEnabled = true; |
||
| 180 | } |
||
| 181 | |||
| 182 | if (!empty($this->sort)) { |
||
| 183 | foreach ($this->sort as $s) { |
||
| 184 | array_push($request->sort, $this->convertSort($s)); |
||
| 185 | } |
||
| 186 | } |
||
| 187 | |||
| 188 | // $returnBinary = $this->returnBinary; |
||
| 189 | // if (isset($returnBinary) && $returnBinary === true) { |
||
| 190 | // $request->returnBinary = true; |
||
| 191 | // } |
||
| 192 | |||
| 193 | return $request; |
||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * @param Navigation[] $navigations |
||
| 198 | * |
||
| 199 | * @return Refinement[] |
||
| 200 | */ |
||
| 201 | private function generateSelectedRefinements($navigations) |
||
| 202 | { |
||
| 203 | $refinements = []; |
||
| 204 | foreach ($navigations as $key => $navigation) { |
||
| 205 | foreach ($navigation->getRefinements() as $refinement) { |
||
| 206 | switch ($refinement->getType()) { |
||
| 207 | case Type::Range: { |
||
| 208 | /** @var RefinementRange $rr */ |
||
| 209 | $rr = $refinement; |
||
| 210 | $selectedRefinementRange = new SelectedRefinementRange(); |
||
| 211 | $selectedRefinementRange |
||
| 212 | ->setNavigationName($navigation->getName()) |
||
| 213 | ->setLow($rr->getLow()) |
||
| 214 | ->setHigh($rr->getHigh()) |
||
| 215 | ->setExclude($rr->isExclude()); |
||
| 216 | |||
| 217 | array_push($refinements, $selectedRefinementRange); |
||
| 218 | break; |
||
| 219 | } |
||
| 220 | case Type::Value: { |
||
| 221 | /** @var RefinementValue $rv */ |
||
| 222 | $rv = $refinement; |
||
| 223 | $selectedRefinementValue = new SelectedRefinementValue(); |
||
| 224 | $selectedRefinementValue |
||
| 225 | ->setNavigationName($navigation->getName()) |
||
| 226 | ->setValue($rv->getValue()) |
||
| 227 | ->setExclude($rv->isExclude()); |
||
| 228 | |||
| 229 | array_push($refinements, $selectedRefinementValue); |
||
| 230 | break; |
||
| 231 | } |
||
| 232 | } |
||
| 233 | } |
||
| 234 | } |
||
| 235 | return $refinements; |
||
| 236 | } |
||
| 237 | |||
| 238 | /** |
||
| 239 | * @param string $clientKey Your client key. |
||
| 240 | * |
||
| 241 | * @return string JSON representation of request to Bridge. |
||
| 242 | */ |
||
| 243 | public function getBridgeJsonRefinementSearch($clientKey) |
||
| 244 | { |
||
| 245 | $data = new Request(); |
||
| 246 | $data->clientKey = $clientKey; |
||
| 247 | $data->collection = $this->collection; |
||
| 248 | $data->area = $this->area; |
||
| 249 | $data->refinementQuery = $this->query; |
||
| 250 | |||
| 251 | $wildcardSearchEnabled = $this->wildcardSearchEnabled; |
||
| 252 | if (isset($wildcardSearchEnabled) && $wildcardSearchEnabled === true) { |
||
| 253 | $data->wildcardSearchEnabled = true; |
||
| 254 | } |
||
| 255 | |||
| 256 | return $this->requestToJson($data); |
||
| 257 | } |
||
| 258 | |||
| 259 | public function __construct() |
||
| 263 | |||
| 264 | /** |
||
| 265 | * @return string The current search string. |
||
| 266 | */ |
||
| 267 | public function getQuery() |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @param string $query The search string. |
||
| 274 | */ |
||
| 275 | public function setQuery($query) |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @return string The data sub-collection. |
||
| 282 | */ |
||
| 283 | public function getCollection() |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @param string $collection The string representation of a collection query. |
||
| 290 | */ |
||
| 291 | public function setCollection($collection) |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @return string The area name. |
||
| 298 | */ |
||
| 299 | public function getArea() |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @param string $area The area name. |
||
| 306 | */ |
||
| 307 | public function setArea($area) |
||
| 311 | |||
| 312 | /** |
||
| 313 | * @return string[] A list of metadata fields that will be returned by the search engine. |
||
| 314 | */ |
||
| 315 | public function getFields() |
||
| 319 | |||
| 320 | /** |
||
| 321 | * @return string[] A list of the fields that the search service will treat as OR'able. |
||
| 322 | */ |
||
| 323 | public function getOrFields() |
||
| 327 | |||
| 328 | /** |
||
| 329 | * @param string[] $fields A list of case-sensitive names of the attributes to return. |
||
| 330 | */ |
||
| 331 | public function addFields($fields) |
||
| 335 | |||
| 336 | /** |
||
| 337 | * @return string[] A list of which navigations to return from the bridge. |
||
| 338 | */ |
||
| 339 | public function getIncludedNavigations() |
||
| 343 | |||
| 344 | /** |
||
| 345 | * @param string[] $navigations A list of which navigations to return from the bridge. |
||
| 346 | */ |
||
| 347 | public function addIncludedNavigations($navigations) |
||
| 351 | |||
| 352 | /** |
||
| 353 | * @return string[] A list of which navigations to not return from the bridge. |
||
| 354 | */ |
||
| 355 | public function getExcludedNavigations() |
||
| 359 | |||
| 360 | /** |
||
| 361 | * @param string[] $navigations A list of which navigations to not return from the bridge. |
||
| 362 | */ |
||
| 363 | public function addExcludedNavigations($navigations) |
||
| 367 | |||
| 368 | /** |
||
| 369 | * @return Navigation[] |
||
| 370 | */ |
||
| 371 | public function &getNavigations() |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @param Navigation[] $navigations |
||
| 378 | */ |
||
| 379 | public function setNavigations($navigations) |
||
| 383 | |||
| 384 | /** |
||
| 385 | * @param string $name The case-sensitive name of the attribute to return. |
||
| 386 | */ |
||
| 387 | public function addField($name) |
||
| 391 | |||
| 392 | /** |
||
| 393 | * @param string $name Field that should be treated as OR. |
||
| 394 | */ |
||
| 395 | public function addOrField($name) |
||
| 399 | |||
| 400 | /** |
||
| 401 | * @param string[] $fields A list of fields that should be treated as OR. |
||
| 402 | */ |
||
| 403 | public function addOrFields($fields) |
||
| 407 | |||
| 408 | /** |
||
| 409 | * @param string $name The parameter name. |
||
| 410 | * @param string $value The parameter value. |
||
| 411 | */ |
||
| 412 | public function addCustomUrlParamByName($name, $value) |
||
| 413 | { |
||
| 414 | $param = new CustomUrlParam(); |
||
| 415 | $this->addCustomUrlParam($param->setKey($name)->setValue($value)); |
||
| 416 | } |
||
| 417 | |||
| 418 | /** |
||
| 419 | * @param CustomUrlParam $param Set an additional parameter that can be used to trigger rules. |
||
| 420 | */ |
||
| 421 | public function addCustomUrlParam($param) |
||
| 425 | |||
| 426 | public function splitRefinements($refinementString) |
||
| 427 | { |
||
| 428 | if (StringUtils::isNotBlank($refinementString)) { |
||
| 429 | return preg_split(self::TILDE_REGEX, $refinementString, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
||
| 430 | } |
||
| 431 | return []; |
||
| 432 | } |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @param string $refinementString A tilde separated list of refinements. |
||
| 436 | */ |
||
| 437 | public function addRefinementsByString($refinementString) |
||
| 438 | { |
||
| 439 | if ($refinementString == null) { |
||
| 440 | return; |
||
| 441 | } |
||
| 442 | |||
| 443 | $refinementStrings = self::splitRefinements($refinementString); |
||
| 444 | foreach ($refinementStrings as $refinementString) { |
||
| 445 | if (empty($refinementString) || "=" == $refinementString) { |
||
| 446 | continue; |
||
| 447 | } |
||
| 448 | $colon = strpos($refinementString, Symbol::COLON); |
||
| 449 | $equals = strpos($refinementString, Symbol::EQUAL); |
||
| 450 | //when === false, it means it did not find the substring in the string |
||
| 451 | $isRange = !($colon === false) && ($equals === false); |
||
| 452 | |||
| 453 | $refinement = null; |
||
| 454 | if ($isRange) { |
||
| 455 | $nameValue = explode(Symbol::COLON, $refinementString, 2); |
||
| 456 | $refinement = new RefinementRange(); |
||
| 457 | if (StringUtils::endsWith($nameValue[1], Symbol::DOUBLE_DOT)) { |
||
| 458 | $value = explode(Symbol::DOUBLE_DOT, $nameValue[1]); |
||
| 459 | $refinement->setLow($value[0]); |
||
| 460 | $refinement->setHigh(""); |
||
| 461 | } else if (StringUtils::startsWith($nameValue[1], Symbol::DOUBLE_DOT)) { |
||
| 462 | $refinement->setLow(""); |
||
| 463 | $value = explode(Symbol::DOUBLE_DOT, $nameValue[1]); |
||
| 464 | $refinement->setHigh($value[1]); |
||
| 465 | } else { |
||
| 466 | $lowHigh = explode(Symbol::DOUBLE_DOT, $nameValue[1]); |
||
| 467 | $refinement->setLow($lowHigh[0]); |
||
| 468 | $refinement->setHigh($lowHigh[1]); |
||
| 469 | } |
||
| 470 | } else { |
||
| 471 | $nameValue = explode(Symbol::EQUAL, $refinementString, 2); |
||
| 472 | $refinement = new RefinementValue(); |
||
| 473 | $refinement->setValue($nameValue[1]); |
||
| 474 | } |
||
| 475 | if (!empty($nameValue[0])) { |
||
| 476 | $this->addRefinement($nameValue[0], $refinement); |
||
| 477 | } |
||
| 478 | } |
||
| 479 | } |
||
| 480 | |||
| 481 | /** |
||
| 482 | * @param string $navigationName The name of the Navigation. |
||
| 483 | * @param Refinement $refinement A RefinementRange or RefinementValue object. |
||
| 484 | */ |
||
| 485 | public function addRefinement($navigationName, $refinement) |
||
| 486 | { |
||
| 487 | $navigation = null; |
||
| 488 | if (array_key_exists($navigationName, $this->navigations)) { |
||
| 489 | $navigation = $this->navigations[$navigationName]; |
||
| 490 | } else { |
||
| 491 | $navigation = new Navigation(); |
||
| 492 | $navigation->setName($navigationName)->setRange($refinement instanceof SelectedRefinementRange); |
||
| 493 | $this->navigations[$navigationName] = $navigation; |
||
| 494 | } |
||
| 495 | $refinements = $navigation->getRefinements(); |
||
| 496 | array_push($refinements, $refinement); |
||
| 497 | $navigation->setRefinements($refinements); |
||
| 498 | } |
||
| 499 | |||
| 500 | /** |
||
| 501 | * @param string $navigationName The name of the refinement. |
||
| 502 | * @param mixed $low The low value. |
||
| 503 | * @param mixed $high The high value. |
||
| 504 | * @param bool $exclude True if the results should exclude this range refinement, false otherwise. |
||
| 505 | */ |
||
| 506 | public function addRangeRefinement($navigationName, $low, $high, $exclude = false) |
||
| 507 | { |
||
| 508 | $refinement = new RefinementRange(); |
||
| 509 | $this->addRefinement($navigationName, $refinement->setLow($low)->setHigh($high)->setExclude($exclude)); |
||
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @param string $navigationName The name of the refinement. |
||
| 514 | * @param mixed $value The refinement value. |
||
| 515 | * @param bool $exclude True if the results should exclude this value refinement, false otherwise. |
||
| 516 | */ |
||
| 517 | public function addValueRefinement($navigationName, $value, $exclude = false) |
||
| 518 | { |
||
| 519 | $refinement = new RefinementValue();; |
||
| 520 | $this->addRefinement($navigationName, $refinement->setValue($value)->setExclude($exclude)); |
||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @return bool Are refinements with zero counts being removed. |
||
| 525 | */ |
||
| 526 | public function isPruneRefinements() |
||
| 530 | |||
| 531 | /** |
||
| 532 | * @param bool $pruneRefinements Specifies whether refinements should be pruned. |
||
| 533 | */ |
||
| 534 | public function setPruneRefinements($pruneRefinements) |
||
| 538 | |||
| 539 | /** |
||
| 540 | * @return MSort[] The current list of sort parameters. |
||
| 541 | */ |
||
| 542 | public function &getSort() |
||
| 546 | |||
| 547 | /** |
||
| 548 | * @param MSort[] $sort Any number of sort criteria. |
||
| 549 | */ |
||
| 550 | public function setSort($sort) |
||
| 554 | |||
| 555 | /** |
||
| 556 | * @return int The number of documents to skip. |
||
| 557 | */ |
||
| 558 | public function getSkip() |
||
| 562 | |||
| 563 | /** |
||
| 564 | * @param int $skip The number of documents to skip. |
||
| 565 | */ |
||
| 566 | public function setSkip($skip) |
||
| 570 | |||
| 571 | /** |
||
| 572 | * @return CustomUrlParam[] A list of custom url params. |
||
| 573 | */ |
||
| 574 | public function getCustomUrlParams() |
||
| 578 | |||
| 579 | /** |
||
| 580 | * @param CustomUrlParam[] $customUrlParams Set the custom url params. |
||
| 581 | */ |
||
| 582 | public function setCustomUrlParams($customUrlParams) |
||
| 586 | |||
| 587 | // /** |
||
| 588 | // * @return bool Is return JSON set to true. |
||
| 589 | // */ |
||
| 590 | // public function isReturnBinary() |
||
| 591 | // { |
||
| 592 | // return $this->returnBinary; |
||
| 593 | // } |
||
| 594 | // |
||
| 595 | // /** |
||
| 596 | // * @param bool $returnBinary Whether to tell the bridge to return binary data rather than JSON. |
||
| 597 | // */ |
||
| 598 | // public function setReturnBinary($returnBinary) |
||
| 599 | // { |
||
| 600 | // $this->returnBinary = $returnBinary; |
||
| 601 | // } |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @return string The current language restrict value. |
||
| 605 | */ |
||
| 606 | public function getLanguage() |
||
| 610 | |||
| 611 | /** |
||
| 612 | * @param string $language The value for language restrict. |
||
| 613 | */ |
||
| 614 | public function setLanguage($language) |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @return string The current biasing profile name. |
||
| 621 | */ |
||
| 622 | public function getBiasingProfile() |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @param string $biasingProfile Override the biasing profile used for this query. |
||
| 629 | */ |
||
| 630 | public function setBiasingProfile($biasingProfile) |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @return int The current page size. |
||
| 637 | */ |
||
| 638 | public function getPageSize() |
||
| 642 | |||
| 643 | /** |
||
| 644 | * @param int $pageSize The number of records to return with the query. |
||
| 645 | */ |
||
| 646 | public function setPageSize($pageSize) |
||
| 650 | |||
| 651 | /** |
||
| 652 | * @return boolean |
||
| 653 | */ |
||
| 654 | public function isDisableAutocorrection() |
||
| 658 | |||
| 659 | /** |
||
| 660 | * @param boolean $disableAutocorrection Specifies whether the auto-correction behavior should be disabled. |
||
| 661 | * By default, when no results are returned for the given query (and there is |
||
| 662 | * a did-you-mean available), the first did-you-mean is automatically queried |
||
| 663 | * instead. |
||
| 664 | */ |
||
| 665 | public function setDisableAutocorrection($disableAutocorrection) |
||
| 669 | |||
| 670 | /** |
||
| 671 | * @return boolean |
||
| 672 | */ |
||
| 673 | public function isWildcardSearchEnabled() |
||
| 677 | |||
| 678 | /** |
||
| 679 | * @param boolean $wildcardSearchEnabled Indicate if the *(star) character in the search string should be treated |
||
| 680 | * as a wildcard prefix search. For example, `sta*` will match `star` and |
||
| 681 | * `start`. |
||
| 682 | */ |
||
| 683 | public function setWildcardSearchEnabled($wildcardSearchEnabled) |
||
| 687 | |||
| 688 | /** |
||
| 689 | * <b>Warning</b> This will count as two queries against your search index. |
||
| 690 | * |
||
| 691 | * Typically, this feature is used when you have a large number of navigation items that will overwhelm the end |
||
| 692 | * user. It works by using one of the existing navigation items to decide what the query is about and fires a second |
||
| 693 | * query to restrict the navigation to the most relevant set of navigation items for this search term. |
||
| 694 | * |
||
| 695 | * For example, if you pass in a search of `paper` and a restrict navigation of `category:2` |
||
| 696 | * |
||
| 697 | * The bridge will find the category navigation refinements in the first query and fire a second query for the top 2 |
||
| 698 | * most populous categories. Therefore, a search for something generic like "paper" will bring back top category |
||
| 699 | * matches like copy paper (1,030), paper pads (567). The bridge will fire off the second query with the search |
||
| 700 | * term, plus an OR refinement with the most likely categories. The navigation items in the first query are |
||
| 701 | * entirely replaced with the navigation items in the second query, except for the navigation that was used for the |
||
| 702 | * restriction so that users still have the ability to navigate by all category types. |
||
| 703 | * |
||
| 704 | * @param RestrictNavigation $restrictNavigation Restriction criteria |
||
| 705 | */ |
||
| 706 | public function setRestrictNavigation($restrictNavigation) |
||
| 710 | |||
| 711 | /** @return RestrictNavigation */ |
||
| 712 | public function getRestrictNavigation() |
||
| 716 | |||
| 717 | /** |
||
| 718 | * @return MBiasing |
||
| 719 | */ |
||
| 720 | public function getBiasing() |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Add a biasing profile, which is defined at query time. |
||
| 727 | * |
||
| 728 | * @param MBiasing $biasing |
||
| 729 | */ |
||
| 730 | public function setBiasing($biasing) |
||
| 734 | |||
| 735 | /** |
||
| 736 | * @param string[] $bringToTop |
||
| 737 | */ |
||
| 738 | public function setBringToTop($bringToTop) { |
||
| 739 | if (empty($this->biasing)) { |
||
| 740 | $this->biasing = new MBiasing(); |
||
| 741 | } |
||
| 742 | $this->biasing->bringToTop = $bringToTop; |
||
| 743 | } |
||
| 744 | |||
| 745 | /** |
||
| 746 | * @return string A string representation of all of the currently set refinements. |
||
| 747 | */ |
||
| 748 | View Code Duplication | public function getRefinementString() |
|
| 763 | |||
| 764 | /** |
||
| 765 | * @return string A string representation of all of the currently set custom url parameters. |
||
| 766 | */ |
||
| 767 | View Code Duplication | public function getCustomUrlParamsString() |
|
| 780 | |||
| 781 | /** |
||
| 782 | * @param MSort $sort |
||
| 783 | * |
||
| 784 | * @return RSort |
||
| 785 | */ |
||
| 786 | protected static function convertSort($sort) |
||
| 804 | |||
| 805 | /** |
||
| 806 | * @param MMatchStrategy $strategy |
||
| 807 | * |
||
| 808 | * @return RMatchStrategy |
||
| 809 | */ |
||
| 810 | protected static function convertPartialMatchStrategy($strategy) |
||
| 827 | |||
| 828 | /** |
||
| 829 | * @param MPartialMatchRule $rule |
||
| 830 | * |
||
| 831 | * @return RPartialMatchRule |
||
| 832 | */ |
||
| 833 | protected static function convertPartialMatchRule($rule) |
||
| 846 | |||
| 847 | /** |
||
| 848 | * @param MBiasing $biasing |
||
| 849 | * |
||
| 850 | * @return Biasing |
||
| 851 | */ |
||
| 852 | protected static function convertBiasing($biasing) |
||
| 862 | |||
| 863 | } |
||
| 864 |