|
1
|
|
|
<?php |
|
2
|
|
|
namespace ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper; |
|
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 2 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\Manager; |
|
28
|
|
|
use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerRequest; |
|
29
|
|
|
use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerResponse; |
|
30
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Dispatches the actions requested to the matching frontend helpers. |
|
34
|
|
|
* |
|
35
|
|
|
* @author Ingo Renner <[email protected]> |
|
36
|
|
|
*/ |
|
37
|
|
|
class Dispatcher |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Frontend helper manager. |
|
42
|
|
|
* |
|
43
|
|
|
* @var Manager |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $frontendHelperManager; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Constructor |
|
49
|
|
|
* |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function __construct() |
|
52
|
|
|
{ |
|
53
|
1 |
|
$this->frontendHelperManager = GeneralUtility::makeInstance(Manager::class); |
|
54
|
1 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Takes the request's actions and hands them of to the according frontend |
|
58
|
|
|
* helpers. |
|
59
|
|
|
* |
|
60
|
|
|
* @param PageIndexerRequest $request The request to dispatch |
|
61
|
|
|
* @param PageIndexerResponse $response The request's response |
|
62
|
|
|
*/ |
|
63
|
|
|
public function dispatch( |
|
64
|
|
|
PageIndexerRequest $request, |
|
65
|
|
|
PageIndexerResponse $response |
|
66
|
|
|
) { |
|
67
|
|
|
$actions = $request->getActions(); |
|
68
|
|
|
|
|
69
|
|
|
foreach ($actions as $action) { |
|
70
|
|
|
$frontendHelper = $this->frontendHelperManager->resolveAction($action); |
|
71
|
|
|
$frontendHelper->activate(); |
|
72
|
|
|
$frontendHelper->processRequest($request, $response); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Sends a shutdown signal to all activated frontend helpers. |
|
78
|
|
|
* |
|
79
|
|
|
* @return void |
|
80
|
|
|
*/ |
|
81
|
|
|
public function shutdown() |
|
82
|
|
|
{ |
|
83
|
|
|
$frontendHelpers = $this->frontendHelperManager->getActivatedFrontendHelpers(); |
|
84
|
|
|
|
|
85
|
|
|
foreach ($frontendHelpers as $frontendHelper) { |
|
86
|
|
|
/** @var FrontendHelper $frontendHelper */ |
|
87
|
|
|
$frontendHelper->deactivate(); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|