mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see Form::createElements() For the method documentation.
|
||||
*/
|
||||
public function createElements(array $formData = array())
|
||||
{
|
||||
$useResource = isset($formData['use_resource']) ? $formData['use_resource'] : $this->getValue('use_resource');
|
||||
$useResource = false;
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'use_resource',
|
||||
array(
|
||||
'label' => $this->translate('Use SSH Identity'),
|
||||
'description' => $this->translate('Make use of the ssh identity resource'),
|
||||
'autosubmit' => true,
|
||||
'ignore' => true
|
||||
)
|
||||
);
|
||||
if ($this->hasResources()) {
|
||||
$useResource = isset($formData['use_resource'])
|
||||
? $formData['use_resource'] : $this->getValue('use_resource');
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'use_resource',
|
||||
array(
|
||||
'label' => $this->translate('Use SSH Identity'),
|
||||
'description' => $this->translate('Make use of the ssh identity resource'),
|
||||
'autosubmit' => true,
|
||||
'ignore' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($useResource) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user