Failed Conditions
Push — task/3376-TYPO3_12_compatibili... ( 6ec289...1d802a )
by Rafael
40:27
created

AbstractFrontendHelper::deactivate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper;
19
20
use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerRequest;
21
use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerResponse;
22
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager;
23
use TYPO3\CMS\Core\SingletonInterface;
24
use TYPO3\CMS\Core\Utility\GeneralUtility;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Core\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...
25
26
/**
27
 * Index Queue page indexer frontend helper base class implementing common
28
 * functionality.
29
 *
30
 * @author Ingo Renner <[email protected]>
31
 */
32
abstract class AbstractFrontendHelper implements FrontendHelper, SingletonInterface
33
{
34
    /**
35
     * Index Queue page indexer request.
36
     *
37
     * @var PageIndexerRequest|null
38
     */
39
    protected ?PageIndexerRequest $request = null;
40
41
    /**
42
     * Index Queue page indexer response.
43
     *
44
     * @var PageIndexerResponse|null
45
     */
46
    protected ?PageIndexerResponse $response = null;
47
48
    /**
49
     * Singleton instance variable for indication of indexing request.
50
     *
51
     * @var bool
52
     */
53
    protected bool $isActivated = false;
54
55
    /**
56
     * The action a frontend helper executes.
57
     */
58
    protected string $action;
59
60
    /**
61
     * @var SolrLogManager|null
62
     */
63
    protected ?SolrLogManager $logger = null;
64
65
    /**
66
     * Starts the execution of a frontend helper.
67
     *
68
     * @param PageIndexerRequest $request Page indexer request
69
     * @param PageIndexerResponse $response Page indexer response
70
     */
71
    public function processRequest(
72
        PageIndexerRequest $request,
73
        PageIndexerResponse $response
74
    ): void {
75
        $this->request = $request;
76
        $this->response = $response;
77
        $this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
78
79
        if ($request->getParameter('loggingEnabled')) {
80
            $this->logger->log(
0 ignored issues
show
Bug introduced by
The method log() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

80
            $this->logger->/** @scrutinizer ignore-call */ 
81
                           log(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
81
                SolrLogManager::INFO,
82
                'Page indexer request received',
83
                [
84
                    'request' => (array)$request,
85
                ]
86
            );
87
        }
88
    }
89
90
    /**
91
     * Deactivates a frontend helper by unregistering from hooks and releasing
92
     * resources.
93
     */
94
    public function deactivate(): void
95
    {
96
        $this->isActivated = false;
97
        $this->response->addActionResult($this->action, $this->getData());
0 ignored issues
show
Bug introduced by
The method addActionResult() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

97
        $this->response->/** @scrutinizer ignore-call */ 
98
                         addActionResult($this->action, $this->getData());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
98
    }
99
}
100