本文整理汇总了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;
}