Passed
Push — main ( 602928...933943 )
by
unknown
03:24
created

Configuration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 8
c 2
b 1
f 1
dl 0
loc 35
ccs 9
cts 9
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureRestler() 0 12 2
A __construct() 0 3 1
1
<?php
2
namespace Aoe\Restler\System\Restler;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2021 AOE GmbH <[email protected]>
8
 *
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
use Aoe\Restler\Configuration\ExtensionConfiguration;
29
use Aoe\Restler\Controller\BeUserAuthenticationController;
30
use Aoe\Restler\Controller\ExplorerAuthenticationController;
31
use Aoe\Restler\Controller\FeUserAuthenticationController;
32
use Luracast\Restler\Explorer\v2\Explorer;
33
use Luracast\Restler\Restler;
34
35
/**
36
 * Configure restler:
37
 *  - add API- and authentication-class, when online-documentation is enabled
38
 *    (this can be configured via extension-manager)
39
 *  - add authentication-class, which can be used to check, if FE-user is logged in
40
 *
41
 * @package Restler
42
 */
43
class Configuration implements ConfigurationInterface
44
{
45
    /**
46
     * @var ExtensionConfiguration
47
     */
48
    private $extensionConfiguration;
49
50
    /**
51
     * @param ExtensionConfiguration $extensionConfiguration
52
     */
53 2
    public function __construct(ExtensionConfiguration $extensionConfiguration)
54
    {
55 2
        $this->extensionConfiguration = $extensionConfiguration;
56 2
    }
57
58
    /**
59
     * configure restler:
60
     *  - add API- and authentication-class, when online documentation is enabled
61
     *  - add common authentication-class (which can be used for TYPO3-FrontEnd-User-authentication)
62
     *
63
     * @param Restler $restler
64
     * @return void
65
     */
66 2
    public function configureRestler(Restler $restler)
67
    {
68 2
        if ($this->extensionConfiguration->isOnlineDocumentationEnabled()) {
69 1
            $restler->addAPIClass(Explorer::class, $this->extensionConfiguration->getPathOfOnlineDocumentation());
70 1
            $restler->addAuthenticationClass(ExplorerAuthenticationController::class);
71
        }
72
73
        // add authentication-class, which can be used to check, if BE-user is logged in
74 2
        $restler->addAuthenticationClass(BeUserAuthenticationController::class);
75
76
        // add authentication-class, which can be used to check, if FE-user is logged in
77 2
        $restler->addAuthenticationClass(FeUserAuthenticationController::class);
78 2
    }
79
}
80