Test Failed
Push — 6-0 ( cfb4d5 )
by Tomas Norre
03:23
created

TcaUtility   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProcessingInstructions() 0 9 3
A getExtensionIcon() 0 13 4
1
<?php
2
namespace AOE\Crawler\Utility;
3
4
/*
5
 * Copyright notice
6
 *
7
 * (c) 2016 AOE GmbH <[email protected]>
8
 *
9
 * All rights reserved
10
 * This file is part of the TYPO3 CMS project.
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;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Core\Utility\ExtensionManagementUtility 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...
23
24
/**
25
 * Class TcaUtility
26
 *
27
 * @package AOE\Crawler\Utility
28
 */
29
class TcaUtility
30
{
31
    /**
32
     * Get crawler processing instructions.
33
     * This function is called as a itemsProcFunc in tx_crawler_configuration.processing_instruction_filter
34
     *
35
     * @param array $configuration
36
     * @return array
37
     */
38
    public function getProcessingInstructions(array $configuration)
39
    {
40
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions'])) {
41
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions'] as $key => $value) {
42
                $configuration['items'][] = [$value . ' [' . $key . ']', $key, $this->getExtensionIcon($key)];
43
            }
44
        }
45
46
        return $configuration;
47
    }
48
49
    /**
50
     * Get path to ext_icon.gif from processing instruction key
51
     *
52
     * @param string $key Like tx_realurl_rebuild
53
     * @return string
54
     */
55
    protected function getExtensionIcon($key)
56
    {
57
        $extIcon = '';
58
59
        if (method_exists(ExtensionManagementUtility::class, 'getExtensionKeyByPrefix')) {
60
            $parts = explode('_', $key);
61
            if (is_array($parts) && count($parts) > 2) {
62
                $extensionKey = ExtensionManagementUtility::getExtensionKeyByPrefix('tx_' . $parts[1]);
63
                $extIcon = ExtensionManagementUtility::siteRelPath($extensionKey) . 'ext_icon.gif';
64
            }
65
        }
66
67
        return $extIcon;
68
    }
69
}
70