Completed
Push — typo3v9 ( c8617d...d49016 )
by Tomas Norre
05:58
created

IndexedSearchCrawlerFilesHook   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 30
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A crawler_execute() 0 20 3
1
<?php
2
namespace AOEPeople\Crawler\Hooks;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
/**
18
 * Crawler hook for indexed search. Works with the "crawler" extension
19
 * This hook is specifically used to index external files found on pages through the crawler extension.
20
 * @see \TYPO3\CMS\IndexedSearch\Indexer::extractLinks()
21
 * @internal this is a TYPO3-internal hook implementation and not part of TYPO3's Core API.
22
 */
23
class IndexedSearchCrawlerFilesHook
24
{
25
    /**
26
     * Call back function for execution of a log element
27
     *
28
     * @param array $params Params from log element.
29
     * @param object $pObj Parent object (tx_crawler lib)
30
     * @return array|null Result array
31
     */
32
    public function crawler_execute($params, &$pObj)
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
        if (!is_array($params['conf'])) {
35
            return;
36
        }
37
        // Initialize the indexer class:
38
        $indexerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class);
39
        $indexerObj->conf = $params['conf'];
40
        $indexerObj->init();
41
        // Index document:
42
        if ($params['alturl']) {
43
            $fI = pathinfo($params['document']);
44
            $ext = strtolower($fI['extension']);
45
            $indexerObj->indexRegularDocument($params['alturl'], true, $params['document'], $ext);
46
        } else {
47
            $indexerObj->indexRegularDocument($params['document'], true);
48
        }
49
        // Return OK:
50
        return ['content' => []];
51
    }
52
}
53