Passed
Push — master ( d5568c...ac874d )
by Timo
28:49 queued 03:56
created

PageIndexerRequestHandler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 36.36%

Importance

Changes 0
Metric Value
wmc 5
eloc 12
c 0
b 0
f 0
dl 0
loc 79
ccs 8
cts 22
cp 0.3636
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A shutdown() 0 3 1
A getRequest() 0 3 1
A __construct() 0 6 1
A getResponse() 0 3 1
A run() 0 3 1
1
<?php
2
namespace ApacheSolrForTypo3\Solr\IndexQueue;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2010-2015 Ingo Renner <[email protected]>
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
use ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\Dispatcher;
28
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager;
29
use TYPO3\CMS\Core\SingletonInterface;
30
use TYPO3\CMS\Core\Utility\GeneralUtility;
31
32
/**
33
 * Checks for Index Queue page indexer requests and handles the actions
34
 * requested by them.
35
 *
36
 * @author Ingo Renner <[email protected]>
37
 */
38
class PageIndexerRequestHandler implements SingletonInterface
39
{
40
41
    /**
42
     * Index Queue page indexer request.
43
     *
44
     * @var PageIndexerRequest
45
     */
46
    protected $request;
47
48
    /**
49
     * Index Queue page indexer response.
50
     *
51
     * @var PageIndexerResponse
52
     */
53
    protected $response;
54
55
    /**
56
     * Index Queue page indexer frontend helper dispatcher.
57
     *
58
     * @var Dispatcher
59
     */
60
    protected $dispatcher;
61
62
    /**
63
     * Constructor.
64
     *
65
     * Initializes request, response, and dispatcher.
66
     */
67 2
    public function __construct(string $jsonEncodedParameters = null)
68
    {
69 2
        $this->dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
70 2
        $this->request = GeneralUtility::makeInstance(PageIndexerRequest::class, /** @scrutinizer ignore-type */ $jsonEncodedParameters);
71 2
        $this->response = GeneralUtility::makeInstance(PageIndexerResponse::class);
72 2
        $this->response->setRequestId($this->request->getRequestId());
73 2
    }
74
    
75
76
    /**
77
     * Authenticates the request, runs the frontend helpers defined by the
78
     * request, and registers its own shutdown() method for execution at
79
     * hook_eofe in tslib/class.tslib_fe.php.
80
     *
81
     * @return void
82
     */
83
    public function run()
84
    {
85
        $this->dispatcher->dispatch($this->request, $this->response);
86
    }
87
88
    /**
89
     * Completes the Index Queue page indexer request and returns the response
90
     * with the collected results.
91
     *
92
     * @return void
93
     */
94
    public function shutdown()
95
    {
96
        $this->dispatcher->shutdown();
97
    }
98
99
    /**
100
     * Gets the Index Queue page indexer request.
101
     *
102
     * @return PageIndexerRequest
103
     */
104 2
    public function getRequest()
105
    {
106 2
        return $this->request;
107
    }
108
109
    /**
110
     * Gets the Index Queue page indexer response.
111
     *
112
     * @return PageIndexerResponse
113
     */
114
    public function getResponse()
115
    {
116
        return $this->response;
117
    }
118
}
119