本文整理匯總了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);
}