mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-26 23:56:12 +01:00
[TASK] Add opening for possible user access lookup
This commit is contained in:
parent
e297d556e6
commit
404f49aad2
4 changed files with 66 additions and 8 deletions
|
@ -22,7 +22,7 @@ namespace Codappix\SearchCore\Controller;
|
|||
*/
|
||||
|
||||
use Codappix\SearchCore\Domain\Model\SearchRequest;
|
||||
use Codappix\SearchCore\Domain\Search\SearchService;
|
||||
use Codappix\SearchCore\Domain\Search\CachedSearchService;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
|
||||
/**
|
||||
|
@ -31,14 +31,14 @@ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|||
class SearchController extends ActionController
|
||||
{
|
||||
/**
|
||||
* @var SearchService
|
||||
* @var CachedSearchService
|
||||
*/
|
||||
protected $searchService;
|
||||
|
||||
/**
|
||||
* @param SearchService $searchService
|
||||
* @param CachedSearchService $searchService
|
||||
*/
|
||||
public function __construct(SearchService $searchService)
|
||||
public function __construct(CachedSearchService $searchService)
|
||||
{
|
||||
$this->searchService = $searchService;
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ abstract class AbstractIndexer implements IndexerInterface
|
|||
} catch (InvalidArgumentException $e) {
|
||||
// Nothing to do.
|
||||
}
|
||||
$this->generateSearchIdentifier($record);
|
||||
$this->generateSearchIdentifiers($record);
|
||||
$this->handleAbstract($record);
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,11 @@ abstract class AbstractIndexer implements IndexerInterface
|
|||
* @param array $record
|
||||
* @return void
|
||||
*/
|
||||
protected function generateSearchIdentifier(array &$record)
|
||||
protected function generateSearchIdentifiers(array &$record)
|
||||
{
|
||||
if (!isset($record['search_document'])) {
|
||||
$record['search_document_type'] = $this->getDocumentName();
|
||||
}
|
||||
if (!isset($record['search_identifier']) && isset($record['uid'])) {
|
||||
$record['search_identifier'] = $this->getDocumentName() . '-' . $record['uid'];
|
||||
}
|
||||
|
|
55
Classes/Domain/Search/CachedSearchService.php
Normal file
55
Classes/Domain/Search/CachedSearchService.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Codappix\SearchCore\Domain\Search;
|
||||
|
||||
use Codappix\SearchCore\Connection\SearchRequestInterface;
|
||||
use Codappix\SearchCore\Connection\SearchResultInterface;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
|
||||
|
||||
/**
|
||||
* Service: Cached Search
|
||||
* @package Codappix\SearchCore\Domain\Search
|
||||
*/
|
||||
class CachedSearchService implements SingletonInterface
|
||||
{
|
||||
protected $results = [];
|
||||
/**
|
||||
* @var SearchService
|
||||
*/
|
||||
protected $searchService;
|
||||
|
||||
/**
|
||||
* @param SearchService $searchService
|
||||
*/
|
||||
public function __construct(SearchService $searchService)
|
||||
{
|
||||
$this->searchService = $searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SearchRequestInterface $searchRequest
|
||||
* @return SearchResultInterface
|
||||
*/
|
||||
public function search(SearchRequestInterface $searchRequest): SearchResultInterface
|
||||
{
|
||||
$hash = $this->getHash($searchRequest);
|
||||
if (isset($this->results[$hash]) && $this->results[$hash] instanceof SearchResultInterface) {
|
||||
return $this->results[$hash];
|
||||
}
|
||||
return $this->results[$hash] = $this->searchService->search($searchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SearchRequestInterface $searchRequest
|
||||
* @return string
|
||||
*/
|
||||
protected function getHash(SearchRequestInterface $searchRequest): string
|
||||
{
|
||||
if (is_callable([$searchRequest, 'getRequestHash'])) {
|
||||
return (string)$searchRequest->getRequestHash();
|
||||
}
|
||||
return sha1(serialize($searchRequest));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
|
||||
data-namespace-typo3-fluid="true">
|
||||
|
||||
<f:link.typolink parameter="{result.plainData.search_page_typolink}">
|
||||
[{result.type}:{result.plainData.uid}] - {result.plainData.search_title}
|
||||
<f:link.typolink parameter="{result.search_page_typolink}">
|
||||
[{result.search_document_type}:{result.uid}] - {result.search_title}
|
||||
</f:link.typolink>
|
||||
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue