public static function FileLogTokenTest::tokenFindWithPrefix in File Log 8
Same name and namespace in other branches
- 2.0.x tests/src/Unit/FileLogTokenTest.php \Drupal\Tests\filelog\Unit\FileLogTokenTest::tokenFindWithPrefix()
Duplicate \Drupal\Core\Utility\Token::findWithPrefix as static.
Parameters
array $tokens: A keyed array of tokens, and their original raw form in the source text.
string $prefix: A textual string to be matched at the beginning of the token.
string $delimiter: A string containing the character that separates the prefix from the rest of the token. Defaults to ':'.
Return value
array An associative array of discovered tokens, with the prefix and delimiter stripped from the key.
See also
\Drupal\Core\Utility\Token::findWithPrefix()
File
- tests/
src/ Unit/ FileLogTokenTest.php, line 280
Class
- FileLogTokenTest
- Test the filelog message token integration.
Namespace
Drupal\Tests\filelog\UnitCode
public static function tokenFindWithPrefix(array $tokens, $prefix, $delimiter = ':') : array {
$results = [];
foreach ($tokens as $token => $raw) {
$parts = explode($delimiter, $token, 2);
if (count($parts) === 2 && $parts[0] === $prefix) {
$results[$parts[1]] = $raw;
}
}
return $results;
}