parent
0c84bf614d
commit
7621f6642d
|
@ -212,7 +212,7 @@ class ConfigController extends ActionController
|
|||
*/
|
||||
public function resourceAction()
|
||||
{
|
||||
$this->view->resources = Config::app('resources', true)->toArray();
|
||||
$this->view->resources = Config::app('resources', true)->keys();
|
||||
$this->view->tabs->activate('resources');
|
||||
}
|
||||
|
||||
|
@ -274,9 +274,9 @@ class ConfigController extends ActionController
|
|||
|
||||
// Check if selected resource is currently used for authentication
|
||||
$resource = $this->getRequest()->getQuery('resource');
|
||||
$authConfig = Config::app('authentication')->toArray();
|
||||
$authConfig = Config::app('authentication');
|
||||
foreach ($authConfig as $backendName => $config) {
|
||||
if (array_key_exists('resource', $config) && $config['resource'] === $resource) {
|
||||
if ($config->get('resource') === $resource) {
|
||||
$form->addError(sprintf(
|
||||
$this->translate(
|
||||
'The resource "%s" is currently in use by the authentication backend "%s". ' .
|
||||
|
|
|
@ -37,7 +37,7 @@ class DashboardController extends ActionController
|
|||
$dashboard = new Dashboard();
|
||||
try {
|
||||
$dashboardConfig = Config::app($config);
|
||||
if (count($dashboardConfig) === 0) {
|
||||
if ($dashboardConfig->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
$dashboard->readConfig($dashboardConfig);
|
||||
|
@ -93,7 +93,7 @@ class DashboardController extends ActionController
|
|||
);
|
||||
|
||||
$configFile = Config::app('dashboard/dashboard')->getConfigFile();
|
||||
if ($this->writeConfiguration(new Config($dashboard->toArray()), $configFile)) {
|
||||
if ($this->writeConfiguration(Config::fromArray($dashboard->toArray()), $configFile)) {
|
||||
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane'))));
|
||||
} else {
|
||||
$this->render('showConfiguration');
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Protocol\File\FileReader;
|
||||
use \Zend_Controller_Action_Exception as ActionError;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ListController extends Controller
|
|||
. ' - (?<message>.*)$/'; // message
|
||||
|
||||
$loggerWriter = Logger::getInstance()->getWriter();
|
||||
$resource = new FileReader(new Config(array(
|
||||
$resource = new FileReader(new ConfigObject(array(
|
||||
'filename' => $loggerWriter->getPath(),
|
||||
'fields' => $pattern
|
||||
)));
|
||||
|
|
|
@ -39,8 +39,8 @@ class PreferenceController extends BasePreferenceController
|
|||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$storeConfig = Config::app()->preferences;
|
||||
if ($storeConfig === null) {
|
||||
$storeConfig = Config::app()->getSection('preferences');
|
||||
if ($storeConfig->isEmpty()) {
|
||||
throw new ConfigurationError(t('You need to configure how to store preferences first.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Icinga\Forms\Config\Authentication;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
|
||||
|
@ -121,7 +121,7 @@ class DbBackendForm extends Form
|
|||
/**
|
||||
* Return the configuration for the chosen resource
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function getResourceConfig()
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Icinga\Forms\Config\Authentication;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\AuthenticationException;
|
||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||
|
@ -156,7 +156,7 @@ class LdapBackendForm extends Form
|
|||
/**
|
||||
* Return the configuration for the chosen resource
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function getResourceConfig()
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ use Icinga\Forms\ConfigForm;
|
|||
use Icinga\Web\Notification;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
|
@ -91,12 +92,12 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
$name = isset($values['name']) ? $values['name'] : '';
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(t('Authentication backend name missing'));
|
||||
} elseif ($this->config->get($name) !== null) {
|
||||
} elseif ($this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Authentication backend already exists'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
$this->config->{$name} = $values;
|
||||
$this->config->setSection($name, $values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -116,18 +117,19 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
throw new InvalidArgumentException(t('Old authentication backend name missing'));
|
||||
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
|
||||
throw new InvalidArgumentException(t('New authentication backend name missing'));
|
||||
} elseif (($backendConfig = $this->config->get($name)) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
|
||||
}
|
||||
|
||||
$backendConfig = $this->config->getSection($name);
|
||||
if ($newName !== $name) {
|
||||
// Only remove the old entry if it has changed as the order gets screwed when editing backend names
|
||||
unset($this->config->{$name});
|
||||
$this->config->removeSection($name);
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
$this->config->{$newName} = array_merge($backendConfig->toArray(), $values);
|
||||
return $this->config->{$newName};
|
||||
$this->config->setSection($newName, $backendConfig->merge($values));
|
||||
return $backendConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,11 +145,12 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(t('Authentication backend name missing'));
|
||||
} elseif (($backendConfig = $this->config->get($name)) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
|
||||
}
|
||||
|
||||
unset($this->config->{$name});
|
||||
$backendConfig = $this->config->getSection($name);
|
||||
$this->config->removeSection($name);
|
||||
return $backendConfig;
|
||||
}
|
||||
|
||||
|
@ -165,7 +168,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(t('Authentication backend name missing'));
|
||||
} elseif ($this->config->get($name) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
|
||||
}
|
||||
|
||||
|
@ -175,10 +178,10 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
|
||||
$newConfig = array();
|
||||
foreach ($backendOrder as $backendName) {
|
||||
$newConfig[$backendName] = $this->config->get($backendName);
|
||||
$newConfig[$backendName] = $this->config->getSection($backendName);
|
||||
}
|
||||
|
||||
$config = new Config($newConfig);
|
||||
$config = Config::fromArray($newConfig);
|
||||
$this->config = $config->setConfigFile($this->config->getConfigFile());
|
||||
return $this;
|
||||
}
|
||||
|
@ -235,13 +238,13 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
if ($authBackend !== null) {
|
||||
if ($authBackend === '') {
|
||||
throw new ConfigurationError(t('Authentication backend name missing'));
|
||||
} elseif (false === isset($this->config->{$authBackend})) {
|
||||
} elseif (! $this->config->hasSection($authBackend)) {
|
||||
throw new ConfigurationError(t('Unknown authentication backend provided'));
|
||||
} elseif (false === isset($this->config->{$authBackend}->backend)) {
|
||||
} elseif ($this->config->getSection($authBackend)->backend === null) {
|
||||
throw new ConfigurationError(sprintf(t('Backend "%s" has no `backend\' setting'), $authBackend));
|
||||
}
|
||||
|
||||
$configValues = $this->config->{$authBackend}->toArray();
|
||||
$configValues = $this->config->getSection($authBackend)->toArray();
|
||||
$configValues['type'] = $configValues['backend'];
|
||||
$configValues['name'] = $authBackend;
|
||||
$this->populate($configValues);
|
||||
|
@ -332,7 +335,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
/**
|
||||
* Return the configuration for the chosen resource
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function getResourceConfig()
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ class GeneralConfigForm extends ConfigForm
|
|||
$sections[$section][$property] = $value;
|
||||
}
|
||||
foreach ($sections as $section => $config) {
|
||||
$this->config->{$section} = $config;
|
||||
$this->config->setSection($section, $config);
|
||||
}
|
||||
|
||||
if ($this->save()) {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Application\Platform;
|
||||
|
||||
|
@ -129,7 +129,7 @@ class DbResourceForm extends Form
|
|||
public static function isValidResource(Form $form)
|
||||
{
|
||||
try {
|
||||
$resource = ResourceFactory::createResource(new Config($form->getValues()));
|
||||
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
|
||||
$resource->getConnection()->getConnection();
|
||||
} catch (Exception $e) {
|
||||
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ class LdapResourceForm extends Form
|
|||
public static function isValidResource(Form $form)
|
||||
{
|
||||
try {
|
||||
$resource = ResourceFactory::createResource(new Config($form->getValues()));
|
||||
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
|
||||
if (false === $resource->testCredentials(
|
||||
$form->getElement('bind_dn')->getValue(),
|
||||
$form->getElement('bind_pw')->getValue()
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ class LivestatusResourceForm extends Form
|
|||
public static function isValidResource(Form $form)
|
||||
{
|
||||
try {
|
||||
$resource = ResourceFactory::createResource(new Config($form->getValues()));
|
||||
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
|
||||
$resource->connect()->disconnect();
|
||||
} catch (Exception $e) {
|
||||
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
|
||||
|
|
|
@ -63,12 +63,12 @@ class ResourceConfigForm extends ConfigForm
|
|||
$name = isset($values['name']) ? $values['name'] : '';
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(t('Resource name missing'));
|
||||
} elseif ($this->config->{$name} !== null) {
|
||||
} elseif ($this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Resource already exists'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
$this->config->{$name} = $values;
|
||||
$this->config->setSection($name, $values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -88,14 +88,15 @@ class ResourceConfigForm extends ConfigForm
|
|||
throw new InvalidArgumentException(t('Old resource name missing'));
|
||||
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
|
||||
throw new InvalidArgumentException(t('New resource name missing'));
|
||||
} elseif (($resourceConfig = $this->config->get($name)) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Unknown resource provided'));
|
||||
}
|
||||
|
||||
$resourceConfig = $this->config->getSection($name);
|
||||
$this->config->removeSection($name);
|
||||
unset($values['name']);
|
||||
unset($this->config->{$name});
|
||||
$this->config->{$newName} = array_merge($resourceConfig->toArray(), $values);
|
||||
return $this->config->{$newName};
|
||||
$this->config->setSection($newName, $resourceConfig->merge($values));
|
||||
return $resourceConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,11 +112,12 @@ class ResourceConfigForm extends ConfigForm
|
|||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(t('Resource name missing'));
|
||||
} elseif (($resourceConfig = $this->config->get($name)) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(t('Unknown resource provided'));
|
||||
}
|
||||
|
||||
unset($this->config->{$name});
|
||||
$resourceConfig = $this->config->getSection($name);
|
||||
$this->config->removeSection($name);
|
||||
return $resourceConfig;
|
||||
}
|
||||
|
||||
|
@ -171,11 +173,11 @@ class ResourceConfigForm extends ConfigForm
|
|||
if ($resource !== null) {
|
||||
if ($resource === '') {
|
||||
throw new ConfigurationError(t('Resource name missing'));
|
||||
} elseif (false === isset($this->config->{$resource})) {
|
||||
} elseif (! $this->config->hasSection($resource)) {
|
||||
throw new ConfigurationError(t('Unknown resource provided'));
|
||||
}
|
||||
|
||||
$configValues = $this->config->{$resource}->toArray();
|
||||
$configValues = $this->config->getSection($resource)->toArray();
|
||||
$configValues['name'] = $resource;
|
||||
$this->populate($configValues);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Icinga\Forms;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Protocol\Ldap\Exception as LdapException;
|
||||
use Icinga\Protocol\Ldap\Connection;
|
||||
use Icinga\Protocol\Dns;
|
||||
|
@ -143,7 +143,7 @@ class LdapDiscoveryForm extends Form
|
|||
|
||||
private function discoverCapabilities($config)
|
||||
{
|
||||
$conn = new Connection(new Config($config));
|
||||
$conn = new Connection(new ConfigObject($config));
|
||||
try {
|
||||
$conn->connect();
|
||||
$this->capabilities = $conn->getCapabilities();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->resources as $name => $resource): ?>
|
||||
<?php foreach ($this->resources as $name): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?= $this->href('config/editresource', array('resource' => $name)); ?>">
|
||||
|
|
|
@ -8,6 +8,7 @@ use ErrorException;
|
|||
use Exception;
|
||||
use LogicException;
|
||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
|
@ -372,7 +373,7 @@ abstract class ApplicationBootstrap
|
|||
$this->moduleManager = new ModuleManager(
|
||||
$this,
|
||||
$this->configDir . '/enabledModules',
|
||||
explode(':', $this->config->fromSection('global', 'module_path', $this->baseDir . '/modules'))
|
||||
explode(':', $this->config->get('global', 'module_path', $this->baseDir . '/modules'))
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
@ -415,7 +416,7 @@ abstract class ApplicationBootstrap
|
|||
protected function setupLogging()
|
||||
{
|
||||
Logger::create(
|
||||
new Config(
|
||||
new ConfigObject(
|
||||
array(
|
||||
'log' => 'syslog'
|
||||
)
|
||||
|
@ -476,9 +477,9 @@ abstract class ApplicationBootstrap
|
|||
*/
|
||||
protected function setupLogger()
|
||||
{
|
||||
if (($loggingConfig = $this->config->logging) !== null) {
|
||||
if ($this->config->hasSection('logging')) {
|
||||
try {
|
||||
Logger::create($loggingConfig);
|
||||
Logger::create($this->config->getSection('logging'));
|
||||
} catch (ConfigurationError $e) {
|
||||
Logger::error($e);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
namespace Icinga\Application;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
use Icinga\Cli\Params;
|
||||
|
@ -12,6 +11,7 @@ use Icinga\Cli\Loader;
|
|||
use Icinga\Cli\Screen;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
||||
require_once __DIR__ . '/ApplicationBootstrap.php';
|
||||
|
@ -50,7 +50,7 @@ class Cli extends ApplicationBootstrap
|
|||
protected function setupLogging()
|
||||
{
|
||||
Logger::create(
|
||||
new Config(
|
||||
new ConfigObject(
|
||||
array(
|
||||
'level' => Logger::INFO,
|
||||
'log' => 'stdout',
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Application;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Application\Logger\Writer\FileWriter;
|
||||
use Icinga\Application\Logger\Writer\SyslogWriter;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -71,12 +71,12 @@ class Logger
|
|||
/**
|
||||
* Create a new logger object
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*
|
||||
* @throws ConfigurationError If the logging configuration directive 'log' is missing or if the logging level is
|
||||
* not defined
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
if ($config->log === null) {
|
||||
throw new ConfigurationError('Required logging configuration directive \'log\' missing');
|
||||
|
@ -118,11 +118,11 @@ class Logger
|
|||
/**
|
||||
* Create a new logger object
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create(Config $config)
|
||||
public static function create(ConfigObject $config)
|
||||
{
|
||||
static::$instance = new static($config);
|
||||
return static::$instance;
|
||||
|
@ -131,12 +131,12 @@ class Logger
|
|||
/**
|
||||
* Create a log writer
|
||||
*
|
||||
* @param Config $config The configuration to initialize the writer with
|
||||
* @param ConfigObject $config The configuration to initialize the writer with
|
||||
*
|
||||
* @return \Icinga\Application\Logger\LogWriter The requested log writer
|
||||
* @throws ConfigurationError If the requested writer cannot be found
|
||||
*/
|
||||
protected function createWriter(Config $config)
|
||||
protected function createWriter(ConfigObject $config)
|
||||
{
|
||||
$class = 'Icinga\\Application\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer';
|
||||
if (! class_exists($class)) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Application\Logger;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
|
||||
/**
|
||||
* Abstract class for writers that write messages to a log
|
||||
|
@ -12,14 +12,14 @@ use Icinga\Application\Config;
|
|||
abstract class LogWriter
|
||||
{
|
||||
/**
|
||||
* @var Zend_Config
|
||||
* @var ConfigObject
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Create a new log writer initialized with the given configuration
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Application\Logger\Writer;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\LogWriter;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -26,12 +26,12 @@ class FileWriter extends LogWriter
|
|||
/**
|
||||
* Create a new file log writer
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*
|
||||
* @throws ConfigurationError If the configuration directive 'file' is missing or if the path to 'file' does
|
||||
* not exist or if writing to 'file' is not possible
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
if ($config->file === null) {
|
||||
throw new ConfigurationError('Required logging configuration directive \'file\' missing');
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Application\Logger\Writer;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\LogWriter;
|
||||
|
||||
|
@ -51,9 +51,9 @@ class SyslogWriter extends LogWriter
|
|||
/**
|
||||
* Create a new syslog log writer
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
$this->ident = $config->get('application', 'icingaweb');
|
||||
$this->facility = static::$facilities['user'];
|
||||
|
|
|
@ -12,6 +12,7 @@ use Icinga\Application\ApplicationBootstrap;
|
|||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Util\Translator;
|
||||
use Icinga\Web\Hook;
|
||||
use Icinga\Web\Menu;
|
||||
|
@ -242,7 +243,7 @@ class Module
|
|||
if (array_key_exists($name, $this->menuItems)) {
|
||||
$this->menuItems[$name]->setProperties($properties);
|
||||
} else {
|
||||
$this->menuItems[$name] = new Menu($name, new Config($properties));
|
||||
$this->menuItems[$name] = new Menu($name, new ConfigObject($properties));
|
||||
}
|
||||
|
||||
return $this->menuItems[$name];
|
||||
|
|
|
@ -259,9 +259,7 @@ class Web extends ApplicationBootstrap
|
|||
$view->view->addHelperPath($this->getApplicationDir('/views/helpers'));
|
||||
|
||||
$view->view->setEncoding('UTF-8');
|
||||
$view->view->headTitle()->prepend(
|
||||
$this->config->global !== null ? $this->config->global->get('project', 'Icinga') : 'Icinga'
|
||||
);
|
||||
$view->view->headTitle()->prepend($this->config->get('global', 'project', 'Icinga'));
|
||||
|
||||
$view->view->headTitle()->setSeparator(' :: ');
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Icinga\Authentication;
|
|||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\User;
|
||||
use Icinga\Util\String;
|
||||
|
||||
|
@ -15,13 +16,13 @@ use Icinga\Util\String;
|
|||
class AdmissionLoader
|
||||
{
|
||||
/**
|
||||
* @param string $username
|
||||
* @param array $userGroups
|
||||
* @param mixed $section
|
||||
* @param string $username
|
||||
* @param array $userGroups
|
||||
* @param ConfigObject $section
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function match($username, $userGroups, $section)
|
||||
protected function match($username, $userGroups, ConfigObject $section)
|
||||
{
|
||||
$username = strtolower($username);
|
||||
if (! empty($section->users)) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Icinga\Authentication;
|
||||
|
||||
use Iterator;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -40,11 +41,13 @@ class AuthChain implements Iterator
|
|||
|
||||
/**
|
||||
* Rewind the chain
|
||||
*
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->config->rewind();
|
||||
$this->currentBackend = null;
|
||||
return $this->config->rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +63,7 @@ class AuthChain implements Iterator
|
|||
/**
|
||||
* Return the key of the current user backend config
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
|
@ -69,16 +72,18 @@ class AuthChain implements Iterator
|
|||
|
||||
/**
|
||||
* Move forward to the next user backend config
|
||||
*
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->config->next();
|
||||
return $this->config->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user backend is valid, i.e. it's enabled and the config's valid
|
||||
* Check if the current user backend is valid, i.e. it's enabled and the config is valid
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
|
@ -86,13 +91,15 @@ class AuthChain implements Iterator
|
|||
// Stop when there are no more backends to check
|
||||
return false;
|
||||
}
|
||||
|
||||
$backendConfig = $this->config->current();
|
||||
if ((bool) $backendConfig->get('disabled', false) === true) {
|
||||
$this->next();
|
||||
return $this->valid();
|
||||
}
|
||||
|
||||
$name = $this->key();
|
||||
try {
|
||||
$name = $this->key();
|
||||
$backend = UserBackend::create($name, $backendConfig);
|
||||
} catch (ConfigurationError $e) {
|
||||
Logger::error(
|
||||
|
@ -105,6 +112,7 @@ class AuthChain implements Iterator
|
|||
$this->next();
|
||||
return $this->valid();
|
||||
}
|
||||
|
||||
$this->currentBackend = $backend;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
namespace Icinga\Authentication\Backend;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Authentication\UserBackend;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\User;
|
||||
|
||||
/**
|
||||
|
@ -23,9 +23,9 @@ class AutoLoginBackend extends UserBackend
|
|||
/**
|
||||
* Create new autologin backend
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
$this->stripUsernameRegexp = $config->get('strip_username_regexp');
|
||||
}
|
||||
|
|
|
@ -63,7 +63,8 @@ class Manager
|
|||
);
|
||||
$config = new Config();
|
||||
}
|
||||
if (($preferencesConfig = $config->preferences) !== null) {
|
||||
if ($config->hasSection('preferences')) {
|
||||
$preferencesConfig = $config->getSection('preferences');
|
||||
try {
|
||||
$preferencesStore = PreferencesStore::create(
|
||||
$preferencesConfig,
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace Icinga\Authentication;
|
|||
|
||||
use Countable;
|
||||
use Icinga\Authentication\Backend\AutoLoginBackend;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\User;
|
||||
|
@ -45,7 +45,7 @@ abstract class UserBackend implements Countable
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public static function create($name, Config $backendConfig)
|
||||
public static function create($name, ConfigObject $backendConfig)
|
||||
{
|
||||
if ($backendConfig->name !== null) {
|
||||
$name = $backendConfig->name;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
namespace Icinga\Authentication;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Authentication\Backend\DbUserGroupBackend;
|
||||
use Icinga\Authentication\Backend\IniUserGroupBackend;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
@ -50,13 +50,13 @@ abstract class UserGroupBackend
|
|||
/**
|
||||
* Create a user group backend
|
||||
*
|
||||
* @param string $name
|
||||
* @param Config $backendConfig
|
||||
* @param string $name
|
||||
* @param ConfigObject $backendConfig
|
||||
*
|
||||
* @return DbUserGroupBackend|IniUserGroupBackend
|
||||
* @throws ConfigurationError If the backend configuration is invalid
|
||||
*/
|
||||
public static function create($name, Config $backendConfig)
|
||||
public static function create($name, ConfigObject $backendConfig)
|
||||
{
|
||||
if ($backendConfig->name !== null) {
|
||||
$name = $backendConfig->name;
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Icinga\Data\Db;
|
|||
|
||||
use PDO;
|
||||
use Zend_Db;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\Db\DbQuery;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Data\Selectable;
|
||||
|
@ -21,7 +21,7 @@ class DbConnection implements Selectable
|
|||
/**
|
||||
* Connection config
|
||||
*
|
||||
* @var Config
|
||||
* @var ConfigObject
|
||||
*/
|
||||
private $config;
|
||||
|
||||
|
@ -59,9 +59,9 @@ class DbConnection implements Selectable
|
|||
/**
|
||||
* Create a new connection object
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*/
|
||||
public function __construct(Config $config = null)
|
||||
public function __construct(ConfigObject $config = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
if (isset($config->prefix)) {
|
||||
|
|
|
@ -40,14 +40,15 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
*
|
||||
* @param $resourceName String The resource's name
|
||||
*
|
||||
* @return Config The configuration of the resource
|
||||
* @return ConfigObject The configuration of the resource
|
||||
*
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
public static function getResourceConfig($resourceName)
|
||||
{
|
||||
self::assertResourcesExist();
|
||||
if (($resourceConfig = self::$resources->get($resourceName)) === null) {
|
||||
$resourceConfig = self::$resources->getSection($resourceName);
|
||||
if ($resourceConfig->isEmpty()) {
|
||||
throw new ConfigurationError(
|
||||
'Cannot load resource config "%s". Resource does not exist',
|
||||
$resourceName
|
||||
|
@ -59,24 +60,12 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
/**
|
||||
* Return the configuration of all existing resources, or get all resources of a given type.
|
||||
*
|
||||
* @param String|null $type Fetch only resources that have the given type.
|
||||
*
|
||||
* @return Config The configuration containing all resources
|
||||
*/
|
||||
public static function getResourceConfigs($type = null)
|
||||
public static function getResourceConfigs()
|
||||
{
|
||||
self::assertResourcesExist();
|
||||
if (!isset($type)) {
|
||||
return self::$resources;
|
||||
} else {
|
||||
$resources = array();
|
||||
foreach (self::$resources as $name => $resource) {
|
||||
if (strtolower($resource->type) === $type) {
|
||||
$resources[$name] = $resource;
|
||||
}
|
||||
}
|
||||
return new Config($resources);
|
||||
}
|
||||
return self::$resources;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,13 +88,13 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
* NOTE: The factory does not test if the given configuration is valid and the resource is accessible, this
|
||||
* depends entirely on the implementation of the returned resource.
|
||||
*
|
||||
* @param Config $config The configuration for the created resource.
|
||||
* @param ConfigObject $config The configuration for the created resource.
|
||||
*
|
||||
* @return DbConnection|LdapConnection|LivestatusConnection An object that can be used to access
|
||||
* the given resource. The returned class depends on the configuration property 'type'.
|
||||
* @throws ConfigurationError When an unsupported type is given
|
||||
*/
|
||||
public static function createResource(Config $config)
|
||||
public static function createResource(ConfigObject $config)
|
||||
{
|
||||
switch (strtolower($config->type)) {
|
||||
case 'db':
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Icinga\Protocol\File;
|
||||
|
||||
use Countable;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\Selectable;
|
||||
use Icinga\Data\ConfigObject;
|
||||
|
||||
/**
|
||||
* Read file line by line
|
||||
|
@ -30,11 +30,11 @@ class FileReader implements Selectable, Countable
|
|||
/**
|
||||
* Create a new reader
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*
|
||||
* @throws FileReaderException If a required $config directive (filename or fields) is missing
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
foreach (array('filename', 'fields') as $key) {
|
||||
if (isset($config->{$key})) {
|
||||
|
|
|
@ -8,6 +8,7 @@ use Icinga\Protocol\Ldap\Exception as LdapException;
|
|||
use Icinga\Application\Platform;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Data\ConfigObject;
|
||||
|
||||
/**
|
||||
* Backend class managing all the LDAP stuff for you.
|
||||
|
@ -100,9 +101,9 @@ class Connection
|
|||
*
|
||||
* TODO: Allow to pass port and SSL options
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
$this->hostname = $config->hostname;
|
||||
$this->bind_dn = $config->bind_dn;
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace Icinga\Test {
|
|||
use Mockery;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Data\Db\DbConnection;
|
||||
|
||||
|
@ -195,13 +195,13 @@ namespace Icinga\Test {
|
|||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function createDbConfigFor($name)
|
||||
{
|
||||
if (array_key_exists($name, self::$dbConfiguration)) {
|
||||
return new Config(self::$dbConfiguration[$name]);
|
||||
return new ConfigObject(self::$dbConfiguration[$name]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Configuration for database type not available: ' . $name);
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Icinga\User\Preferences;
|
|||
use Icinga\Application\Config;
|
||||
use Icinga\User;
|
||||
use Icinga\User\Preferences;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Data\Db\DbConnection;
|
||||
|
@ -18,14 +19,14 @@ use Icinga\Data\Db\DbConnection;
|
|||
* <code>
|
||||
* <?php
|
||||
*
|
||||
* use Icinga\Application\Config;
|
||||
* use Icinga\Data\ConfigObject;
|
||||
* use Icinga\User\Preferences;
|
||||
* use Icinga\User\Preferences\PreferencesStore;
|
||||
*
|
||||
* // Create a INI store
|
||||
* $store = PreferencesStore::create(
|
||||
* new Config(
|
||||
* 'type' => 'ini',
|
||||
* new ConfigObject(
|
||||
* 'type' => 'ini',
|
||||
* 'config_path' => '/path/to/preferences'
|
||||
* ),
|
||||
* $user // Instance of \Icinga\User
|
||||
|
@ -41,7 +42,7 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Store config
|
||||
*
|
||||
* @var Config
|
||||
* @var ConfigObject
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
@ -55,10 +56,10 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Create a new store
|
||||
*
|
||||
* @param Config $config The config for this adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
* @param ConfigObject $config The config for this adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
*/
|
||||
public function __construct(Config $config, User $user)
|
||||
public function __construct(ConfigObject $config, User $user)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
|
@ -68,7 +69,7 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Getter for the store config
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function getStoreConfig()
|
||||
{
|
||||
|
@ -107,14 +108,14 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Create preferences storage adapter from config
|
||||
*
|
||||
* @param Config $config The config for the adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
* @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(Config $config, User $user)
|
||||
public static function create(ConfigObject $config, User $user)
|
||||
{
|
||||
if (($type = $config->type) === null) {
|
||||
throw new ConfigurationError(
|
||||
|
|
|
@ -120,7 +120,7 @@ class IniStore extends PreferencesStore
|
|||
|
||||
$this->writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Config($this->preferences),
|
||||
'config' => Config::fromArray($this->preferences),
|
||||
'filename' => $this->preferencesFile
|
||||
)
|
||||
);
|
||||
|
|
|
@ -10,6 +10,7 @@ use RecursiveIterator;
|
|||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Url;
|
||||
|
@ -79,10 +80,10 @@ class Menu implements RecursiveIterator
|
|||
/**
|
||||
* Create a new menu
|
||||
*
|
||||
* @param int $id The id of this menu
|
||||
* @param Config $config The configuration for this menu
|
||||
* @param int $id The id of this menu
|
||||
* @param ConfigObject $config The configuration for this menu
|
||||
*/
|
||||
public function __construct($id, Config $config = null, Menu $parent = null)
|
||||
public function __construct($id, ConfigObject $config = null, Menu $parent = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
if ($parent !== null) {
|
||||
|
@ -94,7 +95,7 @@ class Menu implements RecursiveIterator
|
|||
/**
|
||||
* Set all given properties
|
||||
*
|
||||
* @param array|Config $props Property list
|
||||
* @param array|ConfigObject $props Property list
|
||||
*/
|
||||
public function setProperties($props = null)
|
||||
{
|
||||
|
@ -170,7 +171,7 @@ class Menu implements RecursiveIterator
|
|||
|
||||
foreach ($modules as $moduleName) {
|
||||
$moduleMenuConfig = Config::module($moduleName, 'menu');
|
||||
if (false === empty($moduleMenuConfig)) {
|
||||
if (! $moduleMenuConfig->isEmpty()) {
|
||||
$menuConfigs[] = $moduleMenuConfig;
|
||||
}
|
||||
}
|
||||
|
@ -424,11 +425,11 @@ class Menu implements RecursiveIterator
|
|||
* Add a sub menu to this menu
|
||||
*
|
||||
* @param string $id The id of the menu to add
|
||||
* @param Config $itemConfig The config with which to initialize the menu
|
||||
* @param ConfigObject $itemConfig The config with which to initialize the menu
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function addSubMenu($id, Config $menuConfig = null)
|
||||
public function addSubMenu($id, ConfigObject $menuConfig = null)
|
||||
{
|
||||
if (false === ($pos = strpos($id, '.'))) {
|
||||
$subMenu = new self($id, $menuConfig, $this);
|
||||
|
@ -518,7 +519,7 @@ class Menu implements RecursiveIterator
|
|||
*/
|
||||
public function add($name, $config = array())
|
||||
{
|
||||
return $this->addSubMenu($name, new Config($config));
|
||||
return $this->addSubMenu($name, new ConfigObject($config));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -366,9 +366,7 @@ class Dashboard extends AbstractWidget
|
|||
*/
|
||||
private function loadConfigPanes()
|
||||
{
|
||||
$items = $this->config;
|
||||
foreach ($items->keys() as $key) {
|
||||
$item = $this->config->get($key, false);
|
||||
foreach ($this->config as $key => $item) {
|
||||
if (false === strstr($key, '.')) {
|
||||
$this->addPane(Pane::fromIni($key, $item));
|
||||
} else {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
namespace Icinga\Web\Widget\Dashboard;
|
||||
|
||||
use Zend_Form_Element_Button;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\AbstractWidget;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
||||
/**
|
||||
|
@ -214,13 +214,13 @@ EOD;
|
|||
/**
|
||||
* Create a @see Component instance from the given Zend config, using the provided title
|
||||
*
|
||||
* @param $title The title for this component
|
||||
* @param Config $config The configuration defining url, parameters, height, width, etc.
|
||||
* @param Pane $pane The pane this component belongs to
|
||||
* @param $title The title for this component
|
||||
* @param ConfigObject $config The configuration defining url, parameters, height, width, etc.
|
||||
* @param Pane $pane The pane this component belongs to
|
||||
*
|
||||
* @return Component A newly created Component for use in the Dashboard
|
||||
*/
|
||||
public static function fromIni($title, Config $config, Pane $pane)
|
||||
public static function fromIni($title, ConfigObject $config, Pane $pane)
|
||||
{
|
||||
$height = null;
|
||||
$width = null;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Dashboard;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Web\Widget\AbstractWidget;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -253,11 +253,11 @@ class Pane extends AbstractWidget
|
|||
* Create a new pane with the title $title from the given configuration
|
||||
*
|
||||
* @param $title The title for this pane
|
||||
* @param Config $config The configuration to use for setup
|
||||
* @param ConfigObject $config The configuration to use for setup
|
||||
*
|
||||
* @return Pane
|
||||
*/
|
||||
public static function fromIni($title, Config $config)
|
||||
public static function fromIni($title, ConfigObject $config)
|
||||
{
|
||||
$pane = new Pane($title);
|
||||
if ($config->get('title', false)) {
|
||||
|
|
|
@ -73,12 +73,12 @@ class BackendConfigForm extends ConfigForm
|
|||
$name = isset($values['name']) ? $values['name'] : '';
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing'));
|
||||
} elseif ($this->config->get($name) !== null) {
|
||||
} elseif ($this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend already exists'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
$this->config->{$name} = $values;
|
||||
$this->config->setSection($name, $values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -98,14 +98,13 @@ class BackendConfigForm extends ConfigForm
|
|||
throw new InvalidArgumentException(mt('monitoring', 'Old monitoring backend name missing'));
|
||||
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'New monitoring backend name missing'));
|
||||
} elseif (($backendConfig = $this->config->get($name)) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
unset($this->config->{$name});
|
||||
$this->config->{$newName} = $values;
|
||||
return $this->config->{$newName};
|
||||
$this->config->setSection($name, $values);
|
||||
return $this->config->getSection($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,11 +120,12 @@ class BackendConfigForm extends ConfigForm
|
|||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing'));
|
||||
} elseif (($backendConfig = $this->config->get($name)) === null) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided'));
|
||||
}
|
||||
|
||||
unset($this->config->{$name});
|
||||
$backendConfig = $this->config->getSection($name);
|
||||
$this->config->removeSection($name);
|
||||
return $backendConfig;
|
||||
}
|
||||
|
||||
|
@ -170,11 +170,11 @@ class BackendConfigForm extends ConfigForm
|
|||
if ($monitoringBackend !== null) {
|
||||
if ($monitoringBackend === '') {
|
||||
throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing'));
|
||||
} elseif (false === isset($this->config->{$monitoringBackend})) {
|
||||
} elseif (! $this->config->hasSection($monitoringBackend)) {
|
||||
throw new ConfigurationError(mt('monitoring', 'Unknown monitoring backend provided'));
|
||||
}
|
||||
|
||||
$backendConfig = $this->config->{$monitoringBackend}->toArray();
|
||||
$backendConfig = $this->config->getSection($monitoringBackend)->toArray();
|
||||
$backendConfig['name'] = $monitoringBackend;
|
||||
$this->populate($backendConfig);
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ class InstanceConfigForm extends ConfigForm
|
|||
if (! $name) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Instance name missing'));
|
||||
}
|
||||
if (isset($this->config->{$name})) {
|
||||
if ($this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Instance already exists'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
$this->config->{$name} = $values;
|
||||
$this->config->setSection($name, $values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -96,14 +96,13 @@ class InstanceConfigForm extends ConfigForm
|
|||
throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing'));
|
||||
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'New instance name missing'));
|
||||
} elseif (! ($instanceConfig = $this->config->get($name))) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
unset($this->config->{$name});
|
||||
$this->config->{$newName} = $values;
|
||||
return $this->config->{$newName};
|
||||
$this->config->setSection($name, $values);
|
||||
return $this->config->getSection($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,11 +118,12 @@ class InstanceConfigForm extends ConfigForm
|
|||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Instance name missing'));
|
||||
} elseif (! ($instanceConfig = $this->config->get($name))) {
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided'));
|
||||
}
|
||||
|
||||
unset($this->config->{$name});
|
||||
$instanceConfig = $this->config->getSection($name);
|
||||
$this->config->removeSection($name);
|
||||
return $instanceConfig;
|
||||
}
|
||||
|
||||
|
@ -138,11 +138,11 @@ class InstanceConfigForm extends ConfigForm
|
|||
if (! $instanceName) {
|
||||
throw new ConfigurationError(mt('monitoring', 'Instance name missing'));
|
||||
}
|
||||
if (! isset($this->config->{$instanceName})) {
|
||||
if (! $this->config->hasSection($instanceName)) {
|
||||
throw new ConfigurationError(mt('monitoring', 'Unknown instance name given'));
|
||||
}
|
||||
|
||||
$instanceConfig = $this->config->{$instanceName}->toArray();
|
||||
$instanceConfig = $this->config->getSection($instanceName)->toArray();
|
||||
$instanceConfig['name'] = $instanceName;
|
||||
$this->populate($instanceConfig);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class SecurityConfigForm extends ConfigForm
|
|||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
$this->config->security = $this->getValues();
|
||||
$this->config->setSection('security', $this->getValues());
|
||||
|
||||
if ($this->save()) {
|
||||
Notification::success(mt('monitoring', 'New security configuration has successfully been stored'));
|
||||
|
@ -40,9 +40,7 @@ class SecurityConfigForm extends ConfigForm
|
|||
*/
|
||||
public function onRequest()
|
||||
{
|
||||
if (isset($this->config->security)) {
|
||||
$this->populate($this->config->security->toArray());
|
||||
}
|
||||
$this->populate($this->config->getSection('security')->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Monitoring\Backend;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Data\ConnectionInterface;
|
||||
use Icinga\Data\Queryable;
|
||||
|
@ -16,7 +17,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
|||
/**
|
||||
* Backend configuration
|
||||
*
|
||||
* @var Config
|
||||
* @var ConfigObject
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
@ -51,10 +52,10 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
|||
/**
|
||||
* Create a new backend
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $config
|
||||
* @param string $name
|
||||
* @param ConfigObject $config
|
||||
*/
|
||||
protected function __construct($name, $config)
|
||||
protected function __construct($name, ConfigObject $config)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->config = $config;
|
||||
|
@ -180,9 +181,9 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
|||
|
||||
} else {
|
||||
|
||||
$config = $backends->get($name);
|
||||
$config = $backends->getSection($name);
|
||||
|
||||
if ($config === null) {
|
||||
if ($config->isEmpty()) {
|
||||
throw new ConfigurationError(
|
||||
mt('monitoring', 'No configuration for backend %s'),
|
||||
$name
|
||||
|
|
|
@ -39,7 +39,7 @@ class BackendStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config($config),
|
||||
'config' => Config::fromArray($config),
|
||||
'filename' => Config::resolvePath('modules/monitoring/backends.ini')
|
||||
));
|
||||
$writer->write();
|
||||
|
@ -60,7 +60,7 @@ class BackendStep extends Step
|
|||
|
||||
try {
|
||||
$config = Config::app('resources', true);
|
||||
$config->merge(new Config(array($resourceName => $resourceConfig)));
|
||||
$config->setSection($resourceName, $resourceConfig);
|
||||
|
||||
$writer = new IniWriter(array(
|
||||
'config' => $config,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Icinga\Module\Monitoring\Command\Transport;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +32,7 @@ abstract class CommandTransport
|
|||
{
|
||||
if (! isset(self::$config)) {
|
||||
self::$config = Config::module('monitoring', 'instances');
|
||||
if (self::$config->count() === 0) {
|
||||
if (self::$config->isEmpty()) {
|
||||
throw new ConfigurationError(
|
||||
'No instances have been configured in \'%s\'.',
|
||||
self::$config->getConfigFile()
|
||||
|
@ -44,12 +45,12 @@ abstract class CommandTransport
|
|||
/**
|
||||
* Create a transport from config
|
||||
*
|
||||
* @param Config $config
|
||||
* @param ConfigObject $config
|
||||
*
|
||||
* @return LocalCommandFile|RemoteCommandFile
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
public static function fromConfig(Config $config)
|
||||
public static function fromConfig(ConfigObject $config)
|
||||
{
|
||||
switch (strtolower($config->transport)) {
|
||||
case RemoteCommandFile::TRANSPORT:
|
||||
|
@ -90,8 +91,8 @@ abstract class CommandTransport
|
|||
*/
|
||||
public static function create($name)
|
||||
{
|
||||
$config = self::getConfig()->get($name);
|
||||
if ($config === null) {
|
||||
$config = self::getConfig()->getSection($name);
|
||||
if ($config->isEmpty()) {
|
||||
throw new ConfigurationError();
|
||||
}
|
||||
return self::fromConfig($config);
|
||||
|
|
|
@ -28,7 +28,7 @@ class InstanceStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config(array($instanceName => $instanceConfig)),
|
||||
'config' => Config::fromArray(array($instanceName => $instanceConfig)),
|
||||
'filename' => Config::resolvePath('modules/monitoring/instances.ini')
|
||||
));
|
||||
$writer->write();
|
||||
|
|
|
@ -290,10 +290,7 @@ abstract class MonitoredObject
|
|||
$blacklist = array();
|
||||
$blacklistPattern = '/^(.*pw.*|.*pass.*|community)$/i';
|
||||
|
||||
if ($security = Config::module('monitoring')->get('security')) {
|
||||
|
||||
$blacklistConfig = $security->get('protected_customvars', '');
|
||||
|
||||
if (($blacklistConfig = Config::module('monitoring')->get('security', 'protected_customvars', '')) !== '') {
|
||||
foreach (explode(',', $blacklistConfig) as $customvar) {
|
||||
$nonWildcards = array();
|
||||
foreach (explode('*', $customvar) as $nonWildcard) {
|
||||
|
|
|
@ -27,7 +27,7 @@ class SecurityStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config($config),
|
||||
'config' => Config::fromArray($config),
|
||||
'filename' => Config::resolvePath('modules/monitoring/config.ini')
|
||||
));
|
||||
$writer->write();
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Tests\Icinga\Module\Monitoring\Regression;
|
|||
require_once realpath(dirname(__FILE__) . '/../../../../../test/php/bootstrap.php');
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Mockery;
|
||||
|
@ -45,7 +46,7 @@ class Bug7043Test extends BaseTestCase
|
|||
->getMock()
|
||||
);
|
||||
|
||||
ConfigWithSetModuleConfig::setModuleConfig('monitoring', 'backends', new Config(array(
|
||||
ConfigWithSetModuleConfig::setModuleConfig('monitoring', 'backends', new ConfigObject(array(
|
||||
'backendName' => array(
|
||||
'type' => 'ido',
|
||||
'resource' => 'ido'
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Icinga\Module\Setup\Forms;
|
|||
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||
|
@ -253,10 +253,10 @@ class AdminAccountPage extends Form
|
|||
protected function fetchUsers()
|
||||
{
|
||||
if ($this->backendConfig['backend'] === 'db') {
|
||||
$backend = new DbUserBackend(ResourceFactory::createResource(new Config($this->resourceConfig)));
|
||||
$backend = new DbUserBackend(ResourceFactory::createResource(new ConfigObject($this->resourceConfig)));
|
||||
} elseif ($this->backendConfig['backend'] === 'ldap') {
|
||||
$backend = new LdapUserBackend(
|
||||
ResourceFactory::createResource(new Config($this->resourceConfig)),
|
||||
ResourceFactory::createResource(new ConfigObject($this->resourceConfig)),
|
||||
$this->backendConfig['user_class'],
|
||||
$this->backendConfig['user_name_attribute'],
|
||||
$this->backendConfig['base_dn']
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
namespace Icinga\Module\Setup\Forms;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\AutologinBackendForm;
|
||||
use Icinga\Data\ConfigObject;
|
||||
|
||||
/**
|
||||
* Wizard page to define authentication backend specific details
|
||||
|
@ -46,11 +46,11 @@ class AuthBackendPage extends Form
|
|||
/**
|
||||
* Return the resource configuration as Config object
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function getResourceConfig()
|
||||
{
|
||||
return new Config($this->config);
|
||||
return new ConfigObject($this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Setup\Forms;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
|
@ -56,11 +56,11 @@ EOT;
|
|||
/**
|
||||
* Return the resource configuration as Config object
|
||||
*
|
||||
* @return Config
|
||||
* @return ConfigObject
|
||||
*/
|
||||
public function getResourceConfig()
|
||||
{
|
||||
return new Config($this->config);
|
||||
return new ConfigObject($this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Icinga\Module\Setup\Steps;
|
|||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\File\Ini\IniWriter;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
use Icinga\Module\Setup\Step;
|
||||
|
@ -50,7 +51,7 @@ class AuthenticationStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config($config),
|
||||
'config' => Config::fromArray($config),
|
||||
'filename' => Config::resolvePath('authentication.ini')
|
||||
));
|
||||
$writer->write();
|
||||
|
@ -73,7 +74,7 @@ class AuthenticationStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config($config),
|
||||
'config' => Config::fromArray($config),
|
||||
'filename' => Config::resolvePath('permissions.ini')
|
||||
));
|
||||
$writer->write();
|
||||
|
@ -90,7 +91,7 @@ class AuthenticationStep extends Step
|
|||
{
|
||||
try {
|
||||
$backend = new DbUserBackend(
|
||||
ResourceFactory::createResource(new Config($this->data['adminAccountData']['resourceConfig']))
|
||||
ResourceFactory::createResource(new ConfigObject($this->data['adminAccountData']['resourceConfig']))
|
||||
);
|
||||
|
||||
if (array_search($this->data['adminAccountData']['username'], $backend->listUsers()) === false) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class GeneralConfigStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config($config),
|
||||
'config' => Config::fromArray($config),
|
||||
'filename' => Config::resolvePath('config.ini')
|
||||
));
|
||||
$writer->write();
|
||||
|
|
|
@ -39,7 +39,7 @@ class ResourceStep extends Step
|
|||
|
||||
try {
|
||||
$writer = new IniWriter(array(
|
||||
'config' => new Config($resourceConfig),
|
||||
'config' => Config::fromArray($resourceConfig),
|
||||
'filename' => Config::resolvePath('resources.ini'),
|
||||
'filemode' => 0660
|
||||
));
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Tests\Icinga\Forms\Config\Authentication;
|
|||
require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
|
||||
|
||||
use Mockery;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
|
||||
|
@ -71,6 +71,6 @@ class DbBackendFormTest extends BaseTestCase
|
|||
->shouldReceive('createResource')
|
||||
->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection'))
|
||||
->shouldReceive('getResourceConfig')
|
||||
->andReturn(new Config());
|
||||
->andReturn(new ConfigObject());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace Tests\Icinga\Forms\Config\Authentication;
|
|||
require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
|
||||
|
||||
use Mockery;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Exception\AuthenticationException;
|
||||
|
||||
|
@ -70,6 +70,6 @@ class LdapBackendFormTest extends BaseTestCase
|
|||
->shouldReceive('createResource')
|
||||
->andReturn(Mockery::mock('Icinga\Protocol\Ldap\Connection'))
|
||||
->shouldReceive('getResourceConfig')
|
||||
->andReturn(new Config());
|
||||
->andReturn(new ConfigObject());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class AuthenticationBackendReorderFormTest extends BaseTestCase
|
|||
{
|
||||
public function testMoveBackend()
|
||||
{
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'test1' => '',
|
||||
'test2' => '',
|
||||
|
|
|
@ -56,7 +56,7 @@ class DbResourceFormTest extends BaseTestCase
|
|||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('Icinga\Application\Config'))
|
||||
->with(Mockery::type('Icinga\Data\ConfigObject'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class LdapResourceFormTest extends BaseTestCase
|
|||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('Icinga\Application\Config'))
|
||||
->with(Mockery::type('Icinga\Data\ConfigObject'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class LivestatusResourceFormTest extends BaseTestCase
|
|||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('Icinga\Application\Config'))
|
||||
->with(Mockery::type('Icinga\Data\ConfigObject'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Config(
|
||||
'config' => Config::fromArray(
|
||||
array(
|
||||
'section' => array(
|
||||
'foo.bar' => 1337
|
||||
|
@ -57,7 +57,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Config(array('key' => 'value'));
|
||||
$config = Config::fromArray(array('key' => 'value'));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -69,7 +69,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('key1 = "1"');
|
||||
$config = new Config(array('key2' => '2'));
|
||||
$config = Config::fromArray(array('key2' => '2'));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -84,7 +84,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('key = "value"');
|
||||
$config = new Config(array('key' => 'eulav'));
|
||||
$config = Config::fromArray(array('key' => 'eulav'));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -99,7 +99,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('key = "value"');
|
||||
$config = new Config(array());
|
||||
$config = new Config();
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -110,19 +110,19 @@ class IniWriterTest extends BaseTestCase
|
|||
public function testWhetherNestedPropertiesAreInserted()
|
||||
{
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Config(array('a' => array('b' => 'c')));
|
||||
$config = Config::fromArray(array('a' => array('b' => 'c')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
get_class($newConfig),
|
||||
$newConfig->get('a'),
|
||||
'Icinga\Data\ConfigObject',
|
||||
$newConfig->getSection('a'),
|
||||
'IniWriter does not insert nested properties'
|
||||
);
|
||||
$this->assertEquals(
|
||||
'c',
|
||||
$newConfig->get('a')->get('b'),
|
||||
$newConfig->getSection('a')->get('b'),
|
||||
'IniWriter does not insert nested properties'
|
||||
);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('a.b = "c"');
|
||||
$config = new Config(array('a' => array('b' => 'cc')));
|
||||
$config = Config::fromArray(array('a' => array('b' => 'cc')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -158,7 +158,7 @@ class IniWriterTest extends BaseTestCase
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('a.b = "c"');
|
||||
$config = new Config(array());
|
||||
$config = new Config();
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -172,19 +172,19 @@ class IniWriterTest extends BaseTestCase
|
|||
public function testWhetherSimpleSectionPropertiesAreInserted()
|
||||
{
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Config(array('section' => array('key' => 'value')));
|
||||
$config = Config::fromArray(array('section' => array('key' => 'value')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
get_class($newConfig),
|
||||
$newConfig->get('section'),
|
||||
'Icinga\Data\ConfigObject',
|
||||
$newConfig->getSection('section'),
|
||||
'IniWriter does not insert sections'
|
||||
);
|
||||
$this->assertEquals(
|
||||
'value',
|
||||
$newConfig->get('section')->get('key'),
|
||||
$newConfig->getSection('section')->get('key'),
|
||||
'IniWriter does not insert simple section properties'
|
||||
);
|
||||
}
|
||||
|
@ -199,14 +199,14 @@ class IniWriterTest extends BaseTestCase
|
|||
key = "value"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(array('section' => array('key' => 'eulav')));
|
||||
$config = Config::fromArray(array('section' => array('key' => 'eulav')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals(
|
||||
'eulav',
|
||||
$newConfig->get('section')->get('key'),
|
||||
$newConfig->getSection('section')->get('key'),
|
||||
'IniWriter does not update simple section properties'
|
||||
);
|
||||
}
|
||||
|
@ -221,13 +221,13 @@ EOD
|
|||
key = "value"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(array('section' => array()));
|
||||
$config = Config::fromArray(array('section' => array()));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull(
|
||||
$newConfig->get('section')->get('key'),
|
||||
$newConfig->getSection('section')->get('key'),
|
||||
'IniWriter does not delete simple section properties'
|
||||
);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ EOD
|
|||
{
|
||||
$this->markTestSkipped('Implementation has changed. Config::fromIni cannot handle nested properties anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Config(array('section' => array('a' => array('b' => 'c'))));
|
||||
$config = Config::fromArray(array('section' => array('a' => array('b' => 'c'))));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -268,7 +268,7 @@ EOD
|
|||
a.b = "c"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(array('section' => array('a' => array('b' => 'cc'))));
|
||||
$config = Config::fromArray(array('section' => array('a' => array('b' => 'cc'))));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -290,7 +290,7 @@ EOD
|
|||
a.b = "c"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(array('section' => array()));
|
||||
$config = Config::fromArray(array('section' => array()));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
|
@ -307,7 +307,7 @@ EOD
|
|||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'foo' => array('key1' => '1'),
|
||||
'bar' => array('key2' => '2')
|
||||
|
@ -356,7 +356,7 @@ key1 = "1"
|
|||
key2 = "2"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'foo' => array('key1' => '1'),
|
||||
'bar' => array('key2' => '22')
|
||||
|
@ -390,7 +390,7 @@ key1 = "1"
|
|||
key2 = "2"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'foo' => array('key1' => '1'),
|
||||
'bar' => array()
|
||||
|
@ -413,7 +413,7 @@ EOD
|
|||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'foo' => array('a' => array('b' => 'c')),
|
||||
'bar' => array('d' => array('e' => 'f'))
|
||||
|
@ -464,7 +464,7 @@ a.b = "c"
|
|||
d.e = "f"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'foo' => array('a' => array('b' => 'c')),
|
||||
'bar' => array('d' => array('e' => 'ff'))
|
||||
|
@ -498,7 +498,7 @@ a.b = "c"
|
|||
d.e = "f"
|
||||
EOD
|
||||
);
|
||||
$config = new Config(
|
||||
$config = Config::fromArray(
|
||||
array(
|
||||
'foo' => array('a' => array('b' => 'c')),
|
||||
'bar' => array()
|
||||
|
@ -551,7 +551,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Config(
|
||||
'config' => Config::fromArray(
|
||||
array(
|
||||
'three' => array(
|
||||
'foo' => array(
|
||||
|
@ -606,7 +606,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Config(
|
||||
'config' => Config::fromArray(
|
||||
array(
|
||||
'two' => array(),
|
||||
'one' => array()
|
||||
|
@ -634,7 +634,7 @@ key = "value"
|
|||
EOD;
|
||||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array('config' => new Config(array('key' => 'value')), 'filename' => $target)
|
||||
array('config' => Config::fromArray(array('key' => 'value')), 'filename' => $target)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -655,7 +655,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Config(
|
||||
'config' => Config::fromArray(
|
||||
array(
|
||||
'foo' => 1337,
|
||||
'bar' => 7331,
|
||||
|
@ -683,7 +683,7 @@ key = "value"
|
|||
EOD;
|
||||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array('config' => new Config(array('section' => array('key' => 'value'))), 'filename' => $target)
|
||||
array('config' => Config::fromArray(array('section' => array('key' => 'value'))), 'filename' => $target)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -705,7 +705,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Config(
|
||||
'config' => Config::fromArray(
|
||||
array(
|
||||
'section' => array(
|
||||
'foo' => 1337,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Tests\Icinga\Logger\Writer;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\Writer\FileWriter;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
@ -27,7 +27,7 @@ class StreamWriterTest extends BaseTestCase
|
|||
|
||||
public function testWhetherStreamWriterCreatesMissingFiles()
|
||||
{
|
||||
new FileWriter(new Config(array('file' => $this->target)));
|
||||
new FileWriter(new ConfigObject(array('file' => $this->target)));
|
||||
$this->assertFileExists($this->target, 'StreamWriter does not create missing files on initialization');
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class StreamWriterTest extends BaseTestCase
|
|||
*/
|
||||
public function testWhetherStreamWriterWritesMessages()
|
||||
{
|
||||
$writer = new FileWriter(new Config(array('file' => $this->target)));
|
||||
$writer = new FileWriter(new ConfigObject(array('file' => $this->target)));
|
||||
$writer->log(Logger::ERROR, 'This is a test error');
|
||||
$log = file_get_contents($this->target);
|
||||
$this->assertContains('This is a test error', $log, 'StreamWriter does not write log messages');
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
namespace Tests\Icinga\Protocol\Ldap;
|
||||
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Protocol\Ldap\Connection;
|
||||
|
||||
class QueryTest extends BaseTestCase
|
||||
{
|
||||
private function emptySelect()
|
||||
{
|
||||
$config = new Config(
|
||||
$config = new ConfigObject(
|
||||
array(
|
||||
'hostname' => 'localhost',
|
||||
'root_dn' => 'dc=example,dc=com',
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Tests\Icinga\User\Preferences\Store;
|
||||
|
||||
use Mockery;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\NotWritableError;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\User\Preferences\Store\DbStore;
|
||||
|
@ -165,7 +165,7 @@ class DbStoreTest extends BaseTestCase
|
|||
protected function getStore($dbMock)
|
||||
{
|
||||
return new DbStoreWithSetPreferences(
|
||||
new Config(
|
||||
new ConfigObject(
|
||||
array(
|
||||
'connection' => Mockery::mock(array('getDbAdapter' => $dbMock))
|
||||
)
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Tests\Icinga\User\Preferences\Store;
|
||||
|
||||
use Mockery;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\User\Preferences\Store\IniStore;
|
||||
|
||||
class IniStoreWithSetGetPreferencesAndEmptyWrite extends IniStore
|
||||
|
@ -61,7 +61,7 @@ class IniStoreTest extends BaseTestCase
|
|||
protected function getStore()
|
||||
{
|
||||
return new IniStoreWithSetGetPreferencesAndEmptyWrite(
|
||||
new Config(
|
||||
new ConfigObject(
|
||||
array(
|
||||
'location' => 'some/Path/To/Some/Directory'
|
||||
)
|
||||
|
|
|
@ -6,19 +6,19 @@ namespace Tests\Icinga\Web;
|
|||
|
||||
use Icinga\Web\Menu;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ConfigObject;
|
||||
|
||||
class MenuTest extends BaseTestCase
|
||||
{
|
||||
public function testWhetherMenusAreNaturallySorted()
|
||||
{
|
||||
$menu = new Menu('test');
|
||||
$menu->addSubMenu(5, new Config(array('title' => 'ccc5')));
|
||||
$menu->addSubMenu(0, new Config(array('title' => 'aaa')));
|
||||
$menu->addSubMenu(3, new Config(array('title' => 'ccc')));
|
||||
$menu->addSubMenu(2, new Config(array('title' => 'bbb')));
|
||||
$menu->addSubMenu(4, new Config(array('title' => 'ccc2')));
|
||||
$menu->addSubMenu(1, new Config(array('title' => 'bb')));
|
||||
$menu->addSubMenu(5, new ConfigObject(array('title' => 'ccc5')));
|
||||
$menu->addSubMenu(0, new ConfigObject(array('title' => 'aaa')));
|
||||
$menu->addSubMenu(3, new ConfigObject(array('title' => 'ccc')));
|
||||
$menu->addSubMenu(2, new ConfigObject(array('title' => 'bbb')));
|
||||
$menu->addSubMenu(4, new ConfigObject(array('title' => 'ccc2')));
|
||||
$menu->addSubMenu(1, new ConfigObject(array('title' => 'bb')));
|
||||
|
||||
$this->assertEquals(
|
||||
array('aaa', 'bb', 'bbb', 'ccc', 'ccc2', 'ccc5'),
|
||||
|
|
Loading…
Reference in New Issue