Completed
Pull Request — master (#1083)
by
unknown
16:21
created

ModuleBootstrap::main()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 2
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Backend\IndexInspector;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2017 Rafael Kähm <[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
 *  A copy is found in the textfile GPL.txt and important notices to the license
19
 *  from the author is found in LICENSE.txt distributed with these scripts.
20
 *
21
 *
22
 *  This script is distributed in the hope that it will be useful,
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 *  GNU General Public License for more details.
26
 *
27
 *  This copyright notice MUST APPEAR in all copies of the script!
28
 ***************************************************************/
29
30
use TYPO3\CMS\Core\Utility\GeneralUtility;
31
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
32
use TYPO3\CMS\Extbase\Core\Bootstrap;
33
34
/**
35
 * This class is a wrapper for Web->Info controller of solr Index Inspector.
36
 * It is registered in ext_tables.php with \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction()
37
 * and called by the info extension via SCbase functionality.
38
 *
39
 * Extbase currently provides no way to register a "TBE_MODULES_EXT"(third level module) module directly,
40
 * therefore we need to bootstrap extbase on our own here to jump to the Web->Info controller.
41
 * @todo: Remove this class and register 'ApacheSolrForTypo3\Solr\Controller\ApacheSolrDocumentController' in proper Extbase way if Web>Info is implemented with Extbase. See the class description before doing something.
42
 */
43
class ModuleBootstrap
44
{
45
46
    /**
47
     * Dummy method, called by SCbase external object handling
48
     *
49
     * @return void
50
     */
51
    public function init()
52
    {
53
    }
54
55
    /**
56
     * Dummy method, called by SCbase external object handling
57
     *
58
     * @return void
59
     */
60
    public function checkExtObj()
61
    {
62
    }
63
64
    /**
65
     * Bootstrap extbase and jump to WebInfo controller
66
     *
67
     * @return string
68
     */
69
    public function main()
70
    {
71
        $configuration = [
72
            'vendorName' => 'ApacheSolrForTypo3',
73
            'extensionName' => 'Solr',
74
            'pluginName' => 'tools_SolrAdministration'
75
        ];
76
        // Yeah, this is ugly. But currently, there is no other direct way
77
        // in extbase to force a specific controller in backend mode.
78
        // Overwriting $_GET was the most simple solution here until extbase
79
        // provides a clean way to solve this.
80
81
        $_GET['tx_solr_tools_solradministration']['controller'] = 'Backend\\Web\\Info\\ApacheSolrDocument';
82
        /* @var $extbaseBootstrap Bootstrap */
83
        $extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class);
84
        return $extbaseBootstrap->run('', $configuration);
85
    }
86
}
87