Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
25 | 6 | public function isValid($value, array $parameters) |
|
26 | { |
||
27 | |||
28 | 6 | if (in_array($value, [null, ''])) { |
|
29 | 5 | return true; |
|
30 | } |
||
31 | |||
32 | 6 | $data = $parameters[0]; |
|
33 | 6 | $field = $parameters[1]; |
|
34 | 6 | $definition = $data->getDefinition(); |
|
35 | 6 | $paramsOperators = ['id' => '=']; |
|
36 | 6 | $referenceEntity = $definition->getSubTypeField($field, 'reference', 'entity'); |
|
37 | 6 | $table = $definition->getService()->getData($referenceEntity)->getDefinition()->getTable(); |
|
38 | 6 | $amount = $data->countBy($table, ['id' => $value], $paramsOperators, false); |
|
39 | 6 | return $amount > 0; |
|
40 | } |
||
41 | |||
51 |