function Interpolator::findTokens
Same name in other branches
- 9 composer/Plugin/Scaffold/Interpolator.php \Drupal\Composer\Plugin\Scaffold\Interpolator::findTokens()
- 10 composer/Plugin/Scaffold/Interpolator.php \Drupal\Composer\Plugin\Scaffold\Interpolator::findTokens()
- 11.x composer/Plugin/Scaffold/Interpolator.php \Drupal\Composer\Plugin\Scaffold\Interpolator::findTokens()
Finds all of the tokens in the provided message.
Parameters
string $message: String with tokens.
Return value
string[] map of token to key, e.g. {{key}} => key
1 call to Interpolator::findTokens()
- Interpolator::replacements in composer/
Plugin/ Scaffold/ Interpolator.php - Finds the tokens that exist in a message and builds a replacement array.
File
-
composer/
Plugin/ Scaffold/ Interpolator.php, line 144
Class
- Interpolator
- Injects config values from an associative array into a string.
Namespace
Drupal\Composer\Plugin\ScaffoldCode
protected function findTokens($message) {
$reg_ex = '#' . $this->startToken . '([a-zA-Z0-9._-]+)' . $this->endToken . '#';
if (!preg_match_all($reg_ex, $message, $matches, PREG_SET_ORDER)) {
return [];
}
$tokens = [];
foreach ($matches as $matchSet) {
list($sourceText, $key) = $matchSet;
$tokens[$sourceText] = $key;
}
return $tokens;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.