当前位置: 首页>>代码示例>>PHP>>正文


PHP Data\ResourceFactory类代码示例

本文整理汇总了PHP中Icinga\Data\ResourceFactory的典型用法代码示例。如果您正苦于以下问题:PHP ResourceFactory类的具体用法?PHP ResourceFactory怎么用?PHP ResourceFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ResourceFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connection

 protected function connection()
 {
     if ($this->connection === null) {
         $this->connection = ResourceFactory::create($this->settings['resource']);
     }
     return $this->connection;
 }
开发者ID:dgoeger,项目名称:icingadirector,代码行数:7,代码来源:ImportSourceLdap.php

示例2: 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');
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:36,代码来源:ConfigController.php

示例3: setResourceConfig

 /**
  * Set the resource configuration to use
  *
  * @param   array   $config
  *
  * @return  $this
  */
 public function setResourceConfig(array $config)
 {
     $resourceConfig = new Config();
     $resourceConfig->setSection($config['name'], $config);
     ResourceFactory::setConfig($resourceConfig);
     $this->config = $config;
     return $this;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:15,代码来源:AuthBackendPage.php

示例4: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     $result = ResourceFactory::createResource(new ConfigObject($form->getValues()))->inspect();
     if ($result->hasError()) {
         $form->addError(sprintf('%s (%s)', $form->translate('Connectivity validation failed, connection to the given resource not possible.'), $result->getError()));
     }
     // TODO: display diagnostics in $result->toArray() to the user
     return !$result->hasError();
 }
开发者ID:bebehei,项目名称:icingaweb2,代码行数:16,代码来源:LdapResourceForm.php

示例5: 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;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:15,代码来源:DbUserGroupBackendForm.php

示例6: 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;
 }
开发者ID:dgoeger,项目名称:icingadirector,代码行数:10,代码来源:Util.php

示例7: 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;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:15,代码来源:RemoteInstanceForm.php

示例8: 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;
 }
开发者ID:xert,项目名称:icingaweb2,代码行数:13,代码来源:ConfigController.php

示例9: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     try {
         $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
         $resource->getConnection()->getConnection();
     } catch (Exception $e) {
         $form->addError($form->translate('Connectivity validation failed, connection to the given resource not possible.'));
         return false;
     }
     return true;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:18,代码来源:DbResourceForm.php

示例10: createAccount

 protected function createAccount()
 {
     try {
         $backend = new DbUserBackend(ResourceFactory::createResource(new ConfigObject($this->data['adminAccountData']['resourceConfig'])));
         if ($backend->select()->where('user_name', $this->data['adminAccountData']['username'])->count() === 0) {
             $backend->insert('user', array('user_name' => $this->data['adminAccountData']['username'], 'password' => $this->data['adminAccountData']['password'], 'is_active' => true));
         }
     } catch (Exception $e) {
         $this->dbError = $e;
         return false;
     }
     $this->dbError = false;
     return true;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:14,代码来源:AuthenticationStep.php

示例11: 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;
 }
开发者ID:xert,项目名称:icingaweb2,代码行数:18,代码来源:ApplicationConfigForm.php

示例12: 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;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:22,代码来源:RemoteInstanceForm.php

示例13: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     try {
         $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
         $resource->bind();
     } catch (Exception $e) {
         $msg = $form->translate('Connectivity validation failed, connection to the given resource not possible.');
         if ($error = $e->getMessage()) {
             $msg .= ' (' . $error . ')';
         }
         $form->addError($msg);
         return false;
     }
     return true;
 }
开发者ID:kain64,项目名称:icingaweb2,代码行数:22,代码来源:LdapResourceForm.php

示例14: createMembership

 protected function createMembership()
 {
     try {
         $backend = new DbUserGroupBackend(ResourceFactory::createResource(new ConfigObject($this->data['resourceConfig'])));
         $groupName = mt('setup', 'Administrators', 'setup.role.name');
         $userName = $this->data['username'];
         if ($backend->select()->from('group_membership')->where('group_name', $groupName)->where('user_name', $userName)->count() === 0) {
             $backend->insert('group_membership', array('group_name' => $groupName, 'user_name' => $userName));
             $this->memberError = false;
         }
     } catch (Exception $e) {
         $this->memberError = $e;
         return false;
     }
     return true;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:16,代码来源:UserGroupStep.php

示例15: 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;
 }
开发者ID:ZipRecruiter,项目名称:icingaweb2,代码行数:20,代码来源:ApplicationConfigForm.php


注:本文中的Icinga\Data\ResourceFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。