本文整理匯總了PHP中action_menu::will_be_enhanced方法的典型用法代碼示例。如果您正苦於以下問題:PHP action_menu::will_be_enhanced方法的具體用法?PHP action_menu::will_be_enhanced怎麽用?PHP action_menu::will_be_enhanced使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類action_menu
的用法示例。
在下文中一共展示了action_menu::will_be_enhanced方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: export_for_template
/**
* Export for template.
*
* @param renderer_base $output The renderer.
* @return stdClass
*/
public function export_for_template(renderer_base $output) {
static $instance = 1;
$data = parent::export_for_template($output);
$data->instance = $instance++;
// Ignore what the parent did with the attributes, except for ID and class.
$data->attributes = [];
$attributes = $this->attributes;
unset($attributes['id']);
unset($attributes['class']);
// Handle text being a renderable.
$comparetoalt = $this->text;
if ($this->text instanceof renderable) {
$data->text = $this->render($this->text);
$comparetoalt = '';
}
$comparetoalt = (string) $comparetoalt;
$data->showtext = (!$this->icon || $this->primary === false);
$data->icon = null;
if ($this->icon) {
$icon = $this->icon;
if ($this->primary || !$this->actionmenu->will_be_enhanced()) {
$attributes['title'] = $data->text;
}
if (!$this->primary && $this->actionmenu->will_be_enhanced()) {
if ((string) $icon->attributes['alt'] === $comparetoalt) {
$icon->attributes['alt'] = '';
}
if (isset($icon->attributes['title']) && (string) $icon->attributes['title'] === $comparetoalt) {
unset($icon->attributes['title']);
}
}
$data->icon = $icon ? $icon->export_for_template($output) : null;
}
$data->disabled = !empty($attributes['disabled']);
unset($attributes['disabled']);
$data->attributes = array_map(function($key, $value) {
return [
'name' => $key,
'value' => $value
];
}, array_keys($attributes), $attributes);
return $data;
}