public function getActiveView()
{
$activeView = null;
$views = $this->getViews();
if (($id = $this->getActiveViewID()) !== '') {
if (($index = $views->findIndexByID($id)) >= 0) {
$activeView = $views->itemAt($index);
} else {
throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id);
}
} else {
if (($index = $this->getActiveViewIndex()) >= 0) {
if ($index < $views->getCount()) {
$activeView = $views->itemAt($index);
} else {
throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index);
}
} else {
foreach ($views as $index => $view) {
if ($view->getActive()) {
$activeView = $view;
break;
}
}
}
}
if ($activeView !== null) {
$this->activateView($activeView);
}
return $activeView;
}