本文整理汇总了PHP中Icinga\Data\ResourceFactory::getResourceConfigs方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceFactory::getResourceConfigs方法的具体用法?PHP ResourceFactory::getResourceConfigs怎么用?PHP ResourceFactory::getResourceConfigs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Data\ResourceFactory
的用法示例。
在下文中一共展示了ResourceFactory::getResourceConfigs方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createbackendAction
/**
* Create a new monitoring backend
*/
public function createbackendAction()
{
$form = new BackendConfigForm();
$form->setRedirectUrl('monitoring/config');
$form->setTitle($this->translate('Create New Monitoring Backend'));
$form->setIniConfig($this->Config('backends'));
try {
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
} catch (ConfigurationError $e) {
if ($this->hasPermission('config/application/resources')) {
Notification::error($e->getMessage());
$this->redirectNow('config/createresource');
}
throw $e;
// No permission for resource configuration, show the error
}
$form->setOnSuccess(function (BackendConfigForm $form) {
try {
$form->add(array_filter($form->getValues()));
} catch (Exception $e) {
$form->error($e->getMessage());
return false;
}
if ($form->save()) {
Notification::success(t('Monitoring backend successfully created'));
return true;
}
return false;
});
$form->handleRequest();
$this->view->form = $form;
$this->render('form');
}
示例2: hasResources
/**
* 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;
}
示例3: getDatabaseResourceNames
/**
* Return the names of all configured database resources
*
* @return array
*/
protected function getDatabaseResourceNames()
{
$names = array();
foreach (ResourceFactory::getResourceConfigs() as $name => $config) {
if (strtolower($config->type) === 'db') {
$names[] = $name;
}
}
return $names;
}
示例4: createbackendAction
/**
* Display a form to create a new backend
*/
public function createbackendAction()
{
$form = new BackendConfigForm();
$form->setTitle($this->translate('Add New Backend'));
$form->setIniConfig($this->Config('backends'));
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
$form->setRedirectUrl('monitoring/config');
$form->handleRequest();
$this->view->form = $form;
}
示例5: enumResources
protected static function enumResources($type)
{
$resources = array();
foreach (ResourceFactory::getResourceConfigs() as $name => $resource) {
if ($resource->type === $type && self::resourceIsAllowed($name)) {
$resources[$name] = $name;
}
}
return $resources;
}
示例6: loadResources
/**
* Load all available ssh identity resources
*
* @return $this
*
* @throws \Icinga\Exception\ConfigurationError
*/
public function loadResources()
{
$resourceConfig = ResourceFactory::getResourceConfigs();
$resources = array();
foreach ($resourceConfig as $name => $resource) {
if ($resource->type === 'ssh') {
$resources['ssh'][$name] = $name;
}
}
if (empty($resources)) {
throw new ConfigurationError($this->translate('Could not find any valid monitoring instance resources'));
}
$this->resources = $resources;
return $this;
}
示例7: createElements
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement('text', 'global_module_path', array('label' => $this->translate('Module Path'), 'required' => true, 'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()), 'description' => $this->translate('Contains the directories that will be searched for available modules, separated by ' . 'colons. Modules that don\'t exist in these directories can still be symlinked in ' . 'the module folder, but won\'t show up in the list of disabled modules.')));
$this->addElement('select', 'preferences_store', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => array('ini' => $this->translate('File System (INI Files)'), 'db' => $this->translate('Database'), 'none' => $this->translate('Don\'t Store Preferences'))));
if (isset($formData['preferences_store']) && $formData['preferences_store'] === 'db') {
$backends = array();
foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) {
if ($resource['type'] === 'db') {
$backends[$name] = $name;
}
}
$this->addElement('select', 'preferences_resource', array('required' => true, 'multiOptions' => $backends, 'label' => $this->translate('Database Connection')));
}
return $this;
}
示例8: createElements
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement('checkbox', 'global_show_stacktraces', array('required' => true, 'value' => true, 'label' => $this->translate('Show Stacktraces'), 'description' => $this->translate('Set whether to show an exception\'s stacktrace by default. This can also' . ' be set in a user\'s preferences with the appropriate permission.')));
$this->addElement('text', 'global_module_path', array('label' => $this->translate('Module Path'), 'required' => true, 'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()), 'description' => $this->translate('Contains the directories that will be searched for available modules, separated by ' . 'colons. Modules that don\'t exist in these directories can still be symlinked in ' . 'the module folder, but won\'t show up in the list of disabled modules.')));
$this->addElement('select', 'global_config_backend', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => array('ini' => $this->translate('File System (INI Files)'), 'db' => $this->translate('Database'), 'none' => $this->translate('Don\'t Store Preferences'))));
if (isset($formData['global_config_backend']) && $formData['global_config_backend'] === 'db') {
$backends = array();
foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) {
if ($resource['type'] === 'db') {
$backends[$name] = $name;
}
}
$this->addElement('select', 'global_config_resource', array('required' => true, 'multiOptions' => $backends, 'label' => $this->translate('Database Connection')));
}
$this->addElement('text', 'datetime_format', array('label' => $this->translate('Datetime format'), 'required' => true, 'value' => $this->translate('Y-m-d H:i:s'), 'description' => $this->translate('Datetime format for use when displaying timestamps in history views. Uses PHP ' . 'date() format, see PHP documentation for syntax.')));
return $this;
}
示例9: edituserbackendAction
/**
* Edit a user backend
*/
public function edituserbackendAction()
{
$this->assertPermission('config/application/userbackend');
$backendName = $this->params->getRequired('backend');
$form = new UserBackendConfigForm();
$form->setRedirectUrl('config/userbackend');
$form->setIniConfig(Config::app('authentication'));
$form->setOnSuccess(function (UserBackendConfigForm $form) use($backendName) {
try {
$form->edit($backendName, array_map(function ($v) {
return $v !== '' ? $v : null;
}, $form->getValues()));
} catch (Exception $e) {
$form->error($e->getMessage());
return false;
}
if ($form->save()) {
Notification::success(sprintf(t('User backend "%s" successfully updated'), $backendName));
return true;
}
return false;
});
try {
$form->load($backendName);
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
$form->handleRequest();
} catch (NotFoundError $_) {
$this->httpNotFound(sprintf($this->translate('User backend "%s" not found'), $backendName));
}
$this->renderForm($form, $this->translate('Update User Backend'));
}
示例10: enumResources
protected function enumResources()
{
$resources = array();
$allowed = array('mysql', 'pgsql');
foreach (ResourceFactory::getResourceConfigs() as $name => $resource) {
if ($resource->type === 'db' && in_array($resource->db, $allowed)) {
$resources[$name] = $name;
}
}
return $resources;
}
示例11: edituserbackendAction
/**
* Action for editing user backends
*/
public function edituserbackendAction()
{
$this->assertPermission('config/application/userbackend');
$form = new UserBackendConfigForm();
$form->setTitle($this->translate('Edit User Backend'));
$form->setIniConfig(Config::app('authentication'));
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
$form->setRedirectUrl('config/userbackend');
$form->setAction(Url::fromRequest());
$form->handleRequest();
$this->view->form = $form;
$this->render('userbackend/modify');
}
示例12: getLdapResourceNames
/**
* Return the names of all configured LDAP resources
*
* @return array
*/
protected function getLdapResourceNames()
{
$names = array();
foreach (ResourceFactory::getResourceConfigs() as $name => $config) {
if (in_array(strtolower($config->type), array('ldap', 'msldap'))) {
$names[] = $name;
}
}
if (empty($names)) {
Notification::error($this->translate('No LDAP resources available. Please configure an LDAP resource first.'));
$this->getResponse()->redirectAndExit('config/createresource');
}
return $names;
}