1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MultiDomain Query Field Class. |
4
|
|
|
* |
5
|
|
|
* @package UIType |
6
|
|
|
* |
7
|
|
|
* @copyright YetiForce S.A. |
8
|
|
|
* @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com) |
9
|
|
|
* @author Adrian Kon <[email protected]> |
10
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
11
|
|
|
* @author Radosław Skrzypczak <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace App\Conditions\QueryFields; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class MultiDomainField. |
18
|
|
|
*/ |
19
|
|
|
class MultiDomainField extends BaseField |
20
|
|
|
{ |
21
|
|
|
/** @var string Separator. */ |
22
|
|
|
protected $separator = ','; |
23
|
|
|
|
24
|
|
|
/** {@inheritdoc} */ |
25
|
|
|
public function getValue() |
26
|
|
|
{ |
27
|
|
|
$valueArray = array_filter(explode($this->separator, $this->value)); |
28
|
|
|
if (\in_array($this->operator, ['e', 'n'])) { |
29
|
|
|
foreach ($valueArray as $key => $value) { |
30
|
|
|
$valueArray[$key] = "{$this->separator}{$value}{$this->separator}"; |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
return $valueArray; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** {@inheritdoc} */ |
38
|
|
|
public function getOperator(): string |
39
|
|
|
{ |
40
|
|
|
return 'a' === $this->operator ? 'c' : $this->operator; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** {@inheritdoc} */ |
44
|
|
|
public function operatorE(): array |
45
|
|
|
{ |
46
|
|
|
return ['or like', $this->getColumnName(), $this->getValue()]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** {@inheritdoc} */ |
50
|
|
|
public function operatorN(): array |
51
|
|
|
{ |
52
|
|
|
return ['not like', $this->getColumnName(), $this->getValue()]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** {@inheritdoc} */ |
56
|
|
|
public function operatorC(): array |
57
|
|
|
{ |
58
|
|
|
return ['like', $this->getColumnName(), $this->getValue()]; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** {@inheritdoc} */ |
62
|
|
|
public function operatorK(): array |
63
|
|
|
{ |
64
|
|
|
return ['not like', $this->getColumnName(), $this->getValue()]; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|