Passed
Push — Cleanup/misc ( 4cc982 )
by Tomas Norre
06:26
created

HookUtility::triggerCliHooks()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 6
rs 10
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 AOE\Crawler\Hooks\ProcessCleanUpHook;
23
24
/**
25
 * Class HookUtility
26
 *
27
 * @codeCoverageIgnore
28
 */
29
class HookUtility
30
{
31
    /**
32
     * Registers hooks
33
     *
34
     * @param string $extKey
35
     */
36
    public static function registerHooks($extKey): void
37
    {
38
        // Activating Crawler cli_hooks
39
        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['cli_hooks'][] =
40
            ProcessCleanUpHook::class;
41
42
        // Activating refresh hooks
43
        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['refresh_hooks'][] =
44
            ProcessCleanUpHook::class;
45
    }
46
47
    public function triggerCliHooks(): void
48
    {
49
        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['cli_hooks'] ?? [] as $objRef) {
50
            $hookObj = GeneralUtility::makeInstance($objRef);
0 ignored issues
show
Bug introduced by
The type AOE\Crawler\Utility\GeneralUtility 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...
51
            if (is_object($hookObj)) {
52
                $hookObj->crawler_init($this);
53
            }
54
        }
55
    }
56
}
57