You are here

public function AutoLoginUrlConvertTextClass::replace in Auto Login URL 2.x

Same name and namespace in other branches
  1. 8 src/AutoLoginUrlConvertTextClass.php \Drupal\auto_login_url\AutoLoginUrlConvertTextClass::replace()

Replace each link in the text.

Parameters

array $matches: Matches array.

Return value

string Converted URL.

File

src/AutoLoginUrlConvertTextClass.php, line 31

Class

AutoLoginUrlConvertTextClass
Class AutoLoginUrlConvertTextClass.

Namespace

Drupal\auto_login_url

Code

public function replace(array $matches) {

  // Make a new search to check that the link is not image.
  // I know, not very clean.
  $pattern = '/(\\.jpg|\\.gif|\\.png)/';
  preg_match($pattern, $matches[0], $new_matches);
  if (count($new_matches) > 0) {
    return $matches[0];
  }
  else {
    return \Drupal::service('auto_login_url.create')
      ->create($this->uid, $matches[0], TRUE);
  }
}