-
Notifications
You must be signed in to change notification settings - Fork 7
/
ext_localconf.php
155 lines (143 loc) · 5.34 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
use PAGEmachine\Searchable\Controller\SearchController;
use PAGEmachine\Searchable\Eid\Autosuggest;
use PAGEmachine\Searchable\Eid\Search;
use PAGEmachine\Searchable\Feature\CompletionSuggestFeature;
use PAGEmachine\Searchable\Feature\HighlightFeature;
use PAGEmachine\Searchable\Feature\TermSuggestFeature;
use PAGEmachine\Searchable\Hook\DynamicFlexFormHook;
use PAGEmachine\Searchable\Query\AutosuggestQuery;
use PAGEmachine\Searchable\Query\SearchQuery;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\Log\LogLevel;
use TYPO3\CMS\Core\Log\Writer\FileWriter;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
if (!defined('TYPO3')) {
die('Access denied.');
}
ExtensionUtility::configurePlugin(
'Searchable',
'Searchbar',
[
SearchController::class => 'searchbar',
],
[
SearchController::class => 'searchbar',
]
);
ExtensionUtility::configurePlugin(
'Searchable',
'LiveSearchbar',
[
SearchController::class => 'liveSearchbar',
],
[
SearchController::class => 'liveSearchbar',
]
);
ExtensionUtility::configurePlugin(
'Searchable',
'Results',
[
SearchController::class => 'results',
],
[
SearchController::class => 'results',
]
);
// Add custom logging
if (empty($GLOBALS['TYPO3_CONF_VARS']['LOG']['PAGEmachine']['Searchable']['writerConfiguration'])) {
$GLOBALS['TYPO3_CONF_VARS']['LOG']['PAGEmachine']['Searchable']['writerConfiguration'] = [
LogLevel::ERROR => [
FileWriter::class => [
'logFile' => 'typo3temp/logs/searchable.log',
],
],
];
}
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['searchable'] = [
// Configuration coming from Extension Manager
// Subkey 'hosts' contains connection credentials
// See https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_configuration.html#_extended_host_configuration for available options
'extensionManagement' => [
'connection' => [
'hosts' => 'http://localhost:9200',
],
'indexing' => [
'domain' => 'http://localhost:80',
],
],
// The fieldname to store meta information in (link, preview etc.). This field will be added to all created ES types and set to index = false
// Note that this field will also affect how you can access the meta fields in templates!
'metaField' => 'searchable_meta',
//Update index. Used for storing the records to update in the next indexing run
'updateIndex' => [
'name' => 'searchable_updates',
],
//Add indices here. Default format: language UID => index configuration
'indices' => [],
//Add your indexer configurations here. Each indexer represents a toplevel object type like news, pages etc.
'indexers' => [],
//Define pipelines here. Pipelines can be used to modify content during indexing
'pipelines' => [],
//Default index settings used for every index. If you define custom settings, these will be merged with them
'defaultIndexSettings' => [
'number_of_shards' => 2,
'number_of_replicas' => 0,
],
'defaultMapping' => [
'features' => [
'suggest' => [
'className' => TermSuggestFeature::class,
],
],
],
'query' => [
SearchQuery::class => [
'features' => [
'highlighting' => [
'className' => HighlightFeature::class,
],
'termSuggest' => [
'className' => TermSuggestFeature::class,
],
],
],
AutosuggestQuery::class => [
'features' => [
'completionSuggest' => [
'className' => CompletionSuggestFeature::class,
],
],
],
],
];
// Load Extension Manager settings
(function (): void {
try {
$extensionConfiguration = GeneralUtility::makeInstance(
ExtensionConfiguration::class
)->get('searchable');
} catch (ExtensionConfigurationExtensionNotConfiguredException) {
$extensionConfiguration = [];
}
foreach ($extensionConfiguration as $key => $value) {
if (is_array($value) && isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['searchable']['extensionManagement'][$key])) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['searchable']['extensionManagement'][$key] = array_merge(
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['searchable']['extensionManagement'][$key],
$extensionConfiguration[$key]
);
} else {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['searchable']['extensionManagement'][$key] = $extensionConfiguration[$key];
}
}
})();
//Register eid
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['searchable_autosuggest'] = Autosuggest::class . '::processRequest';
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['searchable_search'] = Search::class . '::processRequest';
// Register Hook for dynamic Plugin FlexForms
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][FlexFormTools::class]['flexParsing']['searchable'] =
DynamicFlexFormHook::class;