Skip to content

Commit 564c365

Browse files
committed
Fix web connector to use new processors
Fix main class to work with PHP 8.1
1 parent 529306e commit 564c365

File tree

4 files changed

+85
-104
lines changed

4 files changed

+85
-104
lines changed

_build/gpm.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: >-
55
Evolution (minus the ajax). Only searches Resources; does not search dynamic
66
content.
77
author: modxcms
8-
version: 3.0.0-alpha
8+
version: 3.0.0-beta
99
chunks:
1010
- name: SearchForm
1111
file: searchform.chunk.tpl
@@ -289,7 +289,7 @@ snippets:
289289
lexicon: simplesearch:properties
290290
systemSettings:
291291
- key: driver_class
292-
value: \SimpleSearch\Driver\SimpleSearchDriverBasic
292+
value: ''
293293
area: Drivers
294294
- key: autosuggest_tv
295295
value: simpleSearchAutoSuggestions
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
2-
31
<?php
4-
/**
5-
* @var \Teleport\Transport\Transport $transport
6-
* @var array $object
7-
* @var array $options
8-
*/
9-
10-
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
11-
case xPDOTransport::ACTION_UPGRADE:
12-
/** @var modX $modx */
13-
$modx =& $transport->xpdo;
142

15-
/** @var \MODX\Revolution\modSystemSetting $ss */
16-
$ss = $modx->getObject(\MODX\Revolution\modSystemSetting::class, ['key' => 'simplesearch.driver_class']);
17-
if ($ss && $ss->value === 'SimpleSearchDriverBasic') {
18-
$ss->set('value', '\SimpleSearch\Driver\SimpleSearchDriverBasic');
19-
$ss->save();
20-
}
3+
use MODX\Revolution\modSystemSetting;
214

22-
break;
5+
/** @var array $options */
6+
if ($options[xPDOTransport::PACKAGE_ACTION] === xPDOTransport::ACTION_UPGRADE) {
7+
/** @var xPDOTransport $transport */
8+
/** @var modSystemSetting $setting */
9+
$setting = $transport->xpdo->getObject(modSystemSetting::class, ['key' => 'simplesearch.driver_class']);
10+
if ($setting && $setting->value === 'SimpleSearchDriverBasic') {
11+
$setting->set('value', '');
12+
$setting->save();
13+
}
2314
}
2415

2516
return true;
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
22

3-
require_once dirname(dirname(dirname(__DIR__))) . '/config.core.php';
3+
/** @var \MODX\Revolution\modX $modx */
4+
require_once dirname(__DIR__, 3) . '/config.core.php';
45
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
56
require_once MODX_CONNECTORS_PATH . 'index.php';
67

8+
use SimpleSearch\Processors\Web\AutoSuggestions;
79
use SimpleSearch\SimpleSearch;
810

911
$webActions = [
10-
'web/autosuggestions'
12+
'web/autosuggestions' => AutoSuggestions::class,
1113
];
1214

13-
if (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $webActions)) {
15+
if (!empty($_REQUEST['action']) && array_key_exists($_REQUEST['action'], $webActions)) {
1416
define('MODX_REQP', false);
15-
}
1617

17-
if (in_array($_REQUEST['action'], $webActions, true)) {
1818
if ($modx->user->hasSessionContext($modx->context->get('key'))) {
1919
$_SERVER['HTTP_MODAUTH'] = $_SESSION["modx.{$modx->context->get('key')}.user.token"];
2020
} else {
@@ -23,12 +23,13 @@
2323
}
2424

2525
$_REQUEST['HTTP_MODAUTH'] = $_SERVER['HTTP_MODAUTH'];
26+
$_REQUEST['action'] = $webActions[$_REQUEST['action']];
2627
}
2728

2829
$instance = $modx->services->get('simplesearch');
2930
if ($instance instanceof SimpleSearch) {
3031
$modx->request->handleRequest([
3132
'processors_path' => $instance->config['processors_path'],
32-
'location' => ''
33+
'location' => '',
3334
]);
3435
}

0 commit comments

Comments
 (0)