Skip to content

Commit debb44d

Browse files
committed
Merge branch '11'
2 parents e7f7038 + 08b20ea commit debb44d

File tree

58 files changed

+264
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+264
-257
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,38 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
env:
14-
- { php: 7.4 }
14+
- { php: 8.0 }
15+
- { php: 8.1 }
16+
- { php: 8.2 }
1517

1618
env: ${{ matrix.env }}
1719

1820
steps:
1921
- name: Checkout
20-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
2123

2224
- name: Setup PHP
2325
uses: shivammathur/setup-php@v2
2426
with:
2527
php-version: ${{ matrix.env.php }}
26-
tools: composer
28+
tools: composer:2
2729
extensions: pdo, sqlite3
2830

29-
# composer
30-
- name: Update Composer
31-
run: |
32-
sudo composer self-update
33-
composer --version
3431
- name: Validate composer.json and composer.lock
3532
run: composer validate
3633

3734
- name: Cache dependencies
38-
uses: actions/cache@v1
35+
uses: actions/cache@v4
3936
with:
4037
path: ~/.composer/cache
41-
key: dependencies-composer-${{ hashFiles('composer.json') }}
38+
key: dependencies-composer-${{ matrix.env.php }}-${{ hashFiles('composer.json') }}
4239

4340
- name: Install dependencies
4441
run: composer install
4542

4643
- name: Check coding style
4744
run: composer lint
45+
if: ${{ matrix.env.php == '8.1' }}
4846

4947
- name: Run Unit Tests
5048
run: |

.php-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.4
1+
8.1

Classes/Controller/SearchController.php

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,52 @@
2828
*
2929
* This copyright notice MUST APPEAR in all copies of the script!
3030
* ************************************************************* */
31-
31+
use Psr\Http\Message\ResponseInterface;
32+
use Psr\Log\LoggerInterface;
3233
use Subugoe\Find\Service\ServiceProviderInterface;
3334
use Subugoe\Find\Utility\ArrayUtility;
3435
use Subugoe\Find\Utility\FrontendUtility;
3536
use TYPO3\CMS\Core\Log\LogManagerInterface;
37+
use TYPO3\CMS\Core\Page\AssetCollector;
3638
use TYPO3\CMS\Core\Utility\ArrayUtility as CoreArrayUtility;
3739
use TYPO3\CMS\Core\Utility\GeneralUtility;
40+
use TYPO3\CMS\Extbase\Http\ForwardResponse;
3841
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
42+
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
43+
use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException;
3944

4045
class SearchController extends ActionController
4146
{
4247
protected array $requestArguments = [];
4348

4449
protected ?object $searchProvider = null;
4550

46-
private \Psr\Log\LoggerInterface $logger;
51+
private LoggerInterface $logger;
4752

4853
public function __construct(LogManagerInterface $logManager)
4954
{
5055
$this->logger = $logManager->getLogger('find');
5156
}
5257

5358
/**
54-
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
55-
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
59+
* @throws NoSuchArgumentException
60+
* @throws StopActionException
5661
*/
57-
public function detailAction(string $id)
62+
public function detailAction(string $id): ResponseInterface
5863
{
5964
$arguments = $this->searchProvider->getRequestArguments();
6065
$detail = $this->searchProvider->getDocumentById($id);
61-
6266
if ($this->request->hasArgument('underlyingQuery')) {
6367
$underlyingQueryInfo = $this->request->getArgument('underlyingQuery');
64-
$this->response->addAdditionalHeaderData(
65-
FrontendUtility::addQueryInformationAsJavaScript(
66-
$underlyingQueryInfo['q'],
67-
$this->settings,
68-
(int) $underlyingQueryInfo['position'],
69-
$arguments
70-
)
68+
$underlyingQueryScriptTagContent = FrontendUtility::addQueryInformationAsJavaScript(
69+
$underlyingQueryInfo['q'],
70+
$this->settings,
71+
(int) $underlyingQueryInfo['position'],
72+
$arguments
7173
);
74+
75+
GeneralUtility::makeInstance(AssetCollector::class)
76+
->addInlineJavaScript('underlyingQueryVar', $underlyingQueryScriptTagContent, ['type' => 'text/javascript'], ['priority' => true]);
7277
}
7378

7479
$this->addStandardAssignments();
@@ -78,43 +83,49 @@ public function detailAction(string $id)
7883
'arguments' => $arguments,
7984
'config' => $this->searchProvider->getConfiguration(),
8085
]);
86+
87+
return $this->htmlResponse();
8188
}
8289

