private function replaceTokenCallback($matches)
{
$key = $matches[1];
/* Get tokens from tokensource and merge them with the
* tokens given directly via build file. This should be
* done a bit more elegantly
*/
if ($this->_alltokens === null) {
$this->_alltokens = array();
$count = count($this->_tokensources);
for ($i = 0; $i < $count; $i++) {
$source = $this->_tokensources[$i];
$this->_alltokens = array_merge($this->_alltokens, $source->getTokens());
}
$this->_alltokens = array_merge($this->_tokens, $this->_alltokens);
}
$tokens = $this->_alltokens;
$replaceWith = null;
$count = count($tokens);
for ($i = 0; $i < $count; $i++) {
if ($tokens[$i]->getKey() === $key) {
$replaceWith = $tokens[$i]->getValue();
}
}
if ($replaceWith === null) {
$replaceWith = $this->_beginToken . $key . $this->_endToken;
$this->log("No token defined for key \"" . $this->_beginToken . $key . $this->_endToken . "\"");
} else {
$this->log("Replaced \"" . $this->_beginToken . $key . $this->_endToken . "\" with \"" . $replaceWith . "\"");
}
return $replaceWith;
}