-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
ext_localconf.php
63 lines (54 loc) · 2.47 KB
/
ext_localconf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use Cundd\Rest\Authentication\UserProvider\FeUserProvider;
use Cundd\Rest\Authentication\UserProviderInterface;
use Cundd\Rest\BootstrapDispatcher;
use Cundd\Rest\Configuration\ConfigurationProviderInterface;
use Cundd\Rest\Configuration\TypoScriptConfigurationProvider;
use Cundd\Rest\Handler\CrudHandler;
use Cundd\Rest\Handler\HandlerInterface;
use TYPO3\CMS\Extbase\Object\Container\Container;
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
call_user_func(
function () {
// TYPO3 v8
if (!class_exists(TYPO3\CMS\Core\Information\Typo3Version::class)) {
// Register eID
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['rest'] = BootstrapDispatcher::class . '::processRequest';
if (isset($_SERVER['REQUEST_URI'])) {
// Detect and "hijack" REST requests
$restRequestBasePath = (string)(getenv(
'TYPO3_REST_REQUEST_BASE_PATH'
) ?: getenv(
'REDIRECT_TYPO3_REST_REQUEST_BASE_PATH'
));
if ($restRequestBasePath) {
$restRequestBasePath = '/' . trim($restRequestBasePath, '/');
}
$restRequestPrefix = $restRequestBasePath . '/rest/';
$restRequestPrefixLength = strlen($restRequestPrefix);
$requestUri = $_SERVER['REQUEST_URI'];
if (substr($requestUri, 0, $restRequestPrefixLength) === $restRequestPrefix) {
$_GET['eID'] = 'rest';
}
}
}
// Register Cache
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cundd_rest_cache'])
|| !is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cundd_rest_cache'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cundd_rest_cache'] = [];
}
$implementationsMap = [
ConfigurationProviderInterface::class => TypoScriptConfigurationProvider::class,
UserProviderInterface::class => FeUserProvider::class,
HandlerInterface::class => CrudHandler::class,
];
$objectContainer = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
Container::class
);
foreach ($implementationsMap as $interface => $impl) {
$objectContainer->registerImplementation($interface, $impl);
}
}
);