| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | public function validate($value, Constraint $constraint): void |
||
| 41 | { |
||
| 42 | $formats = $this->pool->getFormatNamesByContext($value->getContext()); |
||
| 43 | |||
| 44 | if (!$value instanceof GalleryInterface) { |
||
| 45 | $this->context->buildViolation('Invalid instance, expected GalleryInterface') |
||
| 46 | ->atPath('defaultFormat') |
||
| 47 | ->addViolation(); |
||
| 48 | } |
||
| 49 | |||
| 50 | $galleryDefaultFormat = $value->getDefaultFormat(); |
||
| 51 | |||
| 52 | if (MediaProviderInterface::FORMAT_REFERENCE !== $galleryDefaultFormat |
||
| 53 | && !($formats && \array_key_exists($galleryDefaultFormat, $formats))) { |
||
| 54 | $this->context->addViolation('invalid format'); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } |
||
| 58 |