Add is_var argument for accessor

This commit is contained in:
bzick 2015-06-01 23:20:02 +03:00
parent bf0a0ffedc
commit ec890cc819

View File

@ -811,8 +811,7 @@ class Template extends Render
} }
} }
} elseif ($tokens->is('$')) { } elseif ($tokens->is('$')) {
$is_var = false; $code = $unary . $this->parseAccessor($tokens, $is_var);
$code = $unary . $this->parseAccessor($tokens);
} elseif ($tokens->is(Tokenizer::MACRO_INCDEC)) { } elseif ($tokens->is(Tokenizer::MACRO_INCDEC)) {
if($this->_options & Fenom::FORCE_VERIFY) { if($this->_options & Fenom::FORCE_VERIFY) {
$var = $this->parseVariable($tokens); $var = $this->parseVariable($tokens);
@ -958,14 +957,20 @@ class Template extends Render
/** /**
* Parse accessor * Parse accessor
* @param Tokenizer $tokens * @param Tokenizer $tokens
* @param bool $is_var
* @return string * @return string
*/ */
public function parseAccessor(Tokenizer $tokens) public function parseAccessor(Tokenizer $tokens, &$is_var = false)
{ {
$accessor = $tokens->need('$')->next()->need('.')->next()->current(); $accessor = $tokens->need('$')->next()->need('.')->next()->current();
$callback = $this->getStorage()->getAccessor($accessor); $parser = $this->getStorage()->getAccessor($accessor);
if($callback) { $is_var = false;
return call_user_func($callback, $tokens->next(), $this); if($parser) {
if(is_string($parser)) {
return call_user_func_array($parser, array($tokens->next(), $this, &$is_var));
} else {
return call_user_func_array($parser['parser'], array($parser['accessor'], $tokens->next(), $this, &$is_var));
}
} else { } else {
throw new \RuntimeException("Unknown accessor '$accessor'"); throw new \RuntimeException("Unknown accessor '$accessor'");
} }