public function replaceAllInText($text)
    {
        $uriInfo = [];

        // Collects all µlink URIs present in the text and stores them
        // in an array keyed by their offset.
        foreach ($this->getURIPatterns() as $pattern) {
            $matches = [];

            if (preg_match_all($pattern, $text, $matches,  PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
                foreach ($matches as $match) {
                    list($uri, $offset) = $match[0];

                    $uriInfo[$offset] = [
                        'uri'   => $uri,
                        'type'  => $match['type'][0],
                        'id'    => $match['id'][0],
                    ];
                }
            }
        }

        // Sorts collected URIs by descending offset to start replacements
        // by the end of the text, ensuring in this way that the next offsets
        // will stay valid after each replacement.
        krsort($uriInfo);

        // Dispatches an event to allow some alterations of URIs information
        // before transform them in standard URLs.
        $event = new EntityLinkFilterEvent($uriInfo);
        $this->eventDispatcher->dispatch(EntityLinkFilterEvent::EVENT_BEFORE_FILTER, $event);

        // Replaces µlink URIs by standard URLs.
        foreach ($event->getURIInfo() as $offset => $info) {
            // Something inserted a new entry!?
            // Ok, just ignore it.
            if (!isset($uriInfo[$offset])) {
                continue;
            }
            // Something altered the original URI!?
            // Ok, just retrieve the text's version for the next.
            if ($info['uri'] !== $uriInfo[$offset]['uri']) {
                $info['uri'] = $uriInfo[$offset]['uri'];
            }

            try {
                $uri = url($this->getEntityPath($info['type'], $info['id']));
            } catch (\Exception $e) {
                $uri = '#'; // Silent fail for frontend
            }

            $text = substr_replace($text, $uri, $offset, strlen($info['uri']));
        }

        return $text;
    }