Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Fix web connector to use new processors
Browse files Browse the repository at this point in the history
Fix main class to work with PHP 8.1
  • Loading branch information
bezumkin committed Feb 8, 2023
1 parent fe2ce33 commit 2dacf1e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 107 deletions.
10 changes: 5 additions & 5 deletions _build/gpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
Evolution (minus the ajax). Only searches Resources; does not search dynamic
content.
author: modxcms
version: 3.0.0-alpha
version: 3.0.0-beta
chunks:
- name: SearchForm
file: searchform.chunk.tpl
Expand Down Expand Up @@ -289,12 +289,12 @@ snippets:
lexicon: simplesearch:properties
systemSettings:
- key: driver_class
value: \SimpleSearch\Driver\SimpleSearchDriverBasic
value: ''
area: Drivers
- key: autosuggest_tv
value: simpleSearchAutoSuggestions
area: Autosuggest
build:
- scriptsAfter: [resolve.fixsystemsettings.php]
- requires:
- modx: '>=3.0.0-alpha'
scriptsAfter: [resolve.fixsystemsettings.php]
requires:
modx: '>=3.0.0-alpha'
29 changes: 10 additions & 19 deletions _build/scripts/resolve.fixsystemsettings.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@


<?php
/**
* @var \Teleport\Transport\Transport $transport
* @var array $object
* @var array $options
*/

switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_UPGRADE:
/** @var modX $modx */
$modx =& $transport->xpdo;

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

break;
/** @var array $options */
if ($options[xPDOTransport::PACKAGE_ACTION] === xPDOTransport::ACTION_UPGRADE) {
/** @var xPDOTransport $transport */
/** @var modSystemSetting $setting */
$setting = $transport->xpdo->getObject(modSystemSetting::class, ['key' => 'simplesearch.driver_class']);
if ($setting && $setting->value === 'SimpleSearchDriverBasic') {
$setting->set('value', '');
$setting->save();
}
}

return true;
13 changes: 7 additions & 6 deletions assets/components/simplesearch/connector.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php

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

use SimpleSearch\Processors\Web\AutoSuggestions;
use SimpleSearch\SimpleSearch;

$webActions = [
'web/autosuggestions'
'web/autosuggestions' => AutoSuggestions::class,
];

if (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $webActions)) {
if (!empty($_REQUEST['action']) && array_key_exists($_REQUEST['action'], $webActions)) {
define('MODX_REQP', false);
}

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

$_REQUEST['HTTP_MODAUTH'] = $_SERVER['HTTP_MODAUTH'];
$_REQUEST['action'] = $webActions[$_REQUEST['action']];
}

$instance = $modx->services->get('simplesearch');
if ($instance instanceof SimpleSearch) {
$modx->request->handleRequest([
'processors_path' => $instance->config['processors_path'],
'location' => ''
'location' => '',
]);
}
Loading

0 comments on commit 2dacf1e

Please sign in to comment.