-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Always use SolrSearchResultItem to wrap a single object from se…
…arch engine results. BREAKING CHANGE: `getResultItems` method will always return `array<SolrSearchResultItem>` no matter item type or highlighting.
- Loading branch information
1 parent
21fdc5c
commit 00ebe1d
Showing
6 changed files
with
125 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
lib/RoadizCoreBundle/src/SearchEngine/SolrSearchResultItem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RZ\Roadiz\CoreBundle\SearchEngine; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use Symfony\Component\Serializer\Attribute\Groups; | ||
|
||
/** | ||
* @template T of object | ||
*/ | ||
#[ApiResource( | ||
stateless: true, | ||
)] | ||
final class SolrSearchResultItem | ||
{ | ||
/** | ||
* @param T $item | ||
* @param array<string, array<string>> $highlighting | ||
*/ | ||
public function __construct( | ||
protected readonly object $item, | ||
protected readonly array $highlighting = [] | ||
) { | ||
} | ||
|
||
/** | ||
* @return T | ||
*/ | ||
#[ApiProperty] | ||
#[Groups(['get'])] | ||
public function getItem(): object | ||
{ | ||
return $this->item; | ||
} | ||
|
||
/** | ||
* @return array<string, array<string>> | ||
*/ | ||
#[ApiProperty] | ||
#[Groups(['get'])] | ||
public function getHighlighting(): array | ||
{ | ||
return $this->highlighting; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters