InvalidMediaUrlException example

$entity = \is_array($entity) ? $entity : iterator_to_array($entity);
        $deserialized = parent::deserialize($config$definition$entity);
        $deserialized = \is_array($deserialized) ? $deserialized : iterator_to_array($deserialized);

        $url = $entity['url'] ?? null;

        if (empty($url)) {
            return $deserialized;
        }

        if (!filter_var($url, \FILTER_VALIDATE_URL)) {
            $deserialized['_error'] = new InvalidMediaUrlException($url);

            return $deserialized;
        }

        $media = null;
        if (isset($deserialized['id'])) {
            $media = $this->mediaRepository->search(new Criteria([$deserialized['id']]), Context::createDefaultContext())->first();
        }

        $isNew = $media === null;

        
Home | Imprint | This part of the site doesn't use cookies.