本文整理汇总了PHP中Icinga\Data\ResourceFactory::getResourceConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceFactory::getResourceConfig方法的具体用法?PHP ResourceFactory::getResourceConfig怎么用?PHP ResourceFactory::getResourceConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Data\ResourceFactory
的用法示例。
在下文中一共展示了ResourceFactory::getResourceConfig方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSetup
protected function onSetup()
{
if ($this->hasBeenSubmitted()) {
// Do not hinder the form from being stored
return;
}
if ($this->hasBeenSent() && $this->isValidPartial($this->getRequest()->getPost())) {
$resourceName = $this->getValue('resource');
} else {
$resourceName = $this->config()->get('db', 'resource');
}
if ($resourceName) {
$resourceConfig = ResourceFactory::getResourceConfig($resourceName);
if (!isset($resourceConfig->charset) || $resourceConfig->charset !== 'utf8') {
$this->getElement('resource')->addError('Please change the encodig for the director database to utf8')->removeDecorator('description');
}
$resource = ResourceFactory::create($resourceName);
$db = $resource->getDbAdapter();
try {
$query = $db->select()->from('director_dbversion', 'COUNT(*)');
$db->fetchOne($query);
if (!$this->hasBeenSent()) {
$hint = $this->translate('Configuration looks good, you should be ready to %s' . ' Icinga Director');
$link = $this->getView()->qlink($this->translate('start using'), 'director', null, array('data-base-target' => '_main'));
$this->addHtmlHint(sprintf($hint, $link));
}
} catch (Exception $e) {
$this->getElement('resource')->addError('Could not fetch: ' . $e->getMessage())->removeDecorator('description');
$hint = $this->translate('Please make sure that your database grants enough permissions' . ' and that you deployed the correct %s.');
$link = $this->getView()->qlink($this->translate('database schema'), 'director/schema/' . $resource->getDbType(), null, array('data-base-target' => '_next'));
$this->addHtmlHint(sprintf($hint, $link));
}
}
}
示例2: fromResourceName
public static function fromResourceName($name)
{
return new static(ResourceFactory::getResourceConfig($name));
}
示例3: getResourceConfig
/**
* Return the configuration for the chosen resource
*
* @return ConfigObject
*/
public function getResourceConfig()
{
return ResourceFactory::getResourceConfig($this->getValue('resource'));
}
示例4: isValid
/**
* Return whether the given values are valid
*
* @param array $formData The data to validate
*
* @return bool
*/
public function isValid($formData)
{
if (!parent::isValid($formData)) {
return false;
}
if (($el = $this->getElement('skip_validation')) === null || false === $el->isChecked()) {
$resourceConfig = ResourceFactory::getResourceConfig($this->getValue('resource'));
if (!self::isValidIdoSchema($this, $resourceConfig) || !self::isValidIdoInstance($this, $resourceConfig)) {
if ($el === null) {
$this->addSkipValidationCheckbox();
}
return false;
}
}
return true;
}
示例5: setResource
/**
* Use a given resource to set the user and the key
*
* @param string
*
* @throws ConfigurationError
*/
public function setResource($resource = null)
{
$config = ResourceFactory::getResourceConfig($resource);
if (!isset($config->user)) {
throw new ConfigurationError(t("Can't send external Icinga Command. Remote user is missing"));
}
if (!isset($config->private_key)) {
throw new ConfigurationError(t("Can't send external Icinga Command. The private key for the remote user is missing"));
}
$this->setUser($config->user);
$this->setPrivateKey($config->private_key);
}
示例6: create
public static function create($name, Zend_Config $backendConfig)
{
if ($backendConfig->name !== null) {
$name = $backendConfig->name;
}
if (isset($backendConfig->class)) {
// Use a custom backend class, this is only useful for testing
if (!class_exists($backendConfig->class)) {
throw new ConfigurationError('Authentication configuration for backend "' . $name . '" defines an invalid backend' . ' class. Backend class "' . $backendConfig->class . '" not found');
}
return new $backendConfig->class($backendConfig);
}
if ($name === 'autologin') {
$backend = new AutoLoginBackend($backendConfig);
$backend->setName($name);
return $backend;
}
if ($backendConfig->resource === null) {
throw new ConfigurationError('Authentication configuration for backend "' . $name . '" is missing the resource directive');
}
if (($backendType = $backendConfig->backend) === null) {
throw new ConfigurationError('Authentication configuration for backend "' . $name . '" is missing the backend directive');
}
try {
$resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource);
} catch (ProgrammingError $e) {
throw new ConfigurationError('Resources not set up. Please contact your Icinga Web administrator');
}
$resource = ResourceFactory::createResource($resourceConfig);
switch (strtolower($backendType)) {
case 'db':
$backend = new DbUserBackend($resource);
break;
case 'msldap':
$backend = new LdapUserBackend($resource, $backendConfig->get('user_class', 'user'), $backendConfig->get('user_name_attribute', 'sAMAccountName'));
break;
case 'ldap':
if (($userClass = $backendConfig->user_class) === null) {
throw new ConfigurationError('Authentication configuration for backend "' . $name . '" is missing the user_class directive');
}
if (($userNameAttribute = $backendConfig->user_name_attribute) === null) {
throw new ConfigurationError('Authentication configuration for backend "' . $name . '" is missing the user_name_attribute directive');
}
$backend = new LdapUserBackend($resource, $userClass, $userNameAttribute);
break;
default:
throw new ConfigurationError('Authentication configuration for backend "' . $name . '" defines an invalid backend' . ' type. Backend type "' . $backendType . '" is not supported');
}
$backend->setName($name);
return $backend;
}
示例7: create
/**
* Create preferences storage adapter from config
*
* @param Zend_Config $config The config for the adapter
* @param User $user The user to which these preferences belong
*
* @return self
*
* @throws ConfigurationError When the configuration defines an invalid storage type
*/
public static function create(Zend_Config $config, User $user)
{
if (($type = $config->type) === null) {
throw new ConfigurationError('Preferences configuration is missing the type directive');
}
$type = ucfirst(strtolower($type));
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
if (!class_exists($storeClass)) {
throw new ConfigurationError('Preferences configuration defines an invalid storage type. Storage type ' . $type . ' not found');
}
if ($type === 'Ini') {
$config->location = $config->config_path;
} elseif ($type === 'Db') {
$config->connection = new DbConnection(ResourceFactory::getResourceConfig($config->resource));
}
return new $storeClass($config, $user);
}
示例8: create
/**
* Create preferences storage adapter from config
*
* @param ConfigObject $config The config for the adapter
* @param User $user The user to which these preferences belong
*
* @return self
*
* @throws ConfigurationError When the configuration defines an invalid storage type
*/
public static function create(ConfigObject $config, User $user)
{
$type = ucfirst(strtolower($config->get('store', 'ini')));
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
if (!class_exists($storeClass)) {
throw new ConfigurationError('Preferences configuration defines an invalid storage type. Storage type %s not found', $type);
}
if ($type === 'Ini') {
$config->location = Config::resolvePath('preferences');
} elseif ($type === 'Db') {
$config->connection = new DbConnection(ResourceFactory::getResourceConfig($config->resource));
}
return new $storeClass($config, $user);
}
示例9: isValid
/**
* Return whether the given values are valid
*
* @param array $formData The data to validate
*
* @return bool
*/
public function isValid($formData)
{
if (!parent::isValid($formData)) {
return false;
}
$resourceConfig = ResourceFactory::getResourceConfig($this->getValue('resource'));
if (!self::isValidIdoSchema($this, $resourceConfig) || !self::isValidIdoInstance($this, $resourceConfig)) {
$this->addSkipValidationCheckbox();
return false;
}
return true;
}