8390
/**
8491
* Index Action.
8592
*/
86-
public function indexAction()
93+
public function indexAction(): ResponseInterface
8794
{
8895
if (array_key_exists('id', $this->requestArguments)) {
89-
$this->forward('detail');
90-
} else {
91-
$this->searchProvider->setCounter();
92-
$this->response->addAdditionalHeaderData(
93-
FrontendUtility::addQueryInformationAsJavaScript(
94-
$this->searchProvider->getRequestArguments()['q'],
95-
$this->settings,
96-
null,
97-
$this->searchProvider->getRequestArguments()
98-
)
99-
);
96+
return new ForwardResponse('detail');
97+
}
10098

101-
$this->addStandardAssignments();
102-
$defaultQuery = $this->searchProvider->getDefaultQuery();
99+
$this->searchProvider->setCounter();
103100

104-
$viewValues = [
105-
'arguments' => $this->searchProvider->getRequestArguments(),
106-
'config' => $this->searchProvider->getConfiguration(),
107-
];
101+
$underlyingQueryScriptTagContent = FrontendUtility::addQueryInformationAsJavaScript(
102+
$this->searchProvider->getRequestArguments()['q'] ?? [],
103+
$this->settings,
104+
null,
105+
$this->searchProvider->getRequestArguments()
106+
);
108107

109-
CoreArrayUtility::mergeRecursiveWithOverrule($viewValues, $defaultQuery);
110-
$this->view->assignMultiple($viewValues);
111-
}
108+
GeneralUtility::makeInstance(AssetCollector::class)
109+
->addInlineJavaScript('underlyingQueryVar', $underlyingQueryScriptTagContent, ['type' => 'text/javascript'], ['priority' => true]);
110+
111+
$this->addStandardAssignments();
112+
$defaultQuery = $this->searchProvider->getDefaultQuery();
113+
114+
$viewValues = [
115+
'arguments' => $this->searchProvider->getRequestArguments(),
116+
'config' => $this->searchProvider->getConfiguration(),
117+
];
118+
119+
CoreArrayUtility::mergeRecursiveWithOverrule($viewValues, $defaultQuery);
120+
$this->view->assignMultiple($viewValues);
121+
122+
return $this->htmlResponse();
112123
}
113124

114125
/**
115126
* Initialisation and setup.
116127
*/
117-
protected function initializeAction()
128+
protected function initializeAction(): void
118129
{
119130
ksort($this->settings['queryFields']);
120131

@@ -131,16 +142,18 @@ protected function initializeAction()
131142
/**
132143
* Suggest/Autocomplete action.
133144
*/
134-
public function suggestAction()
145+
public function suggestAction(): ResponseInterface
135146
{
136147
$results = $this->searchProvider->suggestQuery($this->searchProvider->getRequestArguments());
137148
$this->view->assign('suggestions', $results);
149+
150+
return $this->htmlResponse();
138151
}
139152

140153
/**
141154
* Assigns standard variables to the view.
142155
*/
143-
protected function addStandardAssignments()
156+
protected function addStandardAssignments(): void
144157
{
145158
$this->searchProvider->setConfigurationValue('extendedSearch', $this->searchProvider->isExtendedSearch());
146159
$this->searchProvider->setConfigurationValue(
@@ -154,7 +167,7 @@ protected function addStandardAssignments()
154167
/**
155168
* @param string $activeConnection
156169
*/
157-
protected function initializeConnection($activeConnection)
170+
protected function initializeConnection($activeConnection): void
158171
{
159172
$connectionConfiguration = $this->settings['connections'][$activeConnection];
160173

Classes/Service/AbstractServiceProvider.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,15 @@
88

99
abstract class AbstractServiceProvider implements ServiceProviderInterface
1010
{
11-
protected string $connectionName;
12-
1311
/**
1412
* @var LogManagerInterface
1513
*/
1614
protected $logger;
1715

1816
protected array $requestArguments = [];
1917

20-
protected array $settings = [];
21-
22-
public function __construct(string $connectionName, array $settings)
18+
public function __construct(protected string $connectionName, protected array $settings)
2319
{
24-
$this->connectionName = $connectionName;
25-
$this->settings = $settings;
2620
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger('find');
2721
}
2822

0 commit comments

Comments
 (0)