本文整理汇总了PHP中Helpers::checkCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::checkCallback方法的具体用法?PHP Helpers::checkCallback怎么用?PHP Helpers::checkCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::checkCallback方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Compiles template to PHP code.
* @return string
*/
public function compile($name)
{
foreach ($this->onCompile ?: array() as $cb) {
call_user_func(Helpers::checkCallback($cb), $this);
}
$this->onCompile = array();
$source = $this->getLoader()->getContent($name);
try {
$tokens = $this->getParser()->setContentType($this->contentType)->parse($source);
$code = $this->getCompiler()->setContentType($this->contentType)->compile($tokens);
if (preg_match('#^\\S{5,100}\\z#', $name)) {
$code = "<?php\n// source: {$name}\n?>" . $code;
}
} catch (\Exception $e) {
$e = $e instanceof CompileException ? $e : new CompileException("Thrown exception '{$e->getMessage()}'", NULL, $e);
throw $e->setSource($source, $this->getCompiler()->getLine(), $name);
}
$code = Helpers::optimizePhp($code);
return $code;
}
示例2: compile
/**
* Compiles template to PHP code.
* @return string
*/
public function compile($name)
{
foreach ($this->onCompile ?: [] as $cb) {
call_user_func(Helpers::checkCallback($cb), $this);
}
$this->onCompile = [];
$source = $this->getLoader()->getContent($name);
try {
$tokens = $this->getParser()->setContentType($this->contentType)->parse($source);
$code = $this->getCompiler()->setContentType($this->contentType)->compile($tokens, $this->getTemplateClass($name));
} catch (\Exception $e) {
if (!$e instanceof CompileException) {
$e = new CompileException("Thrown exception '{$e->getMessage()}'", NULL, $e);
}
$line = isset($tokens) ? $this->getCompiler()->getLine() : $this->getParser()->getLine();
throw $e->setSource($source, $line, $name);
}
if (!preg_match('#\\n|\\?#', $name)) {
$code = "<?php\n// source: {$name}\n?>" . $code;
}
$code = PhpHelpers::reformatCode($code);
return $code;
}
示例3: invokeFilter
/**
* Call a run-time filter.
* @param string filter name
* @param array arguments
* @return mixed
*/
public function invokeFilter($name, array $args)
{
$lname = strtolower($name);
if (!isset($this->filters[$lname])) {
$args2 = $args;
array_unshift($args2, $lname);
foreach ($this->filters[NULL] as $filter) {
$res = call_user_func_array(Helpers::checkCallback($filter), $args2);
if ($res !== NULL) {
return $res;
} elseif (isset($this->filters[$lname])) {
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
}
$hint = ($t = Helpers::getSuggestion(array_keys($this->filters), $name)) ? ", did you mean '{$t}'?" : '.';
throw new \LogicException("Filter '{$name}' is not defined{$hint}");
}
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
示例4: invokeFilter
/**
* Call a run-time filter.
* @param string filter name
* @param array arguments
* @return mixed
*/
public function invokeFilter($name, array $args)
{
$lname = strtolower($name);
if (!isset($this->filters[$lname])) {
$args2 = $args;
array_unshift($args2, $lname);
foreach ($this->filters[NULL] as $filter) {
$res = call_user_func_array(Helpers::checkCallback($filter), $args2);
if ($res !== NULL) {
return $res;
} elseif (isset($this->filters[$lname])) {
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
}
throw new \LogicException("Filter '{$name}' is not defined.");
}
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
示例5: __call
/**
* Call a template run-time filter. Do not call directly.
* @param string filter name
* @param array arguments
* @return mixed
*/
public function __call($name, $args)
{
$lname = strtolower($name);
if (!isset($this->filters[$lname])) {
$args2 = $args;
array_unshift($args2, $lname);
foreach ($this->filters[NULL] as $filter) {
$res = call_user_func_array(Helpers::checkCallback($filter), $args2);
if ($res !== NULL) {
return $res;
} elseif (isset($this->filters[$lname])) {
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
}
return parent::__call($name, $args);
}
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}