| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function isValid($value, array $parameters) |
||
| 26 | { |
||
| 27 | |||
| 28 | if (in_array($value, [null, ''])) { |
||
| 29 | return true; |
||
| 30 | } |
||
| 31 | |||
| 32 | $data = $parameters[0]; |
||
| 33 | $field = $parameters[1]; |
||
| 34 | $manyEntity = $data->getDefinition()->getSubTypeField($field, 'many', 'entity'); |
||
| 35 | $validIds = array_keys($data->getIdToNameMap($manyEntity, null)); |
||
| 36 | $candidateIds = array_column($value, 'id'); |
||
| 37 | |||
| 38 | foreach ($candidateIds as $candidateId) { |
||
| 39 | if (!in_array($candidateId, $validIds)) { |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return true; |
||
| 45 | } |
||
| 46 | |||
| 56 |