This repository has been archived by the owner on Jul 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchProcessor.php
51 lines (46 loc) · 1.94 KB
/
SearchProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
/*
* This file is part of the RollerworksSearch package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Rollerworks\Component\Search\Processor;
use Psr\Http\Message\ServerRequestInterface as ServerRequest;
/**
* A SearchProcessor handles a search provided with a Request.
*
* @author Sebastiaan Stok <[email protected]>
*/
interface SearchProcessor
{
/**
* Process the request for a search operation.
*
* A processor is expected to follow a few simple conventions:
*
* * The processor must return a SearchPayload with the results of the processing.
* * A new condition must mark the payload as changed.
* * The SearchPayload#searchCode property is expected to contain an input processable
* search-condition (like JSON) which can be used safely within an URI, when the condition is valid.
* * The client may provide the input format using the `format` query/parsedBody information, but the
* processor's implementation can choose to ignore this.
*
* A Processor must first check if a new condition is provided and fall-back
* to the `searchCode` as active condition.
*
* Note: The $request argument needs to accept at least ServerRequest,
* other formats are of the implementations choice. The interface actor
* must be informed about accepted request formats.
*
* @param ServerRequest|mixed $request The Request (object) to extract information from
* @param ProcessorConfig $config Input processor configuration
*
* @return SearchPayload The SearchPayload contains READ-ONLY information about
* the processing, and 'when there were no errors' the SearchCondition
*/
public function processRequest($request, ProcessorConfig $config): SearchPayload;
}