|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\Service\PurchaseFlow; |
|
15
|
|
|
|
|
16
|
|
|
use Eccube\Entity\ItemHolderInterface; |
|
17
|
|
|
|
|
18
|
|
|
class PurchaseFlowResult |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var ItemHolderInterface */ |
|
21
|
|
|
private $itemHolder; |
|
22
|
|
|
|
|
23
|
|
|
/** @var ProcessResult[] */ |
|
24
|
|
|
private $processResults = []; |
|
25
|
|
|
|
|
26
|
|
|
/** @var ValidateErrorHandlerInterface[] */ |
|
27
|
|
|
private $validateErrorHandlers = []; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
295 |
|
* PurcahseFlowResult constructor. |
|
32
|
|
|
* |
|
33
|
295 |
|
* @param ItemHolderInterface $itemHolder |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(ItemHolderInterface $itemHolder) |
|
36
|
268 |
|
{ |
|
37
|
|
|
$this->itemHolder = $itemHolder; |
|
38
|
268 |
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function addProcessResult(ProcessResult $processResult, ValidateErrorHandlerInterface $validateErrorHandler = null) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->processResults[] = $processResult; |
|
43
|
|
|
if ($validateErrorHandler) { |
|
44
|
|
|
$this->validateErrorHandlers[] = $validateErrorHandler; |
|
45
|
|
|
} |
|
46
|
112 |
|
} |
|
47
|
111 |
|
|
|
48
|
112 |
|
/** |
|
49
|
|
|
* @return array|ProcessResult[] |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getErrors() |
|
52
|
|
|
{ |
|
53
|
|
|
return array_filter($this->processResults, function (ProcessResult $processResult) { |
|
54
|
|
|
return $processResult->isError(); |
|
55
|
|
|
}); |
|
56
|
80 |
|
} |
|
57
|
79 |
|
|
|
58
|
80 |
|
/** |
|
59
|
|
|
* @return array|ProcessResult[] |
|
60
|
|
|
*/ |
|
61
|
112 |
|
public function getWarning() |
|
62
|
|
|
{ |
|
63
|
112 |
|
return array_filter($this->processResults, function (ProcessResult $processResult) { |
|
64
|
|
|
return $processResult->isWarning(); |
|
65
|
|
|
}); |
|
66
|
56 |
|
} |
|
67
|
|
|
|
|
68
|
56 |
|
public function hasError() |
|
69
|
|
|
{ |
|
70
|
|
|
return !empty($this->getErrors()); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function hasWarning() |
|
74
|
|
|
{ |
|
75
|
|
|
return !empty($this->getWarning()); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return ValidateErrorHandlerInterface[] |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getValidateErrorHandlers() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->validateErrorHandlers; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|