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

CrawlerWorker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 35
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A index() 0 16 1
1
<?php
2
namespace AOEPeople\Crawler\Worker;
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
use AOE\Crawler\Controller\CrawlerController;
18
use AOEPeople\Crawler\Hooks\IndexedSearchCrawlerFilesHook;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
21
use TYPO3\CMS\IndexedSearch\Worker\WorkerInterface;
22
23
class CrawlerWorker implements WorkerInterface
24
{
25
26
    /**
27
     * CrawlerWorker constructor.
28
     */
29
    public function __construct()
30
    {
31
    }
32
33
    /**
34
     * @param object $caller Method caller
35
     * @param array $conf Indexed search configuration
36
     * @param string $file Relative Filename, relative to public web path. It can also be an absolute path as long as it is inside the lockRootPath (validated with \TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath()). Finally, if $contentTmpFile is set, this value can be anything, most likely a URL
37
     * @param string $contentTmpFile Temporary file with the content to read it from (instead of $file). Used when the $file is a URL.
38
     * @param string $fileExtension File extension for temporary file.
39
     * @return mixed
40
     */
41
    public function index(object $caller, array $conf, string $file, string $contentTmpFile = '', $fileExtension = '')
42
    {
43
        $crawler = GeneralUtility::makeInstance(CrawlerController::class);
44
45
        $params = [
46
            'document' => $contentTmpFile,
47
            'alturl' =>$file,
48
            'conf' => $conf
49
        ];
50
51
        unset($params['conf']['content']);
52
53
        $crawler->addQueueEntry_callBack(0, $params, IndexedSearchCrawlerFilesHook::class, $conf['id']);
54
55
        GeneralUtility::makeInstance(TimeTracker::class)->setTSlogMessage('media "' . $params['document'] . '" added to "crawler" queue.', 1);
56
    }
57
}