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;
|
||||||
|
@ -118,18 +119,21 @@ EOT;
|
||||||
*
|
*
|
||||||
* @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)) {
|
||||||
|
throw new HttpNotFoundException('Can\'t activate tab %s. Tab does not exist', $name);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->active !== null) {
|
if ($this->active !== null) {
|
||||||
$this->tabs[$this->active]->setActive(false);
|
$this->tabs[$this->active]->setActive(false);
|
||||||
}
|
}
|
||||||
$this->get($name)->setActive();
|
$this->get($name)->setActive();
|
||||||
$this->active = $name;
|
$this->active = $name;
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue