TcaUtility   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 29
rs 10
c 3
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProcessingInstructions() 0 10 3
A getExtensionIcon() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AOE\Crawler\Utility;
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 TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
23
24
/**
25
 * @codeCoverageIgnore
26
 * @internal since v9.2.5
27
 */
28
class TcaUtility
29
{
30
    /**
31
     * Get crawler processing instructions.
32
     * This function is called as a itemsProcFunc in tx_crawler_configuration.processing_instruction_filter
33
     *
34
     * @return array
35
     */
36
    public function getProcessingInstructions(array $configuration)
37
    {
38
        $configuration = $configuration ?? ['items' => []];
39
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions'])) {
40
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions'] as $extensionKey => $extensionConfiguration) {
41
                $configuration['items'][] = [$extensionConfiguration['value'] . ' [' . $extensionConfiguration['key'] . ']', $extensionConfiguration['key'], $this->getExtensionIcon($extensionKey)];
42
            }
43
        }
44
45
        return $configuration;
46
    }
47
48
    /**
49
     * Get path to ext_icon.gif from processing instruction key
50
     *
51
     * @param string $extensionKey Like staticfilecache or indexed_search
52
     * @return string
53
     */
54
    protected function getExtensionIcon($extensionKey)
55
    {
56
        return ExtensionManagementUtility::getExtensionIcon(ExtensionManagementUtility::extPath($extensionKey), true);
57
    }
58
}
59