File tree Expand file tree Collapse file tree 4 files changed +34
-75
lines changed Expand file tree Collapse file tree 4 files changed +34
-75
lines changed Original file line number Diff line number Diff line change 9
9
10
10
use Magento \Framework \Phrase ;
11
11
use Magento \Framework \Validator \AbstractValidator ;
12
+ use Magento \Framework \Validator \ValidatorInterface ;
12
13
use Opengento \Document \Api \Data \DocumentInterface ;
13
- use Opengento \Document \Model \Validator \Code as CodeValidator ;
14
14
15
15
final class Code extends AbstractValidator
16
16
{
17
17
/**
18
- * @var CodeValidator
18
+ * @var ValidatorInterface
19
19
*/
20
- private $ codeValidator ;
20
+ private $ validator ;
21
21
22
22
public function __construct (
23
- CodeValidator $ codeValidator
23
+ ValidatorInterface $ validator
24
24
) {
25
- $ this ->codeValidator = $ codeValidator ;
25
+ $ this ->validator = $ validator ;
26
26
}
27
27
28
28
public function isValid ($ value ): bool
29
29
{
30
30
$ this ->_clearMessages ();
31
31
32
32
if ($ value instanceof DocumentInterface) {
33
- if (!$ this ->codeValidator ->isValid ($ value ->getCode ())) {
34
- $ this ->_addMessages ($ this ->codeValidator ->getMessages ());
33
+ if (!$ this ->validator ->isValid ($ value ->getCode ())) {
34
+ $ this ->_addMessages ($ this ->validator ->getMessages ());
35
35
}
36
36
} else {
37
37
$ this ->_addMessages ([new Phrase ('The entity must implements "%1". ' , [DocumentInterface::class])]);
Original file line number Diff line number Diff line change 9
9
10
10
use Magento \Framework \Phrase ;
11
11
use Magento \Framework \Validator \AbstractValidator ;
12
+ use Magento \Framework \Validator \ValidatorInterface ;
12
13
use Opengento \Document \Api \Data \DocumentTypeInterface ;
13
- use Opengento \Document \Model \Validator \Code as CodeValidator ;
14
14
15
15
final class Code extends AbstractValidator
16
16
{
17
17
/**
18
- * @var CodeValidator
18
+ * @var ValidatorInterface
19
19
*/
20
- private $ codeValidator ;
20
+ private $ validator ;
21
21
22
22
public function __construct (
23
- CodeValidator $ codeValidator
23
+ ValidatorInterface $ validator
24
24
) {
25
- $ this ->codeValidator = $ codeValidator ;
25
+ $ this ->validator = $ validator ;
26
26
}
27
27
28
28
public function isValid ($ value ): bool
29
29
{
30
30
$ this ->_clearMessages ();
31
31
32
32
if ($ value instanceof DocumentTypeInterface) {
33
- if (!$ this ->codeValidator ->isValid ($ value ->getCode ())) {
34
- $ this ->_addMessages ($ this ->codeValidator ->getMessages ());
33
+ if (!$ this ->validator ->isValid ($ value ->getCode ())) {
34
+ $ this ->_addMessages ($ this ->validator ->getMessages ());
35
35
}
36
36
} else {
37
37
$ this ->_addMessages ([new Phrase ('The entity must implements "%1". ' , [DocumentTypeInterface::class])]);
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 27
27
</argument >
28
28
</arguments >
29
29
</type >
30
- <virtualType name =" Opengento\Document\Model\Validator\RegexCode" type =" Magento\Framework\Validator\Regex" >
31
- <arguments >
32
- <argument name =" pattern" xsi : type =" string" >/^[a-z]+[a-z0-9_]+$/</argument >
33
- </arguments >
34
- </virtualType >
35
- <type name =" Opengento\Document\Model\Validator\Code" >
36
- <arguments >
37
- <argument name =" regex" xsi : type =" object" >Opengento\Document\Model\Validator\RegexCode</argument >
38
- </arguments >
39
- </type >
40
30
<virtualType name =" Opengento\Document\Model\ResourceModel\DocumentType\RelationComposite" type =" Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite" >
41
31
<arguments >
42
32
<argument name =" relationProcessors" xsi : type =" array" >
43
33
<item name =" file" xsi : type =" object" >Opengento\Document\Model\ResourceModel\DocumentType\Relation\File</item >
44
34
</argument >
45
35
</arguments >
46
36
</virtualType >
37
+ <virtualType name =" Opengento\Document\Model\DocumentType\Validator\RegexCode" type =" Magento\Framework\Validator\Regex" >
38
+ <arguments >
39
+ <argument name =" pattern" xsi : type =" string" >/^[a-z]+[a-z0-9_]+$/</argument >
40
+ </arguments >
41
+ </virtualType >
42
+ <type name =" Opengento\Document\Model\DocumentType\Validator\Code" >
43
+ <arguments >
44
+ <argument name =" validator" xsi : type =" object" >Opengento\Document\Model\DocumentType\Validator\RegexCode</argument >
45
+ </arguments >
46
+ </type >
47
47
<virtualType name =" Opengento\Document\Model\DocumentType\Validator" type =" Opengento\Document\Model\Validator" >
48
48
<arguments >
49
49
<argument name =" validators" xsi : type =" array" >
64
64
</argument >
65
65
</arguments >
66
66
</virtualType >
67
+ <virtualType name =" Opengento\Document\Model\Document\Validator\RegexCode" type =" Magento\Framework\Validator\Regex" >
68
+ <arguments >
69
+ <argument name =" pattern" xsi : type =" string" >/^[a-z]+[a-z0-9_]+$/</argument >
70
+ </arguments >
71
+ </virtualType >
72
+ <type name =" Opengento\Document\Model\Document\Validator\Code" >
73
+ <arguments >
74
+ <argument name =" validator" xsi : type =" object" >Opengento\Document\Model\Document\Validator\RegexCode</argument >
75
+ </arguments >
76
+ </type >
67
77
<virtualType name =" Opengento\Document\Model\Document\Validator" type =" Opengento\Document\Model\Validator" >
68
78
<arguments >
69
79
<argument name =" validators" xsi : type =" array" >
You can’t perform that action at this time.
0 commit comments