mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
5f7652133e
commit
a6bd802e3e
@ -14,72 +14,6 @@ use Icinga\Data\ResourceFactory;
|
|||||||
*/
|
*/
|
||||||
class EditBackendForm extends Form
|
class EditBackendForm extends Form
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Database resources to use instead of the one's from ResourceFactory (used for testing)
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $resources;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Backend configuration to use for populating the form
|
|
||||||
*
|
|
||||||
* @var Zend_Config
|
|
||||||
*/
|
|
||||||
protected $backend;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the configuration to be used for initial population of the form
|
|
||||||
*
|
|
||||||
* @param Zend_Form $config
|
|
||||||
*/
|
|
||||||
public function setBackendConfiguration($config)
|
|
||||||
{
|
|
||||||
$this->backend = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a custom array of resources to be used in this form instead of the ones from ResourceFactory
|
|
||||||
* (used for testing)
|
|
||||||
*/
|
|
||||||
public function setResources($resources)
|
|
||||||
{
|
|
||||||
$this->resources = $resources;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return content of the resources.ini or previously set resources for displaying in the database selection field
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getResources()
|
|
||||||
{
|
|
||||||
if ($this->resources === null) {
|
|
||||||
return ResourceFactory::getResourceConfigs()->toArray();
|
|
||||||
} else {
|
|
||||||
return $this->resources;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a list of all resources of the given type ready to be used as content for a select input
|
|
||||||
*
|
|
||||||
* @param string $type The type of resources to return
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function getResourcesByType($type)
|
|
||||||
{
|
|
||||||
$backends = array();
|
|
||||||
foreach ($this->getResources() as $name => $resource) {
|
|
||||||
if ($resource['type'] === $type) {
|
|
||||||
$backends[$name] = $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $backends;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create this form
|
* Create this form
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user