1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @category Brownie/BpmOnline |
4
|
|
|
* @author Brownie <[email protected]> |
5
|
|
|
* @license https://opensource.org/licenses/MIT |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Brownie\BpmOnline\DataService\Contract; |
9
|
|
|
|
10
|
|
|
use Brownie\BpmOnline\DataService\Contract; |
11
|
|
|
use Brownie\BpmOnline\DataService\Column\ColumnFilter; |
12
|
|
|
use Brownie\BpmOnline\Exception\ValidateException; |
13
|
|
|
use Brownie\BpmOnline\DataService\Response\DeleteContract as ResponseDeleteContract; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* DeleteContract Data Contract. |
17
|
|
|
*/ |
18
|
|
|
class DeleteContract extends Contract |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Column filter. |
23
|
|
|
* |
24
|
|
|
* @var ColumnFilter |
25
|
|
|
*/ |
26
|
|
|
private $filter; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Sets the input values. |
30
|
|
|
* |
31
|
|
|
* @param string $rootSchemaName The name of the root schema object. |
32
|
|
|
*/ |
33
|
8 |
|
public function __construct($rootSchemaName) |
34
|
|
|
{ |
35
|
8 |
|
parent::__construct([ |
36
|
8 |
|
'rootSchemaName' => $rootSchemaName, |
37
|
8 |
|
'operationType' => Contract::DELETE, |
38
|
8 |
|
'contractType' => Contract::DELETE_QUERY, |
39
|
|
|
]); |
40
|
8 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Adding query filter to contract. |
44
|
|
|
* |
45
|
|
|
* @param ColumnFilter $columnFilter Column filter. |
46
|
|
|
* |
47
|
|
|
* @return self |
48
|
|
|
*/ |
49
|
2 |
|
public function addFilter(ColumnFilter $columnFilter) |
50
|
|
|
{ |
51
|
2 |
|
$this->filter = $columnFilter; |
52
|
2 |
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Returns data as an associative array. |
57
|
|
|
* |
58
|
|
|
* @return array |
59
|
|
|
*/ |
60
|
2 |
|
public function toArray() |
61
|
|
|
{ |
62
|
2 |
|
$filter = []; |
63
|
2 |
|
if (!empty($this->filter)) { |
64
|
1 |
|
$filter = $this->filter->toArray(); |
65
|
|
|
} |
66
|
|
|
return [ |
67
|
2 |
|
'RootSchemaName' => $this->getRootSchemaName(), |
68
|
2 |
|
'OperationType' => $this->getOperationType(), |
69
|
2 |
|
'Filters' => $filter, |
70
|
|
|
]; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Validates contract data, throws an exception in case of an error. |
75
|
|
|
* |
76
|
|
|
* @throws ValidateException |
77
|
|
|
*/ |
78
|
2 |
|
public function validate() |
79
|
|
|
{ |
80
|
2 |
|
if ((3 != $this->getOperationType()) || empty($this->filter)) { |
81
|
1 |
|
throw new ValidateException('Invalid contract arguments.'); |
82
|
|
|
} |
83
|
1 |
|
$this->filter->validate(); |
84
|
1 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Returns the response of the performance contract. |
88
|
|
|
* |
89
|
|
|
* @param string $rawResponse Raw response. |
90
|
|
|
* |
91
|
|
|
* @return ResponseDeleteContract |
92
|
|
|
*/ |
93
|
1 |
|
public function getResponse($rawResponse) |
94
|
|
|
{ |
95
|
1 |
|
return new ResponseDeleteContract($rawResponse); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|