Complex classes like PluginBase 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 PluginBase, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 47 | abstract class PluginBase extends AbstractPlugin |
||
| 48 | { |
||
| 49 | /** |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | public $prefixId = 'tx_solr'; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var string |
||
| 56 | */ |
||
| 57 | public $extKey = 'solr'; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * An instance of ApacheSolrForTypo3\Solr\Template |
||
| 61 | * |
||
| 62 | * @var Template |
||
| 63 | */ |
||
| 64 | protected $template; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * An instance of ApacheSolrForTypo3\Solr\JavascriptManager |
||
| 68 | * |
||
| 69 | * @var JavascriptManager |
||
| 70 | */ |
||
| 71 | protected $javascriptManager; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * An instance of the localization factory |
||
| 75 | * |
||
| 76 | * @var \TYPO3\CMS\Core\Localization\LocalizationFactory |
||
| 77 | */ |
||
| 78 | protected $languageFactory; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * The user's raw query. |
||
| 82 | * |
||
| 83 | * Private to enforce API usage. |
||
| 84 | * |
||
| 85 | * @var string |
||
| 86 | */ |
||
| 87 | private $rawUserQuery; |
||
| 88 | |||
| 89 | // Main |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @var TypoScriptConfiguration |
||
| 93 | */ |
||
| 94 | public $typoScriptConfiguration; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var SearchResultSetService |
||
| 98 | */ |
||
| 99 | private $searchResultsSetService; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * The main method of the plugin |
||
| 103 | * |
||
| 104 | * @param string $content The plugin content |
||
| 105 | * @param array $configuration The plugin configuration |
||
| 106 | * @return string The content that is displayed on the website |
||
| 107 | */ |
||
| 108 | 25 | public function main($content, $configuration) |
|
|
|
|||
| 109 | { |
||
| 110 | /** @noinspection PhpUnusedLocalVariableInspection */ |
||
| 111 | 25 | $content = ''; |
|
| 112 | |||
| 113 | try { |
||
| 114 | 25 | $this->initialize($configuration); |
|
| 115 | 25 | $this->preRender(); |
|
| 116 | |||
| 117 | 25 | $actionResult = $this->performAction(); |
|
| 118 | |||
| 119 | 25 | if ($this->getSearchResultSetService()->getIsSolrAvailable()) { |
|
| 120 | 25 | $content = $this->render($actionResult); |
|
| 121 | } else { |
||
| 122 | $content = $this->renderError(); |
||
| 123 | } |
||
| 124 | |||
| 125 | 25 | $content = $this->postRender($content); |
|
| 126 | } catch (\Exception $e) { |
||
| 127 | if ($this->typoScriptConfiguration->getLoggingExceptions()) { |
||
| 128 | GeneralUtility::devLog( |
||
| 129 | $e->getCode() . ': ' . $e->__toString(), |
||
| 130 | 'solr', |
||
| 131 | 3, |
||
| 132 | (array)$e |
||
| 133 | ); |
||
| 134 | } |
||
| 135 | |||
| 136 | $this->initializeTemplateEngine(); |
||
| 137 | $content = $this->renderException(); |
||
| 138 | } |
||
| 139 | |||
| 140 | 25 | return $this->baseWrap($content); |
|
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Adds the possibility to use stdWrap on the plugins content instead of wrapInBaseClass. |
||
| 145 | * Defaults to wrapInBaseClass to ensure downward compatibility. |
||
| 146 | * |
||
| 147 | * @param string $content The plugin content |
||
| 148 | * @return string |
||
| 149 | */ |
||
| 150 | 25 | protected function baseWrap($content) |
|
| 151 | { |
||
| 152 | 25 | $baseWrap = $this->typoScriptConfiguration->getObjectByPath('plugin.tx_solr.general.baseWrap.'); |
|
| 153 | 25 | if (isset($baseWrap)) { |
|
| 154 | 25 | return $this->cObj->stdWrap($content, |
|
| 155 | $baseWrap); |
||
| 156 | } else { |
||
| 157 | return $this->pi_wrapInBaseClass($content); |
||
| 158 | } |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Implements the action logic. The result of this method is passed to the |
||
| 163 | * render method. |
||
| 164 | * |
||
| 165 | * @return string Action result |
||
| 166 | */ |
||
| 167 | abstract protected function performAction(); |
||
| 168 | |||
| 169 | // Initialization |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Initializes the plugin - configuration, language, caching, search... |
||
| 173 | * |
||
| 174 | * @param array $configuration configuration array as provided by the TYPO3 core |
||
| 175 | */ |
||
| 176 | 25 | protected function initialize($configuration) |
|
| 177 | { |
||
| 178 | /** @var $configurationManager \ApacheSolrForTypo3\Solr\System\Configuration\ConfigurationManager */ |
||
| 179 | 25 | $configurationManager = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\System\\Configuration\\ConfigurationManager'); |
|
| 180 | 25 | $typoScriptConfiguration = $configurationManager->getTypoScriptConfiguration()->mergeSolrConfiguration($configuration); |
|
| 181 | 25 | $this->typoScriptConfiguration = $typoScriptConfiguration; |
|
| 182 | |||
| 183 | 25 | $this->initializeLanguageFactory(); |
|
| 184 | 25 | $this->pi_setPiVarDefaults(); |
|
| 185 | 25 | $this->pi_loadLL(); |
|
| 186 | 25 | $this->pi_initPIflexForm(); |
|
| 187 | |||
| 188 | 25 | $this->overrideTyposcriptWithFlexformSettings(); |
|
| 189 | |||
| 190 | 25 | $this->initializeQuery(); |
|
| 191 | 25 | $this->initializeSearch(); |
|
| 192 | 25 | $this->initializeTemplateEngine(); |
|
| 193 | 25 | $this->initializeJavascriptManager(); |
|
| 194 | |||
| 195 | 25 | $this->postInitialize(); |
|
| 196 | 25 | } |
|
| 197 | |||
| 198 | /** |
||
| 199 | * Overwrites pi_setPiVarDefaults to add stdWrap-functionality to _DEFAULT_PI_VARS |
||
| 200 | * |
||
| 201 | * @author Grigori Prokhorov <[email protected]> |
||
| 202 | * @author Ivan Kartolo <[email protected]> |
||
| 203 | * @return void |
||
| 204 | */ |
||
| 205 | 25 | public function pi_setPiVarDefaults() |
|
| 206 | { |
||
| 207 | 25 | if (is_array($this->conf['_DEFAULT_PI_VARS.'])) { |
|
| 208 | foreach ($this->conf['_DEFAULT_PI_VARS.'] as $key => $defaultValue) { |
||
| 209 | $this->conf['_DEFAULT_PI_VARS.'][$key] = $this->cObj->cObjGetSingle($this->conf['_DEFAULT_PI_VARS.'][$key], |
||
| 210 | $this->conf['_DEFAULT_PI_VARS.'][$key . '.']); |
||
| 211 | } |
||
| 212 | |||
| 213 | $piVars = is_array($this->piVars) ? $this->piVars : array(); |
||
| 214 | $this->piVars = $this->conf['_DEFAULT_PI_VARS.']; |
||
| 215 | ArrayUtility::mergeRecursiveWithOverrule( |
||
| 216 | $this->piVars, |
||
| 217 | $piVars |
||
| 218 | ); |
||
| 219 | } |
||
| 220 | 25 | } |
|
| 221 | |||
| 222 | /** |
||
| 223 | * Overwrites pi_loadLL() to handle custom location of language files. |
||
| 224 | * |
||
| 225 | * Loads local-language values by looking for a "locallang" file in the |
||
| 226 | * plugin class directory ($this->scriptRelPath) and if found includes it. |
||
| 227 | * Also locallang values set in the TypoScript property "_LOCAL_LANG" are |
||
| 228 | * merged onto the values found in the "locallang" file. |
||
| 229 | * Supported file extensions xlf, xml, php |
||
| 230 | * |
||
| 231 | * @param string $languageFilePath path to the plugin language file in format EXT:.... |
||
| 232 | * @return void |
||
| 233 | */ |
||
| 234 | 25 | public function pi_loadLL($languageFilePath = '') |
|
| 235 | { |
||
| 236 | 25 | if (!$this->LOCAL_LANG_loaded && $this->scriptRelPath) { |
|
| 237 | 25 | $basePath = 'EXT:' . $this->extKey . '/Resources/Private/Language/locallang.xlf'; |
|
| 238 | // Read the strings in the required charset (since TYPO3 4.2) |
||
| 239 | 25 | $this->LOCAL_LANG = $this->languageFactory->getParsedData($basePath, |
|
| 240 | 25 | $this->LLkey, $GLOBALS['TSFE']->renderCharset, 3); |
|
| 241 | |||
| 242 | 25 | $alternativeLanguageKeys = GeneralUtility::trimExplode(',', |
|
| 243 | 25 | $this->altLLkey, true); |
|
| 244 | 25 | foreach ($alternativeLanguageKeys as $languageKey) { |
|
| 245 | $tempLL = $this->languageFactory->getParsedData($basePath, $languageKey, $GLOBALS['TSFE']->renderCharset, 3); |
||
| 246 | if ($this->LLkey !== 'default' && isset($tempLL[$languageKey])) { |
||
| 247 | $this->LOCAL_LANG[$languageKey] = $tempLL[$languageKey]; |
||
| 248 | } |
||
| 249 | } |
||
| 250 | // Overlaying labels from TypoScript (including fictitious language keys for non-system languages!): |
||
| 251 | 25 | $translationInTypoScript = $this->typoScriptConfiguration->getLocalLangConfiguration(); |
|
| 252 | |||
| 253 | 25 | if (count($translationInTypoScript) == 0) { |
|
| 254 | 24 | return; |
|
| 255 | } |
||
| 256 | |||
| 257 | // Clear the "unset memory" |
||
| 258 | 1 | $this->LOCAL_LANG_UNSET = array(); |
|
| 259 | 1 | foreach ($translationInTypoScript as $languageKey => $languageArray) { |
|
| 260 | // Remove the dot after the language key |
||
| 261 | 1 | $languageKey = substr($languageKey, 0, -1); |
|
| 262 | // Don't process label if the language is not loaded |
||
| 263 | 1 | if (is_array($languageArray) && isset($this->LOCAL_LANG[$languageKey])) { |
|
| 264 | 1 | foreach ($languageArray as $labelKey => $labelValue) { |
|
| 265 | 1 | if (!is_array($labelValue)) { |
|
| 266 | 1 | $this->LOCAL_LANG[$languageKey][$labelKey][0]['target'] = $labelValue; |
|
| 267 | 1 | $this->LOCAL_LANG_charset[$languageKey][$labelKey] = 'utf-8'; |
|
| 268 | |||
| 269 | 1 | if ($labelValue === '') { |
|
| 270 | 1 | $this->LOCAL_LANG_UNSET[$languageKey][$labelKey] = ''; |
|
| 271 | } |
||
| 272 | } |
||
| 273 | } |
||
| 274 | } |
||
| 275 | } |
||
| 276 | } |
||
| 277 | 1 | $this->LOCAL_LANG_loaded = 1; |
|
| 278 | 1 | } |
|
| 279 | |||
| 280 | /** |
||
| 281 | * Allows to override TypoScript settings with Flexform values. |
||
| 282 | * |
||
| 283 | */ |
||
| 284 | 3 | protected function overrideTyposcriptWithFlexformSettings() |
|
| 285 | { |
||
| 286 | 3 | } |
|
| 287 | |||
| 288 | /** |
||
| 289 | * Initializes the query from the GET query parameter. |
||
| 290 | * |
||
| 291 | */ |
||
| 292 | 25 | protected function initializeQuery() |
|
| 293 | { |
||
| 294 | 25 | $this->rawUserQuery = GeneralUtility::_GET('q'); |
|
| 295 | 25 | } |
|
| 296 | |||
| 297 | /** |
||
| 298 | * Initializes the Solr connection and tests the connection through a ping. |
||
| 299 | * |
||
| 300 | */ |
||
| 301 | 25 | protected function initializeSearch() |
|
| 302 | { |
||
| 303 | 25 | $solrConnection = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\ConnectionManager')->getConnectionByPageId( |
|
| 304 | 25 | $GLOBALS['TSFE']->id, |
|
| 305 | 25 | $GLOBALS['TSFE']->sys_language_uid, |
|
| 306 | 25 | $GLOBALS['TSFE']->MP |
|
| 307 | ); |
||
| 308 | |||
| 309 | 25 | $search = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Search', $solrConnection); |
|
| 310 | /** @var $this->searchService ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSetService */ |
||
| 311 | 25 | $this->searchResultsSetService = GeneralUtility::makeInstance('ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSetService', $this->typoScriptConfiguration, $search, $this); |
|
| 312 | 25 | $this->solrAvailable = $this->searchResultsSetService->getIsSolrAvailable(); |
|
| 313 | 25 | $this->search = $this->searchResultsSetService->getSearch(); |
|
| 314 | 25 | } |
|
| 315 | |||
| 316 | /** |
||
| 317 | * @return SearchResultSetService |
||
| 318 | */ |
||
| 319 | 25 | public function getSearchResultSetService() |
|
| 320 | { |
||
| 321 | 25 | return $this->searchResultsSetService; |
|
| 322 | } |
||
| 323 | |||
| 324 | /** |
||
| 325 | * Initializes the template engine and returns the initialized instance. |
||
| 326 | * |
||
| 327 | * @throws \UnexpectedValueException if a view helper provider fails to implement interface ApacheSolrForTypo3\Solr\ViewHelper\ViewHelperProvider |
||
| 328 | */ |
||
| 329 | 25 | protected function initializeTemplateEngine() |
|
| 330 | { |
||
| 331 | 25 | $templateFile = $this->getTemplateFile(); |
|
| 332 | 25 | $subPart = $this->getSubpart(); |
|
| 333 | |||
| 334 | 25 | $flexformTemplateFile = $this->pi_getFFvalue( |
|
| 335 | 25 | $this->cObj->data['pi_flexform'], |
|
| 336 | 25 | 'templateFile', |
|
| 337 | 25 | 'sOptions' |
|
| 338 | ); |
||
| 339 | 25 | if (!empty($flexformTemplateFile)) { |
|
| 340 | $templateFile = $flexformTemplateFile; |
||
| 341 | } |
||
| 342 | |||
| 343 | /** @var Template $template */ |
||
| 344 | 25 | $template = GeneralUtility::makeInstance( |
|
| 345 | 25 | 'ApacheSolrForTypo3\\Solr\\Template', |
|
| 346 | 25 | $this->cObj, |
|
| 347 | $templateFile, |
||
| 348 | $subPart |
||
| 349 | ); |
||
| 350 | 25 | $template->addViewHelperIncludePath($this->extKey, |
|
| 351 | 25 | 'Classes/ViewHelper/'); |
|
| 352 | 25 | $template->addViewHelper('LLL', array( |
|
| 353 | 25 | 'languageFile' => 'EXT:solr/Resources/Private/Language/locallang.xlf', |
|
| 354 | 25 | 'llKey' => $this->LLkey |
|
| 355 | )); |
||
| 356 | |||
| 357 | // can be used for view helpers that need configuration during initialization |
||
| 358 | 25 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$this->getPluginKey()]['addViewHelpers'])) { |
|
| 359 | foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$this->getPluginKey()]['addViewHelpers'] as $classReference) { |
||
| 360 | $viewHelperProvider = &GeneralUtility::getUserObj($classReference); |
||
| 361 | |||
| 362 | if ($viewHelperProvider instanceof ViewHelperProvider) { |
||
| 363 | $viewHelpers = $viewHelperProvider->getViewHelpers(); |
||
| 364 | foreach ($viewHelpers as $helperName => $helperObject) { |
||
| 365 | // TODO check whether $helperAdded is TRUE, throw an exception if not |
||
| 366 | $helperAdded = $template->addViewHelperObject($helperName, |
||
| 367 | $helperObject); |
||
| 368 | } |
||
| 369 | } else { |
||
| 370 | throw new \UnexpectedValueException( |
||
| 371 | get_class($viewHelperProvider) . ' must implement interface ApacheSolrForTypo3\Solr\ViewHelper\ViewHelperProvider', |
||
| 372 | 1310387296 |
||
| 373 | ); |
||
| 374 | } |
||
| 375 | } |
||
| 376 | } |
||
| 377 | |||
| 378 | 25 | $template = $this->postInitializeTemplateEngine($template); |
|
| 379 | |||
| 380 | 25 | $this->template = $template; |
|
| 381 | 25 | } |
|
| 382 | |||
| 383 | /** |
||
| 384 | * Initializes the javascript manager. |
||
| 385 | * |
||
| 386 | */ |
||
| 387 | 25 | protected function initializeJavascriptManager() |
|
| 388 | { |
||
| 389 | 25 | $this->javascriptManager = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\JavascriptManager'); |
|
| 390 | 25 | } |
|
| 391 | |||
| 392 | /** |
||
| 393 | * Initializes the language factory; |
||
| 394 | */ |
||
| 395 | 25 | protected function initializeLanguageFactory() |
|
| 399 | |||
| 400 | /** |
||
| 401 | * This method is called after initializing in the initialize method. |
||
| 402 | * Overwrite this method to do your own initialization. |
||
| 403 | * |
||
| 404 | * @return void |
||
| 405 | */ |
||
| 406 | 3 | protected function postInitialize() |
|
| 407 | { |
||
| 408 | 3 | } |
|
| 409 | |||
| 410 | /** |
||
| 411 | * Overwrite this method to do own initialisations of the template. |
||
| 412 | * |
||
| 413 | * @param Template $template Template |
||
| 414 | * @return Template |
||
| 415 | */ |
||
| 416 | protected function postInitializeTemplateEngine(Template $template) |
||
| 417 | { |
||
| 418 | return $template; |
||
| 419 | } |
||
| 420 | |||
| 421 | // Rendering |
||
| 422 | |||
| 423 | /** |
||
| 424 | * This method executes the requested commands and applies the changes to |
||
| 425 | * the template. |
||
| 426 | * |
||
| 427 | * @param $actionResult |
||
| 428 | * @return string Rendered plugin content |
||
| 429 | */ |
||
| 430 | abstract protected function render($actionResult); |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Renders a solr error. |
||
| 434 | * |
||
| 435 | * @return string A representation of the error that should be understandable for the user. |
||
| 436 | */ |
||
| 437 | protected function renderError() |
||
| 438 | { |
||
| 439 | $this->template->workOnSubpart('solr_search_unavailable'); |
||
| 440 | |||
| 441 | return $this->template->render(); |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Renders a solr exception. |
||
| 446 | * |
||
| 447 | * @return string A representation of the exception that should be understandable for the user. |
||
| 448 | */ |
||
| 449 | protected function renderException() |
||
| 450 | { |
||
| 451 | $this->template->workOnSubpart('solr_search_error'); |
||
| 452 | |||
| 453 | return $this->template->render(); |
||
| 454 | } |
||
| 455 | |||
| 456 | /** |
||
| 457 | * Should be overwritten to do things before rendering. |
||
| 458 | * |
||
| 459 | */ |
||
| 460 | 2 | protected function preRender() |
|
| 461 | { |
||
| 462 | 2 | } |
|
| 463 | |||
| 464 | /** |
||
| 465 | * Overwrite this method to perform changes to the content after rendering. |
||
| 466 | * |
||
| 467 | * @param string $content The content rendered by the plugin so far |
||
| 468 | * @return string The content that should be presented on the website, might be different from the output rendered before |
||
| 469 | */ |
||
| 470 | 25 | protected function postRender($content) |
|
| 471 | { |
||
| 472 | 25 | if (isset($this->conf['stdWrap.'])) { |
|
| 473 | $content = $this->cObj->stdWrap($content, $this->conf['stdWrap.']); |
||
| 474 | } |
||
| 475 | |||
| 476 | 25 | return $content; |
|
| 477 | } |
||
| 478 | |||
| 479 | // Helper methods |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Determines the template file from the configuration. |
||
| 483 | * |
||
| 484 | * Overwrite this method to use a different template. |
||
| 485 | * |
||
| 486 | * @return string The template file name to be used for the plugin |
||
| 487 | */ |
||
| 488 | 25 | protected function getTemplateFile() |
|
| 489 | { |
||
| 490 | 25 | return $this->typoScriptConfiguration->getTemplateByFileKey($this->getTemplateFileKey()); |
|
| 491 | } |
||
| 492 | |||
| 493 | /** |
||
| 494 | * This method should be implemented to return the TSconfig key which |
||
| 495 | * contains the template name for this template. |
||
| 496 | * |
||
| 497 | * @see initializeTemplateEngine() |
||
| 498 | * @return string The TSconfig key containing the template name |
||
| 499 | */ |
||
| 500 | abstract protected function getTemplateFileKey(); |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Gets the plugin's template instance. |
||
| 504 | * |
||
| 505 | * @return Template The plugin's template. |
||
| 506 | */ |
||
| 507 | 25 | public function getTemplate() |
|
| 508 | { |
||
| 509 | 25 | return $this->template; |
|
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Gets the plugin's javascript manager. |
||
| 514 | * |
||
| 515 | * @return JavascriptManager The plugin's javascript manager. |
||
| 516 | */ |
||
| 517 | 25 | public function getJavascriptManager() |
|
| 518 | { |
||
| 519 | 25 | return $this->javascriptManager; |
|
| 520 | } |
||
| 521 | |||
| 522 | /** |
||
| 523 | * Should return the relevant subpart of the template. |
||
| 524 | * |
||
| 525 | * @see initializeTemplateEngine() |
||
| 526 | * @return string The subpart of the template to be used |
||
| 527 | */ |
||
| 528 | abstract protected function getSubpart(); |
||
| 529 | |||
| 530 | /** |
||
| 531 | * This method should return the plugin key. Reads some configuration |
||
| 532 | * options in initializeTemplateEngine() |
||
| 533 | * |
||
| 534 | * @see initializeTemplateEngine() |
||
| 535 | * @return string The plugin key |
||
| 536 | */ |
||
| 537 | abstract protected function getPluginKey(); |
||
| 538 | |||
| 539 | /** |
||
| 540 | * Gets the target page Id for links. Might have been set through either |
||
| 541 | * flexform or TypoScript. If none is set, TSFE->id is used. |
||
| 542 | * |
||
| 543 | * @return int The page Id to be used for links |
||
| 544 | */ |
||
| 545 | 18 | public function getLinkTargetPageId() |
|
| 546 | { |
||
| 547 | 18 | return $this->typoScriptConfiguration->getSearchTargetPage(); |
|
| 548 | } |
||
| 549 | |||
| 550 | /** |
||
| 551 | * Gets the user's query term and cleans it so that it can be used in |
||
| 552 | * templates f.e. |
||
| 553 | * |
||
| 554 | * @return string The cleaned user query. |
||
| 555 | */ |
||
| 556 | 25 | public function getCleanUserQuery() |
|
| 557 | { |
||
| 558 | 25 | $userQuery = $this->getRawUserQuery(); |
|
| 559 | |||
| 560 | 25 | if (!is_null($userQuery)) { |
|
| 561 | 21 | $userQuery = Query::cleanKeywords($userQuery); |
|
| 562 | } |
||
| 563 | |||
| 564 | // escape triple hashes as they are used in the template engine |
||
| 565 | // TODO remove after switching to fluid templates |
||
| 566 | 25 | $userQuery = Template::escapeMarkers($userQuery); |
|
| 567 | |||
| 568 | 25 | return $userQuery; |
|
| 569 | } |
||
| 570 | |||
| 571 | /** |
||
| 572 | * Gets the raw user query |
||
| 573 | * |
||
| 574 | * @return string Raw user query. |
||
| 575 | */ |
||
| 576 | 25 | public function getRawUserQuery() |
|
| 580 | |||
| 581 | /** |
||
| 582 | * @return string |
||
| 583 | */ |
||
| 584 | 25 | protected function getCurrentUrlWithQueryLinkBuilder() |
|
| 600 | } |
||
| 601 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.