public function create($title = null, $options = [])
{
if (is_array($title)) {
$options = $title;
$title = null;
}
$options += ['no-body' => false, 'type' => 'default', 'collapsible' => $this->config('collapsible'), 'open' => !$this->_groupInGroup, 'panel-count' => $this->_panelCount];
$nobody = $options['no-body'];
$type = $options['type'];
$open = $options['open'];
$this->_collapsible = $options['collapsible'];
$panelCount = $options['panel-count'];
unset($options['no-body'], $options['collapsible'], $options['type'], $options['open'], $options['panel-count']);
$options = $this->addClass($options, ['panel', 'panel-' . $type]);
if ($this->_collapsible) {
$this->_headId = 'heading-' . $panelCount;
$this->_bodyId = 'collapse-' . $panelCount;
$this->_panelCount = intval($panelCount) + 1;
if ($open) {
$this->_groupPanelOpen = $this->_bodyId;
}
}
$out = '';
if ($this->_autoCloseOnCreate && !$this->_lastPanelClosed) {
$out .= $this->end();
}
$this->_lastPanelClosed = false;
/* Increment panel counter for the current group. */
$this->_groupPanelCount++;
$out .= $this->Html->tag('div', null, $options);
if (is_string($title) && $title) {
$out .= $this->_createHeader($title, ['title' => isset($options['title']) ? $options['title'] : true]);
if (!$nobody) {
$out .= $this->_createBody();
}
}
return $out;
}