function AutoLoginUrlCreate::convertText in Auto Login URL 8
Same name and namespace in other branches
- 2.x src/AutoLoginUrlCreate.php \Drupal\auto_login_url\AutoLoginUrlCreate::convertText()
Convert a whole text (E.g. mail with autologin links).
Parameters
int $uid: User id.
string $text: Text to change links to.
Return value
string The text with changed links.
File
- src/
AutoLoginUrlCreate.php, line 109
Class
Namespace
Drupal\auto_login_urlCode
function convertText($uid, $text) {
global $base_root;
// A pattern to convert links, but not images.
// I am not very sure about that.
$pattern = '/' . str_replace('/', '\\/', $base_root) . '\\/[^\\s^"^\']*/';
// Create a new object and pass the uid.
$current_conversion = new AutoLoginUrlConvertTextClass($uid);
// Replace text with regex/callback.
$text = preg_replace_callback($pattern, [
&$current_conversion,
'replace',
], $text);
return $text;
}