You are here

protected function AlinkPostRenderer::addExistingLink in Alinks 8

Check to see if keywords on this object match the passed word.

Parameters

\Drupal\alinks\Entity\Keyword $word: An individual keyword.

1 call to AlinkPostRenderer::addExistingLink()
AlinkPostRenderer::replace in src/AlinkPostRenderer.php
Load the content and replace the matched strings with automatic links.

File

src/AlinkPostRenderer.php, line 283

Class

AlinkPostRenderer
Class AlinkPostRenderer.

Namespace

Drupal\alinks

Code

protected function addExistingLink(Keyword $word) {
  $this->existingLinks[$word
    ->getUrl()] = TRUE;
  $this->keywords = array_filter($this->keywords, function ($keyword) use ($word) {
    if ($keyword
      ->getText() == $word
      ->getText()) {
      return FALSE;
    }
    if ($keyword
      ->getUrl() == $word
      ->getUrl()) {
      return FALSE;
    }
    return TRUE;
  });
}