icingaweb2-module-director/application/forms/IcingaForgetApiKeyForm.php

38 lines
934 B
PHP
Raw Permalink Normal View History

2017-07-19 12:22:49 -04:00
<?php
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
2017-07-19 12:22:49 -04:00
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Web\Form\DirectorForm;
class IcingaForgetApiKeyForm extends DirectorForm
{
/** @var IcingaHost */
protected $host;
public function setHost(IcingaHost $host)
{
$this->host = $host;
return $this;
}
public function setup()
{
$this->addStandaloneSubmitButton(sprintf(
$this->translate('Drop Self Service API key'),
$this->host->getObjectName()
));
}
public function onSuccess()
{
$this->host->set('api_key', null)->store();
$this->redirectOnSuccess(sprintf($this->translate(
'The Self Service API key for %s has been dropped'
), $this->host->getObjectName()));
}
}