[TASK] Refactor IndexedSearch hook examples 11/40611/3
authorFrederic Gaus <frederic.gaus@flagbit.de>
Thu, 25 Jun 2015 09:36:05 +0000 (11:36 +0200)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Thu, 25 Jun 2015 11:20:01 +0000 (13:20 +0200)
* Remove long class names
* Define undefined variables
* Correct and add phpDocs

Releases: master
Resolves: #67746
Change-Id: Ide42c2cd6c3ca0bcb5a74a2c6a33cb4dcef6579a
Reviewed-on: http://review.typo3.org/40611
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/indexed_search/Classes/Example/CrawlerHook.php
typo3/sysext/indexed_search/Classes/Example/PluginHook.php

index 389aa87..87bcd04 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\IndexedSearch\Example;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\IndexedSearch\Indexer;
+
 /**
  * Index search crawler hook example
  *
@@ -38,10 +41,13 @@ class CrawlerHook {
         * @param array $cfgRec Indexing Configuration Record (the record which holds the information that lead to this indexing session...)
         * @param array $session_data Session data variable. Passed by reference. Changed content is saved and passed back upon next instance in the session.
         * @param array $params Params array from the queue entry.
-        * @param object $pObj Parent Object (from "indexed_search" extension)
+        * @param \TYPO3\CMS\IndexedSearch\Hook\CrawlerHook $pObj Parent Object (from "indexed_search" extension)
         * @return void
         */
        public function indexOperation($cfgRec, &$session_data, $params, &$pObj) {
+               // Set up language uid, if any:
+               $sys_language_uid = 0;
+
                // Init session data array if not already:
                if (!is_array($session_data)) {
                        $session_data = array(
@@ -55,8 +61,6 @@ class CrawlerHook {
                                // Indexing Example: Content accessed with GET parameters added to URL:
                                // Get rootline from the Indexing Record (needed because the indexer relates all search results to a position in the page tree!) [DON'T CHANGE]:
                                $rl = $pObj->getUidRootLineForClosestTemplate($cfgRec['pid']);
-                               // Set up language uid, if any:
-                               $sys_language_uid = 0;
                                // Set up 2 example items to index:
                                $exampleItems = array(
                                        array(
@@ -75,7 +79,8 @@ class CrawlerHook {
                                        // Prepare the GET variables array that must be added to the page URL in order to view result:
                                        parse_str('&itemID=' . rawurlencode($item['ID']), $GETparams);
                                        // Prepare indexer (make instance, initialize it, set special features for indexing parameterized content - probably none of this should be changed by you) [DON'T CHANGE]:
-                                       $indexerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class);
+                                       /** @var Indexer $indexerObj */
+                                       $indexerObj = GeneralUtility::makeInstance(Indexer::class);
                                        $indexerObj->backend_initIndexer($cfgRec['pid'], 0, $sys_language_uid, '', $rl, $GETparams, FALSE);
                                        $indexerObj->backend_setFreeIndexUid($cfgRec['uid'], $cfgRec['set_id']);
                                        $indexerObj->forceIndexing = TRUE;
@@ -87,10 +92,9 @@ class CrawlerHook {
                                // Indexing Example: Content accessed directly in file system:
                                // Get rootline from the Indexing Record (needed because the indexer relates all search results to a position in the page tree!) [DON'T CHANGE]:
                                $rl = $pObj->getUidRootLineForClosestTemplate($cfgRec['pid']);
-                               // Set up language uid, if any:
-                               $sys_language_uid = 0;
                                // Prepare indexer (make instance, initialize it, set special features for indexing parameterized content - probably none of this should be changed by you) [DON'T CHANGE]:
-                               $indexerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class);
+                               /** @var Indexer $indexerObj */
+                               $indexerObj = GeneralUtility::makeInstance(Indexer::class);
                                $indexerObj->backend_initIndexer($cfgRec['pid'], 0, $sys_language_uid, '', $rl);
                                $indexerObj->backend_setFreeIndexUid($cfgRec['uid'], $cfgRec['set_id']);
                                $indexerObj->hash['phash'] = -1;
@@ -101,8 +105,9 @@ class CrawlerHook {
                        case 3:
                                // Indexing Example: Content accessed on External URLs:
                                // Index external URL:
-                               $indexerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class);
-                               $indexerObj->backend_initIndexer($cfgRec['pid'], 0, $sys_language_uid, '', $rl);
+                               /** @var Indexer $indexerObj */
+                               $indexerObj = GeneralUtility::makeInstance(Indexer::class);
+                               $indexerObj->backend_initIndexer($cfgRec['pid'], 0, $sys_language_uid, '', NULL);
                                $indexerObj->backend_setFreeIndexUid($cfgRec['uid'], $cfgRec['set_id']);
                                $indexerObj->hash['phash'] = -1;
                                // To avoid phash_t3 being written to file sections (otherwise they are removed when page is reindexed!!!)
index f74fd0b..f0a763f 100644 (file)
@@ -61,9 +61,9 @@ class PluginHook {
         * Example of how the content displayed in the result rows can be post processed before rendered into HTML.
         * This example simply shows how the description field is wrapped in italics and the path is hidden by setting it blank.
         *
-        * @param array Template Content (generated from result row) being processed.
-        * @param array Result row
-        * @param bool If set, the result row is a sub-row.
+        * @param array $tmplContent Template Content (generated from result row) being processed.
+        * @param array $row Result row
+        * @param bool $headerOnly If set, the result row is a sub-row.
         * @return array Template Content returned.
         */
        public function prepareResultRowTemplateData_postProc($tmplContent, $row, $headerOnly) {