本文整理汇总了PHP中Arrays::addOnKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::addOnKey方法的具体用法?PHP Arrays::addOnKey怎么用?PHP Arrays::addOnKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arrays
的用法示例。
在下文中一共展示了Arrays::addOnKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
@param templates the input or output form of View::parseTemplateString
where subtemplates is the passed into get as $templates.
In the case of subtemplates, named ouput of each subtemplate along with the total previous output of the subtemplates is passed to the supertemplate. The output of each subtemplate is passed by name in a $templates array, and the total output is available under the variable $input.
@return output from the templates
*/
protected function get($templates, $parseTemplates = true)
{
if ($parseTemplates) {
//this parses all levels, so only need to run on non-recursive call
if (!is_array($templates)) {
$templates = self::parseTemplateString($templates);
}
$templates = $this->parseAliases($templates);
$templates = self::attachChildren($templates);
}
$return['collect'] = array();
while ($templates) {
$template = array_pop($templates);
if (is_array($template)) {
if ($template[2]) {
$got = self::get($template[2], false);
if ($template[0]) {
$output = $this->getTemplate($template[0], array('templates' => $got['collect'], 'input' => $got['combine']));
}
Arrays::addOnKey($template[1] ? $template[1] : $template[0], $output, $return['collect']);
} else {
$output = $this->getTemplate($template[0]);
Arrays::addOnKey($template[1] ? $template[1] : $template[0], $output, $return['collect']);
}
} else {
$output = $this->getTemplate($template);
Arrays::addOnKey($template, $output, $return['collect']);
}
$return['combine'] .= $output;
}
return $return;
}
示例2: add
/**
@param options various options:
hookName : sets hookname, so as to allow identifying it for deletion or modification
deleteAfter : #, deletes after # of uses
*/
static function add($spotName, $callback, $options = null)
{
$hook = array('callback' => $callback, 'options' => $options);
return Arrays::addOnKey($options['hookName'], $hook, self::$hooks[$spotName]);
}