Advertisement
zeeos

TYPO3 Solr task that automatically determines correct domain

Apr 4th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. namespace ***\***\Scheduler;
  3.  
  4. use TYPO3\CMS\Backend\Utility\BackendUtility;
  5. use TYPO3\CMS\Core\Utility\GeneralUtility;
  6.  
  7. /**
  8.  * This class provides an enhanced task for Solr that uses proper domains.
  9.  *
  10.  * @author Dmitry Dulepov <***@***.***>
  11.  */
  12. class IndexTask extends \Tx_Solr_Scheduler_IndexQueueWorkerTask {
  13.  
  14.     /**
  15.      * Executes the task.
  16.      *
  17.      * @return bool
  18.      */
  19.     public function execute() {
  20.         $rootPageId = $this->site->getRootPageId();
  21.  
  22.         $domainRecords = BackendUtility::getRecordsByField('sys_domain', 'pid', $rootPageId, ' AND redirectTo=\'\' AND hidden=0', '', 'sorting');
  23.         if (is_array($domainRecords)) {
  24.             $domainRecord = reset($domainRecords);
  25.             $_SERVER['HTTP_HOST'] = rtrim($domainRecord['domainName'], '/');
  26.  
  27.             /* ... some code here, specific to our package structure that you do not need */
  28.         }
  29.  
  30.         return parent::execute();
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement