本文整理汇总了PHP中Token::setKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::setKey方法的具体用法?PHP Token::setKey怎么用?PHP Token::setKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::setKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readToken
/**
* Reads the next token from the INI file
*
* @throws IOException On error
* @return Token
*/
function readToken()
{
if ($this->file === null) {
throw new BuildException("No File set for IniFileTokenReader");
}
static $tokens = null;
if ($tokens === null) {
$tokens = array();
$arr = parse_ini_file($this->file->getAbsolutePath(), true);
if ($this->section === null) {
foreach ($arr as $sec_name => $values) {
foreach ($arr[$sec_name] as $key => $value) {
$tok = new Token();
$tok->setKey($key);
$tok->setValue($value);
$tokens[] = $tok;
}
}
} else {
if (isset($arr[$this->section])) {
foreach ($arr[$this->section] as $key => $value) {
$tok = new Token();
$tok->setKey($key);
$tok->setValue($value);
$tokens[] = $tok;
}
}
}
}
if (count($tokens) > 0) {
return array_pop($tokens);
} else {
return null;
}
}
示例2: _initialize
/**
* Initializes tokens and loads the replacee-replacer hashtable.
* This method is only called when this filter is used through
* a <filterreader> tag in build file.
*/
private function _initialize()
{
$params = $this->getParameters();
if ($params !== null) {
for ($i = 0; $i < count($params); $i++) {
if ($params[$i] !== null) {
$type = $params[$i]->getType();
if ($type === "tokenchar") {
$name = $params[$i]->getName();
if ($name === "begintoken") {
$this->_beginToken = substr($params[$i]->getValue(), 0, 1);
} else {
if ($name === "endtoken") {
$this->_endToken = substr($params[$i]->getValue(), 0, 1);
}
}
} else {
if ($type === "token") {
$name = $params[$i]->getName();
$value = $params[$i]->getValue();
$tok = new Token();
$tok->setKey($name);
$tok->setValue($value);
array_push($this->_tokens, $tok);
} else {
if ($type === "tokensource") {
// Store data from nested tags in local array
$arr = array();
$subparams = $params[$i]->getParams();
$count = count($subparams);
for ($i = 0; $i < $count; $i++) {
$arr[$subparams[$i]->getName()] = $subparams[$i]->getValue();
}
// Create TokenSource
$tokensource = new TokenSource();
if (isset($arr["classname"])) {
$tokensource->setClassname($arr["classname"]);
}
// Copy other parameters 1:1 to freshly created TokenSource
foreach ($arr as $key => $value) {
if (strtolower($key) === "classname") {
continue;
}
$param = $tokensource->createParam();
$param->setName($key);
$param->setValue($value);
}
$this->_tokensources[] = $tokensource;
}
}
}
}
}
}
}
示例3: processSection
/**
* Process an individual section
*
* @param array $section
*/
protected function processSection(array $section)
{
foreach ($section as $key => $value) {
$tok = new Token();
$tok->setKey($key);
$tok->setValue($value);
$this->tokens[] = $tok;
}
}