protected function legalizeLinkParameters(array $linkParameters)
    {
        $parameters = [];

        if (isset($linkParameters['href'])) {
            $parameters['href'] = $linkParameters['href'];
        }

        if (isset($linkParameters['resourceFragmentIdentifier'])) {
            $parameters['anchor_name'] = $linkParameters['resourceFragmentIdentifier'];
        }

        if (isset($linkParameters['class'])) {
            $parameters['class'] = $linkParameters['class'];
        }

        if (isset($linkParameters['id'])) {
            $parameters['xhtml:id'] = $linkParameters['id'];
        }

        if (isset($linkParameters['target'])) {
            $parameters['target'] = $linkParameters['target'];
        }

        if (isset($linkParameters['title'])) {
            $parameters['xhtml:title'] = $linkParameters['title'];
        }

        if ($linkParameters['resourceType'] !== null) {
            switch ($linkParameters['resourceType']) {
                case EmbedToHtml5::LINK_RESOURCE_CONTENT:
                    $parameters['object_id'] = $linkParameters['resourceId'];
                    break;

                case EmbedToHtml5::LINK_RESOURCE_LOCATION:
                    $parameters['node_id'] = $linkParameters['resourceId'];
                    break;

                case EmbedToHtml5::LINK_RESOURCE_URL:
                    $parameters['url_id'] = $linkParameters['resourceId'];
                    break;

                default:
                    // Don't set anything by default
            }
        }

        return $parameters;
    }