Sulu\Bundle\MediaBundle\Markup\MediaTag::createMarkupForAttributes PHP Method

createMarkupForAttributes() private method

For given attributes of a tag, this method constructs the actual markup.
private createMarkupForAttributes ( $attributes, $medias ) : string
$attributes array The attributes of a media tag
$medias array The array of medias corresponding the the ids of all passed attributes
return string The markup for the given attributes
    private function createMarkupForAttributes($attributes, $medias)
    {
        if (!array_key_exists($attributes['id'], $medias)) {
            if (array_key_exists('content', $attributes)) {
                return $attributes['content'];
            }
            if (array_key_exists('title', $attributes)) {
                return $attributes['title'];
            }
            return '';
        }
        $media = $medias[$attributes['id']];
        $title = !empty($attributes['title']) ? $attributes['title'] : $media['title'];
        $text = !empty($attributes['content']) ? $attributes['content'] : $media['title'];
        if (empty($title)) {
            $title = $media['defaultTitle'];
        }
        return sprintf('<a href="%s" title="%s">%s</a>', $media['url'], $title, $text);
    }