lib/Tabs: Throw HttpNotFoundException when activating an inexistent tab
refs #10884
This commit is contained in:
parent
5972612b64
commit
a3f89c8d20
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
|
use Icinga\Exception\Http\HttpNotFoundException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\Tabextension;
|
use Icinga\Web\Widget\Tabextension\Tabextension;
|
||||||
|
@ -114,22 +115,25 @@ EOT;
|
||||||
*
|
*
|
||||||
* If another tab is currently active it will be deactivated
|
* If another tab is currently active it will be deactivated
|
||||||
*
|
*
|
||||||
* @param string $name Name of the tab going to be activated
|
* @param string $name Name of the tab going to be activated
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws ProgrammingError When the given tab name doesn't exist
|
* @throws HttpNotFoundException When the tab w/ the given name does not exist
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function activate($name)
|
public function activate($name)
|
||||||
{
|
{
|
||||||
if ($this->has($name)) {
|
if (! $this->has($name)) {
|
||||||
if ($this->active !== null) {
|
throw new HttpNotFoundException('Can\'t activate tab %s. Tab does not exist', $name);
|
||||||
$this->tabs[$this->active]->setActive(false);
|
|
||||||
}
|
|
||||||
$this->get($name)->setActive();
|
|
||||||
$this->active = $name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->active !== null) {
|
||||||
|
$this->tabs[$this->active]->setActive(false);
|
||||||
|
}
|
||||||
|
$this->get($name)->setActive();
|
||||||
|
$this->active = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue