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