protected function extractLinkParameters(DOMElement $embed)
    {
        $links = $embed->getElementsByTagName('ezlink');

        if ($links->length !== 1) {
            return null;
        }

        /** @var \DOMElement $link */
        $link = $links->item(0);

        $hrefResolved = $link->getAttribute('href_resolved');

        if (empty($hrefResolved)) {
            $this->logger->error('Could not create link parameters: resolved embed link is missing');

            return null;
        }

        $href = $link->getAttribute('xlink:href');
        $target = $link->getAttribute('xlink:show');
        $target = $this->mapLinkTarget($target);
        $title = $link->getAttribute('xlink:title');
        $id = $link->getAttribute('xml:id');
        $class = $link->getAttribute('ezxhtml:class');

        if (strpos($href, 'ezcontent://') === 0) {
            $resourceType = 'CONTENT';
            $resourceId = substr($href, strlen('ezcontent://'));
        } elseif (strpos($href, 'ezlocation://') === 0) {
            $resourceType = 'LOCATION';
            $resourceId = substr($href, strlen('ezlocation://'));
        } else {
            // If link is not Content or Location based, it must be an URL (Url field type) link
            $resourceType = 'URL';
            // ATM there is no way to find out the URL's ID here.
            // The whole implementation is actually lacking:
            // UrlService which would be used here and in Url and RichText field type's external storage,
            // but also for admin UI.
            // With it resolving Url links in the RichText external storage when loading should be removed.
            // Data should be returned as is, and resolving should happen when needed, which is:
            // - in Link converter for links
            // - here for embeds
            $resourceId = null;
        }

        $fragmentPosition = isset($resourceId) ? strpos($resourceId, '#') : false;

        if ($fragmentPosition !== false) {
            $resourceFragmentIdentifier = substr($resourceId, $fragmentPosition + 1);
            $resourceId = substr($resourceId, 0, $fragmentPosition);
        }

        $parameters = [
            'href' => $hrefResolved,
            'resourceType' => $resourceType,
            'resourceId' => $resourceId,
            'wrapped' => $this->isLinkWrapped($embed),
        ];

        if (!empty($resourceFragmentIdentifier)) {
            $parameters['resourceFragmentIdentifier'] = $resourceFragmentIdentifier;
        }

        if (!empty($target)) {
            $parameters['target'] = $target;
        }

        if (!empty($title)) {
            $parameters['title'] = $title;
        }

        if (!empty($id)) {
            $parameters['id'] = $id;
        }

        if (!empty($class)) {
            $parameters['class'] = $class;
        }

        return $parameters;
    }