mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 09:14:08 +02:00
RemoteInstanceForm: Fix the unhandled exception if no ...
..resources are available * Now we only can use the ssh identity, if there is at least one ssh identity resource exists fixes #9517
This commit is contained in:
parent
66edf55ca6
commit
ceb32679d8
@ -52,24 +52,46 @@ class RemoteInstanceForm extends Form
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether ssh identity resources exists or not
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasResources()
|
||||||
|
{
|
||||||
|
$resourceConfig = ResourceFactory::getResourceConfigs();
|
||||||
|
|
||||||
|
foreach ($resourceConfig as $name => $resource) {
|
||||||
|
if ($resource->type === 'ssh') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* (non-PHPDoc)
|
||||||
* @see Form::createElements() For the method documentation.
|
* @see Form::createElements() For the method documentation.
|
||||||
*/
|
*/
|
||||||
public function createElements(array $formData = array())
|
public function createElements(array $formData = array())
|
||||||
{
|
{
|
||||||
$useResource = isset($formData['use_resource']) ? $formData['use_resource'] : $this->getValue('use_resource');
|
$useResource = false;
|
||||||
|
|
||||||
$this->addElement(
|
if ($this->hasResources()) {
|
||||||
'checkbox',
|
$useResource = isset($formData['use_resource'])
|
||||||
'use_resource',
|
? $formData['use_resource'] : $this->getValue('use_resource');
|
||||||
array(
|
|
||||||
'label' => $this->translate('Use SSH Identity'),
|
$this->addElement(
|
||||||
'description' => $this->translate('Make use of the ssh identity resource'),
|
'checkbox',
|
||||||
'autosubmit' => true,
|
'use_resource',
|
||||||
'ignore' => true
|
array(
|
||||||
)
|
'label' => $this->translate('Use SSH Identity'),
|
||||||
);
|
'description' => $this->translate('Make use of the ssh identity resource'),
|
||||||
|
'autosubmit' => true,
|
||||||
|
'ignore' => true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($useResource) {
|
if ($useResource) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user