Prefer Icinga\Application\Config over Zend_Config

refs #7163
This commit is contained in:
Johannes Meyer 2014-11-11 12:11:14 +01:00
parent d2f8fd750f
commit af99f62843
14 changed files with 27 additions and 31 deletions

View File

@ -5,6 +5,7 @@
namespace Icinga\Form\Config\Authentication; namespace Icinga\Form\Config\Authentication;
use Exception; use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Request; use Icinga\Web\Request;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
@ -121,7 +122,7 @@ class DbBackendForm extends Form
/** /**
* Return the configuration for the chosen resource * Return the configuration for the chosen resource
* *
* @return Zend_Config * @return Config
*/ */
public function getResourceConfig() public function getResourceConfig()
{ {

View File

@ -5,6 +5,7 @@
namespace Icinga\Form\Config\Authentication; namespace Icinga\Form\Config\Authentication;
use Exception; use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Request; use Icinga\Web\Request;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
@ -156,7 +157,7 @@ class LdapBackendForm extends Form
/** /**
* Return the configuration for the chosen resource * Return the configuration for the chosen resource
* *
* @return Zend_Config * @return Config
*/ */
public function getResourceConfig() public function getResourceConfig()
{ {

View File

@ -333,7 +333,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
/** /**
* Return the configuration for the chosen resource * Return the configuration for the chosen resource
* *
* @return Zend_Config * @return Config
*/ */
public function getResourceConfig() public function getResourceConfig()
{ {

View File

@ -5,7 +5,6 @@
namespace Icinga\Module\Monitoring; namespace Icinga\Module\Monitoring;
use Exception; use Exception;
use Zend_Config;
use Icinga\Module\Setup\Step; use Icinga\Module\Setup\Step;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter; use Icinga\File\Ini\IniWriter;
@ -40,7 +39,7 @@ class BackendStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config($config), 'config' => new Config($config),
'filename' => Config::resolvePath('modules/monitoring/backends.ini'), 'filename' => Config::resolvePath('modules/monitoring/backends.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));
@ -62,7 +61,7 @@ class BackendStep extends Step
try { try {
$config = Config::app('resources', true); $config = Config::app('resources', true);
$config->merge(new Zend_Config(array($resourceName => $resourceConfig))); $config->merge(new Config(array($resourceName => $resourceConfig)));
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => $config, 'config' => $config,

View File

@ -5,7 +5,6 @@
namespace Icinga\Module\Monitoring; namespace Icinga\Module\Monitoring;
use Exception; use Exception;
use Zend_Config;
use Icinga\Module\Setup\Step; use Icinga\Module\Setup\Step;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter; use Icinga\File\Ini\IniWriter;
@ -29,7 +28,7 @@ class InstanceStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config(array($instanceName => $instanceConfig)), 'config' => new Config(array($instanceName => $instanceConfig)),
'filename' => Config::resolvePath('modules/monitoring/instances.ini'), 'filename' => Config::resolvePath('modules/monitoring/instances.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));

View File

@ -5,7 +5,6 @@
namespace Icinga\Module\Monitoring; namespace Icinga\Module\Monitoring;
use Exception; use Exception;
use Zend_Config;
use Icinga\Module\Setup\Step; use Icinga\Module\Setup\Step;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter; use Icinga\File\Ini\IniWriter;
@ -28,7 +27,7 @@ class SecurityStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config($config), 'config' => new Config($config),
'filename' => Config::resolvePath('modules/monitoring/config.ini'), 'filename' => Config::resolvePath('modules/monitoring/config.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));

View File

@ -5,8 +5,8 @@
namespace Icinga\Module\Setup\Form; namespace Icinga\Module\Setup\Form;
use Exception; use Exception;
use Zend_Config;
use LogicException; use LogicException;
use Icinga\Application\Config;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
use Icinga\Web\Form\Element\Note; use Icinga\Web\Form\Element\Note;
@ -244,10 +244,10 @@ class AdminAccountPage extends Form
protected function fetchUsers() protected function fetchUsers()
{ {
if ($this->backendConfig['backend'] === 'db') { if ($this->backendConfig['backend'] === 'db') {
$backend = new DbUserBackend(ResourceFactory::createResource(new Zend_Config($this->resourceConfig))); $backend = new DbUserBackend(ResourceFactory::createResource(new Config($this->resourceConfig)));
} elseif ($this->backendConfig['backend'] === 'ldap') { } elseif ($this->backendConfig['backend'] === 'ldap') {
$backend = new LdapUserBackend( $backend = new LdapUserBackend(
ResourceFactory::createResource(new Zend_Config($this->resourceConfig)), ResourceFactory::createResource(new Config($this->resourceConfig)),
$this->backendConfig['user_class'], $this->backendConfig['user_class'],
$this->backendConfig['user_name_attribute'], $this->backendConfig['user_name_attribute'],
$this->backendConfig['base_dn'] $this->backendConfig['base_dn']

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Setup\Form; namespace Icinga\Module\Setup\Form;
use Zend_Config; use Icinga\Application\Config;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Form\Element\Note; use Icinga\Web\Form\Element\Note;
use Icinga\Form\Config\Authentication\DbBackendForm; use Icinga\Form\Config\Authentication\DbBackendForm;
@ -45,13 +45,13 @@ class AuthBackendPage extends Form
} }
/** /**
* Return the resource configuration as Zend_Config object * Return the resource configuration as Config object
* *
* @return Zend_Config * @return Config
*/ */
public function getResourceConfig() public function getResourceConfig()
{ {
return new Zend_Config($this->config); return new Config($this->config);
} }
/** /**

View File

@ -4,6 +4,7 @@
namespace Icinga\Module\Setup\Form; namespace Icinga\Module\Setup\Form;
use Icinga\Application\Config;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Form\Element\Note; use Icinga\Web\Form\Element\Note;
@ -55,13 +56,13 @@ EOT;
} }
/** /**
* Return the resource configuration as Zend_Config object * Return the resource configuration as Config object
* *
* @return Zend_Config * @return Config
*/ */
public function getResourceConfig() public function getResourceConfig()
{ {
return new Zend_Config($this->config); return new Config($this->config);
} }
/** /**

View File

@ -5,7 +5,6 @@
namespace Icinga\Module\Setup\Steps; namespace Icinga\Module\Setup\Steps;
use Exception; use Exception;
use Zend_Config;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter; use Icinga\File\Ini\IniWriter;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
@ -51,7 +50,7 @@ class AuthenticationStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config($config), 'config' => new Config($config),
'filename' => Config::resolvePath('authentication.ini'), 'filename' => Config::resolvePath('authentication.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));
@ -75,7 +74,7 @@ class AuthenticationStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config($config), 'config' => new Config($config),
'filename' => Config::resolvePath('permissions.ini'), 'filename' => Config::resolvePath('permissions.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));
@ -93,7 +92,7 @@ class AuthenticationStep extends Step
{ {
try { try {
$backend = new DbUserBackend( $backend = new DbUserBackend(
ResourceFactory::createResource(new Zend_Config($this->data['adminAccountData']['resourceConfig'])) ResourceFactory::createResource(new Config($this->data['adminAccountData']['resourceConfig']))
); );
if (array_search($this->data['adminAccountData']['username'], $backend->listUsers()) === false) { if (array_search($this->data['adminAccountData']['username'], $backend->listUsers()) === false) {

View File

@ -5,7 +5,6 @@
namespace Icinga\Module\Setup\Steps; namespace Icinga\Module\Setup\Steps;
use Exception; use Exception;
use Zend_Config;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter; use Icinga\File\Ini\IniWriter;
@ -37,7 +36,7 @@ class GeneralConfigStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config($config), 'config' => new Config($config),
'filename' => Config::resolvePath('config.ini'), 'filename' => Config::resolvePath('config.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));

View File

@ -5,7 +5,6 @@
namespace Icinga\Module\Setup\Steps; namespace Icinga\Module\Setup\Steps;
use Exception; use Exception;
use Zend_Config;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter; use Icinga\File\Ini\IniWriter;
use Icinga\Module\Setup\Step; use Icinga\Module\Setup\Step;
@ -40,7 +39,7 @@ class ResourceStep extends Step
try { try {
$writer = new IniWriter(array( $writer = new IniWriter(array(
'config' => new Zend_Config($resourceConfig), 'config' => new Config($resourceConfig),
'filename' => Config::resolvePath('resources.ini'), 'filename' => Config::resolvePath('resources.ini'),
'filemode' => octdec($this->data['fileMode']) 'filemode' => octdec($this->data['fileMode'])
)); ));

View File

@ -9,7 +9,7 @@ namespace Tests\Icinga\Form\Config\Authentication;
require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php'); require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
use Mockery; use Mockery;
use Zend_Config; use Icinga\Application\Config;
use Icinga\Test\BaseTestCase; use Icinga\Test\BaseTestCase;
use Icinga\Form\Config\Authentication\DbBackendForm; use Icinga\Form\Config\Authentication\DbBackendForm;
@ -71,6 +71,6 @@ class DbBackendFormTest extends BaseTestCase
->shouldReceive('createResource') ->shouldReceive('createResource')
->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection')) ->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection'))
->shouldReceive('getResourceConfig') ->shouldReceive('getResourceConfig')
->andReturn(new Zend_Config(array())); ->andReturn(new Config());
} }
} }

View File

@ -9,7 +9,6 @@ namespace Tests\Icinga\Form\Config\Authentication;
require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php'); require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
use Mockery; use Mockery;
use Zend_Config;
use Icinga\Test\BaseTestCase; use Icinga\Test\BaseTestCase;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Form\Config\Authentication\LdapBackendForm; use Icinga\Form\Config\Authentication\LdapBackendForm;