Skip to content

Commit

Permalink
[WIP][TASK] Allow v12 solr + core
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer committed Jun 21, 2023
1 parent d58eaf4 commit 991327d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
26 changes: 26 additions & 0 deletions Classes/EventListener/BeforeSearchResultIsShownEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);

namespace StudioMitte\SolrNumberedPagination\EventListener;

use ApacheSolrForTypo3\Solr\Event\Search\BeforeSearchResultIsShownEvent;
use ApacheSolrForTypo3\Solr\Pagination\ResultsPaginator;
use GeorgRinger\NumberedPagination\NumberedPagination;
use TYPO3\CMS\Core\Pagination\SlidingWindowPagination;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class BeforeSearchResultIsShownEventListener
{

public function __invoke(BeforeSearchResultIsShownEvent $event)
{
$searchResultSet = $event->getResultSet();
$currentPage = $event->getCurrentPage();
$itemsPerPage = ($searchResultSet->getUsedResultsPerPage() ?: 10);
$maximumNumberOfLinks = ($event->getPagination()->getMaxPageNumbers() ?: 10);
$paginator = GeneralUtility::makeInstance(ResultsPaginator::class, $searchResultSet, $currentPage, $itemsPerPage);

$event->setPagination(GeneralUtility::makeInstance(NumberedPagination::class, $paginator, $maximumNumberOfLinks));
}

}
13 changes: 13 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
_defaults:
autowire: false
autoconfigure: true

StudioMitte\SolrNumberedPagination\:
resource: '../Classes/*'

StudioMitte\SolrNumberedPagination\EventListener\BeforeSearchResultIsShownEventListener:
tags:
- name: event.listener
identifier: 'solr_numbered_pagination/pagination'
event: ApacheSolrForTypo3\Solr\Event\Search\BeforeSearchResultIsShownEvent
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"GPL-2.0-or-later"
],
"require": {
"typo3/cms-core": "^10 || ^11.5",
"typo3/cms-core": "^10 || ^11.5 || ^12.4.2",
"georgringer/numbered-pagination": "^1",
"apache-solr-for-typo3/solr": "11.5.x-dev || ^11"
"apache-solr-for-typo3/solr": "11.5.x-dev || ^11 || ^12"
},
"autoload": {
"psr-4": {
Expand All @@ -26,4 +26,4 @@
"extension-key": "solr_numbered_pagination"
}
}
}
}
6 changes: 3 additions & 3 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
'author' => 'Georg Ringer',
'author_email' => '[email protected]',
'state' => 'stable',
'version' => '1.0.1',
'version' => '1.0.2',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-11.5.99',
'solr' => '11.5.0-11.5.99',
'typo3' => '10.4.0-12.4.99',
'solr' => '11.5.0-12.99.99',
'numbered_pagination' => '1.0.0-1.99.99',
],
'conflicts' => [],
Expand Down
16 changes: 9 additions & 7 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
\ApacheSolrForTypo3\Solr\Controller\SearchController::class,
'resultsAction',
\StudioMitte\SolrNumberedPagination\Slot\SolrResultActionSlot::class,
'run'
);
if ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() < 12) {
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
\ApacheSolrForTypo3\Solr\Controller\SearchController::class,
'resultsAction',
\StudioMitte\SolrNumberedPagination\Slot\SolrResultActionSlot::class,
'run'
);
}

0 comments on commit 991327d

Please sign in to comment.