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