Passed
Push — typo3v9 ( 2404ee...b9b5fa )
by Tomas Norre
05:51
created

CrawlerWorker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 32
ccs 0
cts 14
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 15 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AOE\Crawler\Worker;
6
7
/*
8
 * (c) 2020 AOE GmbH <[email protected]>
9
 *
10
 * This file is part of the TYPO3 Crawler Extension.
11
 *
12
 * It is free software; you can redistribute it and/or modify it under
13
 * the terms of the GNU General Public License, either version 2
14
 * of the License, or any later version.
15
 *
16
 * For the full copyright and license information, please read the
17
 * LICENSE.txt file that was distributed with this source code.
18
 *
19
 * The TYPO3 project - inspiring people to share!
20
 */
21
22
use AOE\Crawler\Controller\CrawlerController;
23
use AOE\Crawler\Hooks\IndexedSearchCrawlerFilesHook;
24
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
25
use TYPO3\CMS\Core\Utility\GeneralUtility;
26
use TYPO3\CMS\IndexedSearch\Worker\WorkerInterface;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\IndexedSearch\Worker\WorkerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
28
class CrawlerWorker implements WorkerInterface
29
{
30
    /**
31
     * CrawlerWorker constructor.
32
     */
33
    public function __construct()
34
    {
35
    }
36
37
    /**
38
     * @param object $caller Method caller
39
     * @param array $conf Indexed search configuration
40
     * @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
41
     * @param string $contentTmpFile Temporary file with the content to read it from (instead of $file). Used when the $file is a URL.
42
     * @param string $fileExtension File extension for temporary file.
43
     * @return mixed
44
     */
45
    public function index(object $caller, array $conf, string $file, string $contentTmpFile = '', $fileExtension = '')
46
    {
47
        $crawler = GeneralUtility::makeInstance(CrawlerController::class);
48
49
        $params = [
50
            'document' => $contentTmpFile,
51
            'alturl' => $file,
52
            'conf' => $conf,
53
        ];
54
55
        unset($params['conf']['content']);
56
57
        $crawler->addQueueEntry_callBack(0, $params, IndexedSearchCrawlerFilesHook::class, $conf['id']);
58
59
        GeneralUtility::makeInstance(TimeTracker::class)->setTSlogMessage('media "' . $params['document'] . '" added to "crawler" queue.', 1);
60
    }
61
}
62