本文整理汇总了PHP中Zend_View_Abstract::getHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_View_Abstract::getHelper方法的具体用法?PHP Zend_View_Abstract::getHelper怎么用?PHP Zend_View_Abstract::getHelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_View_Abstract
的用法示例。
在下文中一共展示了Zend_View_Abstract::getHelper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function _compile_compiler_tag($tagCommand, $tagArgs, &$output)
{
//We first try to use Smarty's own functionality to parse the tag
$found = parent::_compile_compiler_tag($tagCommand, $tagArgs, $output);
if ($found === false) {
try {
//Check if helper exists and create output
$this->zendView->getHelper($tagCommand);
$helperArgs = array();
if ($tagArgs !== null) {
//Start parsing our custom syntax
$params = explode(' ', $tagArgs);
foreach ($params as $p) {
//Split each key=value pair to vars
list($key, $value) = explode('=', $p, 2);
$section = '';
//If there's a dot in the key, it means we
//need to use associative arrays
if (strpos('.', $key) != -1) {
list($key, $section) = explode('.', $key);
}
//Use Smarty's own functions to parse the value
//so that if there's a variable, it gets changed to
//properly point at a template variable etc.
$value = $this->_parse_var_props($value);
//Put the value into the arg array
if ($section == '') {
if (array_key_exists($key, $helperArgs)) {
if (is_array($helperArgs[$key])) {
$helperArgs[$key][] = $value;
} else {
$helperArgs[$key] = array($helperArgs[$key], $value);
}
} else {
$helperArgs[$key] = $value;
}
} else {
if (!is_array($helperArgs[$key])) {
$helperArgs[$key] = array();
}
$helperArgs[$key][$section] = $value;
}
}
}
//Save the code to put to the template in the output
$output = "<?php echo \$this->callViewHelper('{$tagCommand}',array(" . $this->_createParameterCode($helperArgs) . ")); ?>";
$found = true;
} catch (Exception $e) {
//Exception means the helper was not found
$found = false;
fwrite(fopen('php://stderr', 'a'), $e->getMessage());
}
}
return $found;
}
示例2: callViewHelper
/**
* @param string $name
* @param mixed $args
* @return mixed The helper return
*/
public function callViewHelper($name, $args)
{
$helper = $this->zendView->getHelper($name);
return call_user_func_array(array($helper, $name), $args);
}