TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Backend\Search\Event;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Backend\Search\LiveSearch\SearchDemand\SearchDemand;
|
||||
|
||||
/**
|
||||
* PSR-14 event to add, change or remove data for the live search form
|
||||
*/
|
||||
final class BeforeLiveSearchFormIsBuiltEvent
|
||||
{
|
||||
private SearchDemand $searchDemand;
|
||||
|
||||
/**
|
||||
* @var array<non-empty-string, mixed>
|
||||
*/
|
||||
private array $additionalViewData = [];
|
||||
|
||||
/**
|
||||
* @param list<non-empty-string> $hints
|
||||
*/
|
||||
public function __construct(
|
||||
private array $hints,
|
||||
private readonly ServerRequestInterface $request,
|
||||
) {
|
||||
$this->searchDemand = SearchDemand::fromRequest($this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<non-empty-string>
|
||||
*/
|
||||
public function getHints(): array
|
||||
{
|
||||
return $this->hints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<non-empty-string> $hints
|
||||
*/
|
||||
public function setHints(array $hints): void
|
||||
{
|
||||
$this->hints = [];
|
||||
$this->addHints(...$hints);
|
||||
}
|
||||
|
||||
public function addHint(string $label): void
|
||||
{
|
||||
$this->addHints($label);
|
||||
}
|
||||
|
||||
public function addHints(string ...$labels): void
|
||||
{
|
||||
foreach ($labels as $label) {
|
||||
if ($label === '') {
|
||||
continue;
|
||||
}
|
||||
$this->hints[] = $label;
|
||||
}
|
||||
}
|
||||
|
||||
public function getRequest(): ServerRequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function getSearchDemand(): SearchDemand
|
||||
{
|
||||
return $this->searchDemand;
|
||||
}
|
||||
|
||||
public function setSearchDemand(SearchDemand $searchDemand): void
|
||||
{
|
||||
$this->searchDemand = $searchDemand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<non-empty-string, mixed>
|
||||
*/
|
||||
public function getAdditionalViewData(): array
|
||||
{
|
||||
return $this->additionalViewData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<non-empty-string, mixed> $viewData
|
||||
*/
|
||||
public function setAdditionalViewData(array $viewData): void
|
||||
{
|
||||
$this->additionalViewData = $viewData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Backend\Search\Event;
|
||||
|
||||
use TYPO3\CMS\Backend\Search\LiveSearch\SearchDemand\SearchDemand;
|
||||
|
||||
/**
|
||||
* PSR-14 event to modify the incoming input about which tables should be searched for within
|
||||
* the live search results. This allows adding additional DB tables to be excluded / ignored, to
|
||||
* further limit the search result on certain page IDs or to modify the search query altogether.
|
||||
*/
|
||||
final class BeforeSearchInDatabaseRecordProviderEvent
|
||||
{
|
||||
private array $ignoredTables = [];
|
||||
|
||||
public function __construct(
|
||||
private array $searchPageIds,
|
||||
private SearchDemand $searchDemand
|
||||
) {}
|
||||
|
||||
public function getSearchPageIds(): array
|
||||
{
|
||||
return $this->searchPageIds;
|
||||
}
|
||||
|
||||
public function setSearchPageIds(array $searchPageIds): void
|
||||
{
|
||||
$this->searchPageIds = $searchPageIds;
|
||||
}
|
||||
|
||||
public function getSearchDemand(): SearchDemand
|
||||
{
|
||||
return $this->searchDemand;
|
||||
}
|
||||
|
||||
public function setSearchDemand(SearchDemand $searchDemand): void
|
||||
{
|
||||
$this->searchDemand = $searchDemand;
|
||||
}
|
||||
|
||||
public function ignoreTable(string $table): void
|
||||
{
|
||||
$this->ignoredTables[] = $table;
|
||||
}
|
||||
|
||||
public function setIgnoredTables(array $tables): void
|
||||
{
|
||||
$this->ignoredTables = $tables;
|
||||
}
|
||||
|
||||
public function isTableIgnored(string $table): bool
|
||||
{
|
||||
return in_array($table, $this->ignoredTables, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getIgnoredTables(): array
|
||||
{
|
||||
return $this->ignoredTables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Backend\Search\Event;
|
||||
|
||||
use TYPO3\CMS\Backend\Search\LiveSearch\SearchDemand\SearchDemand;
|
||||
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
|
||||
|
||||
/**
|
||||
* PSR-14 event to modify the query builder instance for the live search
|
||||
*/
|
||||
final class ModifyConstraintsForLiveSearchEvent
|
||||
{
|
||||
/**
|
||||
* @param array<int, string|CompositeExpression> $constraints
|
||||
*/
|
||||
public function __construct(
|
||||
private array $constraints,
|
||||
private readonly string $table,
|
||||
private readonly SearchDemand $searchDemand
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array<int, string|CompositeExpression>
|
||||
*/
|
||||
public function getConstraints(): array
|
||||
{
|
||||
return $this->constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that we only add a single/multiple constraints
|
||||
* and do not allow to remove or override existing ones. This is
|
||||
* a safeguard to not overwrite security-related query constraints.
|
||||
*/
|
||||
public function addConstraints(string|CompositeExpression ...$constraints): void
|
||||
{
|
||||
foreach ($constraints as $constraint) {
|
||||
$this->addConstraint($constraint);
|
||||
}
|
||||
}
|
||||
|
||||
public function addConstraint(string|CompositeExpression $constraint): void
|
||||
{
|
||||
$this->constraints[] = $constraint;
|
||||
}
|
||||
|
||||
public function getTableName(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
public function getSearchDemand(): SearchDemand
|
||||
{
|
||||
return $this->searchDemand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Backend\Search\Event;
|
||||
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
|
||||
/**
|
||||
* PSR-14 event to modify the query builder instance for the live search
|
||||
*/
|
||||
final readonly class ModifyQueryForLiveSearchEvent
|
||||
{
|
||||
public function __construct(private QueryBuilder $queryBuilder, private string $table) {}
|
||||
|
||||
public function getQueryBuilder(): QueryBuilder
|
||||
{
|
||||
return $this->queryBuilder;
|
||||
}
|
||||
|
||||
public function getTableName(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Backend\Search\Event;
|
||||
|
||||
use TYPO3\CMS\Backend\Search\LiveSearch\ResultItem;
|
||||
|
||||
/**
|
||||
* PSR-14 event to modify as result item created by the live search
|
||||
*/
|
||||
final readonly class ModifyResultItemInLiveSearchEvent
|
||||
{
|
||||
public function __construct(private ResultItem $resultItem) {}
|
||||
|
||||
public function getResultItem(): ResultItem
|
||||
{
|
||||
return $this->resultItem;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user