1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://github.com/flipbox/salesforce/blob/master/LICENSE.md |
6
|
|
|
* @link https://github.com/flipbox/salesforce |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Flipbox\Salesforce\Resources; |
10
|
|
|
|
11
|
|
|
use Flipbox\Relay\Salesforce\Builder\Resources\Search as SearchBuilder; |
12
|
|
|
use Flipbox\Salesforce\Connections\ConnectionInterface; |
13
|
|
|
use Flipbox\Salesforce\Salesforce; |
14
|
|
|
use Psr\Http\Message\ResponseInterface; |
15
|
|
|
use Psr\Log\LoggerInterface; |
16
|
|
|
use Psr\SimpleCache\CacheInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Flipbox Factory <[email protected]> |
20
|
|
|
* @since 3.0.0 |
21
|
|
|
*/ |
22
|
|
|
class Search |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* The resource name |
26
|
|
|
*/ |
27
|
|
|
const SALESFORCE_RESOURCE = 'search'; |
28
|
|
|
|
29
|
|
|
/******************************************* |
30
|
|
|
* QUERY |
31
|
|
|
*******************************************/ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param ConnectionInterface|null $connection |
35
|
|
|
* @param CacheInterface|null $cache |
36
|
|
|
* @param string $search |
37
|
|
|
* @param LoggerInterface|null $logger |
38
|
|
|
* @param array $config |
39
|
|
|
* @return ResponseInterface |
40
|
|
|
*/ |
41
|
|
|
public static function search( |
42
|
|
|
string $search, |
43
|
|
|
ConnectionInterface $connection = null, |
44
|
|
|
CacheInterface $cache = null, |
45
|
|
|
LoggerInterface $logger = null, |
46
|
|
|
array $config = [] |
47
|
|
|
): ResponseInterface { |
48
|
|
|
return static::searchRelay( |
49
|
|
|
$search, |
50
|
|
|
$connection, |
51
|
|
|
$cache, |
52
|
|
|
$logger, |
53
|
|
|
$config |
54
|
|
|
)(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param ConnectionInterface|null $connection |
59
|
|
|
* @param CacheInterface|null $cache |
60
|
|
|
* @param string $search |
61
|
|
|
* @param LoggerInterface|null $logger |
62
|
|
|
* @param array $config |
63
|
|
|
* @return callable |
64
|
|
|
*/ |
65
|
|
|
public static function searchRelay( |
66
|
|
|
string $search, |
67
|
|
|
ConnectionInterface $connection = null, |
68
|
|
|
CacheInterface $cache = null, |
69
|
|
|
LoggerInterface $logger = null, |
70
|
|
|
array $config = [] |
71
|
|
|
): callable { |
72
|
|
|
$connection = $connection ?: Salesforce::getConnection(); |
73
|
|
|
|
74
|
|
|
$builder = new SearchBuilder( |
75
|
|
|
$connection, |
76
|
|
|
$connection, |
77
|
|
|
$cache ?: Salesforce::getCache(), |
78
|
|
|
$search, |
79
|
|
|
$logger ?: Salesforce::getLogger(), |
80
|
|
|
$config |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
return $builder->build(); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|