diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index c12860e72..b39f57734 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -7,7 +7,7 @@ use Icinga\Web\Notification; use Icinga\Application\Modules\Module; use Icinga\Web\Widget; use Icinga\Application\Icinga; -use Icinga\Application\Config as IcingaConfig; +use Icinga\Application\Config; use Icinga\Form\Config\GeneralConfigForm; use Icinga\Form\Config\AuthenticationBackendReorderForm; use Icinga\Form\Config\AuthenticationBackendConfigForm; @@ -46,7 +46,7 @@ class ConfigController extends ActionController public function indexAction() { $form = new GeneralConfigForm(); - $form->setIniConfig(IcingaConfig::app()); + $form->setIniConfig(Config::app()); $form->handleRequest(); $this->view->form = $form; @@ -131,7 +131,7 @@ class ConfigController extends ActionController public function authenticationAction() { $form = new AuthenticationBackendReorderForm(); - $form->setIniConfig(IcingaConfig::app('authentication')); + $form->setIniConfig(Config::app('authentication')); $form->handleRequest(); $this->view->form = $form; @@ -145,7 +145,7 @@ class ConfigController extends ActionController public function createauthenticationbackendAction() { $form = new AuthenticationBackendConfigForm(); - $form->setIniConfig(IcingaConfig::app('authentication')); + $form->setIniConfig(Config::app('authentication')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); $form->setRedirectUrl('config/authentication'); $form->handleRequest(); @@ -161,7 +161,7 @@ class ConfigController extends ActionController public function editauthenticationbackendAction() { $form = new AuthenticationBackendConfigForm(); - $form->setIniConfig(IcingaConfig::app('authentication')); + $form->setIniConfig(Config::app('authentication')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); $form->setRedirectUrl('config/authentication'); $form->handleRequest(); @@ -179,7 +179,7 @@ class ConfigController extends ActionController $form = new ConfirmRemovalForm(array( 'onSuccess' => function ($request) { $configForm = new AuthenticationBackendConfigForm(); - $configForm->setIniConfig(IcingaConfig::app('authentication')); + $configForm->setIniConfig(Config::app('authentication')); $authBackend = $request->getQuery('auth_backend'); try { @@ -212,7 +212,7 @@ class ConfigController extends ActionController */ public function resourceAction() { - $this->view->resources = IcingaConfig::app('resources', true)->toArray(); + $this->view->resources = Config::app('resources', true)->toArray(); $this->view->tabs->activate('resources'); } @@ -222,7 +222,7 @@ class ConfigController extends ActionController public function createresourceAction() { $form = new ResourceConfigForm(); - $form->setIniConfig(IcingaConfig::app('resources')); + $form->setIniConfig(Config::app('resources')); $form->setRedirectUrl('config/resource'); $form->handleRequest(); @@ -236,7 +236,7 @@ class ConfigController extends ActionController public function editresourceAction() { $form = new ResourceConfigForm(); - $form->setIniConfig(IcingaConfig::app('resources')); + $form->setIniConfig(Config::app('resources')); $form->setRedirectUrl('config/resource'); $form->handleRequest(); @@ -252,7 +252,7 @@ class ConfigController extends ActionController $form = new ConfirmRemovalForm(array( 'onSuccess' => function ($request) { $configForm = new ResourceConfigForm(); - $configForm->setIniConfig(IcingaConfig::app('resources')); + $configForm->setIniConfig(Config::app('resources')); $resource = $request->getQuery('resource'); try { @@ -274,7 +274,7 @@ class ConfigController extends ActionController // Check if selected resource is currently used for authentication $resource = $this->getRequest()->getQuery('resource'); - $authConfig = IcingaConfig::app('authentication')->toArray(); + $authConfig = Config::app('authentication')->toArray(); foreach ($authConfig as $backendName => $config) { if (array_key_exists('resource', $config) && $config['resource'] === $resource) { $form->addError(sprintf( diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 0ae931c18..51435d727 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -93,7 +93,7 @@ class DashboardController extends ActionController ); $configFile = Config::app('dashboard/dashboard')->getConfigFile(); - if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) { + if ($this->writeConfiguration(new Config($dashboard->toArray()), $configFile)) { $this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane')))); } else { $this->render('showConfiguration'); @@ -151,12 +151,12 @@ class DashboardController extends ActionController /** * Store the given configuration as INI file * - * @param Zend_Config $config The configuration to store - * @param string $target The path where to store the configuration + * @param Config $config The configuration to store + * @param string $target The path where to store the configuration * * @return bool Whether the configuartion has been successfully stored */ - protected function writeConfiguration(Zend_Config $config, $target) + protected function writeConfiguration(Config $config, $target) { $writer = new IniWriter(array('config' => $config, 'filename' => $target)); diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 8f9a39e1b..8efc3fc11 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -3,9 +3,9 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Module\Monitoring\Controller; -use Icinga\Web\Hook; use Icinga\Web\Url; use Icinga\Application\Logger; +use Icinga\Application\Config; use Icinga\Protocol\File\FileReader; use \Zend_Controller_Action_Exception as ActionError; @@ -48,7 +48,7 @@ class ListController extends Controller . ' - (?.*)$/'; // message $loggerWriter = Logger::getInstance()->getWriter(); - $resource = new FileReader(new Zend_Config(array( + $resource = new FileReader(new Config(array( 'filename' => $loggerWriter->getPath(), 'fields' => $pattern ))); diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index 4fd7297d9..f3d81e648 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -5,7 +5,7 @@ namespace Icinga\Form\Config\Resource; use Exception; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Web\Form; use Icinga\Web\Request; use Icinga\Web\Form\Element\Number; @@ -118,7 +118,7 @@ class DbResourceForm extends Form public function isValidResource(Form $form) { try { - $resource = ResourceFactory::createResource(new Zend_Config($form->getValues())); + $resource = ResourceFactory::createResource(new Config($form->getValues())); $resource->getConnection()->getConnection(); } catch (Exception $e) { $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index 6196f3a17..ee647d507 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -5,7 +5,7 @@ namespace Icinga\Form\Config\Resource; use Exception; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Web\Form; use Icinga\Web\Request; use Icinga\Web\Form\Element\Number; @@ -104,7 +104,7 @@ class LdapResourceForm extends Form public function isValidResource(Form $form) { try { - $resource = ResourceFactory::createResource(new Zend_Config($form->getValues())); + $resource = ResourceFactory::createResource(new Config($form->getValues())); $resource->connect(); } catch (Exception $e) { $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); diff --git a/application/forms/Config/Resource/LivestatusResourceForm.php b/application/forms/Config/Resource/LivestatusResourceForm.php index 92534f220..676904966 100644 --- a/application/forms/Config/Resource/LivestatusResourceForm.php +++ b/application/forms/Config/Resource/LivestatusResourceForm.php @@ -5,7 +5,7 @@ namespace Icinga\Form\Config\Resource; use Exception; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Web\Form; use Icinga\Web\Request; use Icinga\Application\Icinga; @@ -65,7 +65,7 @@ class LivestatusResourceForm extends Form public function isValidResource(Form $form) { try { - $resource = ResourceFactory::createResource(new Zend_Config($form->getValues())); + $resource = ResourceFactory::createResource(new Config($form->getValues())); $resource->connect()->disconnect(); } catch (Exception $e) { $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); diff --git a/application/forms/Dashboard/AddUrlForm.php b/application/forms/Dashboard/AddUrlForm.php index 88195654d..564ff3d7a 100644 --- a/application/forms/Dashboard/AddUrlForm.php +++ b/application/forms/Dashboard/AddUrlForm.php @@ -4,7 +4,7 @@ namespace Icinga\Form\Dashboard; -use Icinga\Application\Config as IcingaConfig; +use Icinga\Application\Config; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; @@ -110,7 +110,7 @@ class AddUrlForm extends Form protected function getDashboardPaneSelectionValues() { $dashboard = new Dashboard(); - $dashboard->readConfig(IcingaConfig::app('dashboard/dashboard')); + $dashboard->readConfig(Config::app('dashboard/dashboard')); return $dashboard->getPaneKeyTitleArray(); } } diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 7d22eaafa..00c600609 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -6,7 +6,6 @@ namespace Icinga\Application; use ErrorException; use Exception; -use Zend_Config; use Icinga\Application\Modules\Manager as ModuleManager; use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; @@ -57,7 +56,7 @@ abstract class ApplicationBootstrap /** * Config object * - * @var Zend_Config + * @var Config */ protected $config; @@ -313,12 +312,7 @@ abstract class ApplicationBootstrap $this->moduleManager = new ModuleManager( $this, $this->configDir . '/enabledModules', - explode( - ':', - $this->config->global !== null - ? $this->config->global->get('modulePath', ICINGAWEB_APPDIR . '/../modules') - : ICINGAWEB_APPDIR . '/../modules' - ) + explode(':', $this->config->fromSection('global', 'modulePath', ICINGAWEB_APPDIR . '/../modules')) ); return $this; } @@ -346,7 +340,7 @@ abstract class ApplicationBootstrap protected function setupLogging() { Logger::create( - new Zend_Config( + new Config( array( 'log' => 'syslog' ) @@ -367,7 +361,7 @@ abstract class ApplicationBootstrap $this->config = Config::app(); } catch (NotReadableError $e) { Logger::error(new IcingaException('Cannot load application configuration. An exception was thrown:', $e)); - $this->config = new Zend_Config(array()); + $this->config = new Config(); } return $this; } @@ -404,9 +398,9 @@ abstract class ApplicationBootstrap */ protected function setupLogger() { - if ($this->config->logging !== null) { + if (($loggingConfig = $this->config->get('logging')) !== null) { try { - Logger::create($this->config->logging); + Logger::create($loggingConfig); } catch (ConfigurationError $e) { Logger::error($e); } @@ -445,7 +439,7 @@ abstract class ApplicationBootstrap if (! $default) { $default = 'UTC'; } - $timeZoneString = $this->config->global !== null ? $this->config->global->get('timezone', $default) : $default; + $timeZoneString = $this->config->fromSection('global', 'timezone', $default); date_default_timezone_set($timeZoneString); DateTimeFactory::setConfig(array('timezone' => $timeZoneString)); return $this; diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index e82eaabbb..740623d9d 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -4,6 +4,7 @@ namespace Icinga\Application; +use Icinga\Application\Config; use Icinga\Application\Platform; use Icinga\Application\ApplicationBootstrap; use Icinga\Cli\Params; @@ -12,7 +13,6 @@ use Icinga\Cli\Screen; use Icinga\Application\Logger; use Icinga\Application\Benchmark; use Icinga\Exception\ProgrammingError; -use Zend_Config; require_once __DIR__ . '/ApplicationBootstrap.php'; @@ -49,7 +49,7 @@ class Cli extends ApplicationBootstrap protected function setupLogging() { Logger::create( - new Zend_Config( + new Config( array( 'level' => Logger::INFO, 'log' => 'file', diff --git a/library/Icinga/Application/Logger.php b/library/Icinga/Application/Logger.php index cb06ef8c3..f74c6d021 100644 --- a/library/Icinga/Application/Logger.php +++ b/library/Icinga/Application/Logger.php @@ -5,7 +5,7 @@ namespace Icinga\Application; use Exception; -use Zend_Config; +use Icinga\Application\Config; 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 Zend_Config $config + * @param Config $config * * @throws ConfigurationError If the logging configuration directive 'log' is missing or if the logging level is * not defined */ - public function __construct(Zend_Config $config) + public function __construct(Config $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 Zend_Config $config + * @param Config $config * * @return static */ - public static function create(Zend_Config $config) + public static function create(Config $config) { static::$instance = new static($config); return static::$instance; @@ -131,12 +131,12 @@ class Logger /** * Create a log writer * - * @param Zend_Config $config The configuration to initialize the writer with + * @param Config $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(Zend_Config $config) + protected function createWriter(Config $config) { $class = 'Icinga\\Application\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer'; if (! class_exists($class)) { diff --git a/library/Icinga/Application/Logger/LogWriter.php b/library/Icinga/Application/Logger/LogWriter.php index 370af35c1..c18e51257 100644 --- a/library/Icinga/Application/Logger/LogWriter.php +++ b/library/Icinga/Application/Logger/LogWriter.php @@ -4,7 +4,7 @@ namespace Icinga\Application\Logger; -use Zend_Config; +use Icinga\Application\Config; /** * Abstract class for writers that write messages to a log @@ -14,7 +14,7 @@ abstract class LogWriter /** * Create a new log writer initialized with the given configuration */ - abstract public function __construct(Zend_Config $config); + abstract public function __construct(Config $config); /** * Log a message with the given severity diff --git a/library/Icinga/Application/Logger/Writer/FileWriter.php b/library/Icinga/Application/Logger/Writer/FileWriter.php index 220b9be79..eec3b038f 100644 --- a/library/Icinga/Application/Logger/Writer/FileWriter.php +++ b/library/Icinga/Application/Logger/Writer/FileWriter.php @@ -5,7 +5,7 @@ namespace Icinga\Application\Logger\Writer; use Exception; -use Zend_Config; +use Icinga\Application\Config; 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 Zend_Config $config + * @param Config $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(Zend_Config $config) + public function __construct(Config $config) { if ($config->file === null) { throw new ConfigurationError('Required logging configuration directive \'file\' missing'); diff --git a/library/Icinga/Application/Logger/Writer/SyslogWriter.php b/library/Icinga/Application/Logger/Writer/SyslogWriter.php index 9a5ac28e5..6c39eee28 100644 --- a/library/Icinga/Application/Logger/Writer/SyslogWriter.php +++ b/library/Icinga/Application/Logger/Writer/SyslogWriter.php @@ -4,7 +4,7 @@ namespace Icinga\Application\Logger\Writer; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Application\Logger; use Icinga\Application\Logger\LogWriter; @@ -51,9 +51,9 @@ class SyslogWriter extends LogWriter /** * Create a new syslog log writer * - * @param Zend_Config $config + * @param Config $config */ - public function __construct(Zend_Config $config) + public function __construct(Config $config) { $this->ident = $config->get('application', 'icingaweb'); $this->facility = static::$facilities['user']; diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index b97483f95..7793ef689 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -5,7 +5,6 @@ namespace Icinga\Application\Modules; use Exception; -use Zend_Config; use Zend_Controller_Router_Route_Abstract; use Zend_Controller_Router_Route as Route; use Zend_Controller_Router_Route_Regex as RegexRoute; @@ -235,7 +234,7 @@ class Module if (array_key_exists($name, $this->menuItems)) { $this->menuItems[$name]->setProperties($properties); } else { - $this->menuItems[$name] = new Menu($name, new Zend_Config($properties)); + $this->menuItems[$name] = new Menu($name, new Config($properties)); } return $this->menuItems[$name]; diff --git a/library/Icinga/Authentication/AuthChain.php b/library/Icinga/Authentication/AuthChain.php index 12c7143bf..d704f2932 100644 --- a/library/Icinga/Authentication/AuthChain.php +++ b/library/Icinga/Authentication/AuthChain.php @@ -5,7 +5,7 @@ namespace Icinga\Authentication; use Iterator; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Application\Logger; use Icinga\Exception\ConfigurationError; @@ -17,7 +17,7 @@ class AuthChain implements Iterator /** * User backends configuration * - * @var Zend_Config + * @var Config */ private $config; @@ -31,9 +31,9 @@ class AuthChain implements Iterator /** * Create a new authentication chain from config * - * @param Zend_Config $config User backends configuration + * @param Config $config User backends configuration */ - public function __construct(Zend_Config $config) + public function __construct(Config $config) { $this->config = $config; } diff --git a/library/Icinga/Authentication/Backend/AutoLoginBackend.php b/library/Icinga/Authentication/Backend/AutoLoginBackend.php index 16373bb6c..8d38d9c15 100644 --- a/library/Icinga/Authentication/Backend/AutoLoginBackend.php +++ b/library/Icinga/Authentication/Backend/AutoLoginBackend.php @@ -4,7 +4,7 @@ namespace Icinga\Authentication\Backend; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Authentication\UserBackend; use Icinga\User; @@ -23,9 +23,9 @@ class AutoLoginBackend extends UserBackend /** * Create new autologin backend * - * @param Zend_Config $config + * @param Config $config */ - public function __construct(Zend_Config $config) + public function __construct(Config $config) { $this->stripUsernameRegexp = $config->get('strip_username_regexp'); } diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index c7d03b16a..ac83529ed 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -5,7 +5,6 @@ namespace Icinga\Authentication; use Exception; -use Zend_Config; use Icinga\Application\Config; use Icinga\Exception\IcingaException; use Icinga\Exception\NotReadableError; @@ -62,7 +61,7 @@ class Manager $e ) ); - $config = new Zend_Config(array()); + $config = new Config(); } if (($preferencesConfig = $config->preferences) !== null) { try { diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index 7829210fd..ee3d1d5b6 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -6,7 +6,7 @@ namespace Icinga\Authentication; use Countable; use Icinga\Authentication\Backend\AutoLoginBackend; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Authentication\Backend\DbUserBackend; use Icinga\Authentication\Backend\LdapUserBackend; use Icinga\Data\ResourceFactory; @@ -45,7 +45,7 @@ abstract class UserBackend implements Countable return $this->name; } - public static function create($name, Zend_Config $backendConfig) + public static function create($name, Config $backendConfig) { if ($backendConfig->name !== null) { $name = $backendConfig->name; diff --git a/library/Icinga/Authentication/UserGroupBackend.php b/library/Icinga/Authentication/UserGroupBackend.php index e411aee03..b41ef3f13 100644 --- a/library/Icinga/Authentication/UserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroupBackend.php @@ -4,7 +4,7 @@ namespace Icinga\Authentication; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Authentication\Backend\DbUserGroupBackend; use Icinga\Authentication\Backend\IniUserGroupBackend; use Icinga\Data\ResourceFactory; @@ -50,13 +50,13 @@ abstract class UserGroupBackend /** * Create a user group backend * - * @param string $name - * @param Zend_Config $backendConfig + * @param string $name + * @param Config $backendConfig * * @return DbUserGroupBackend|IniUserGroupBackend * @throws ConfigurationError If the backend configuration is invalid */ - public static function create($name, Zend_Config $backendConfig) + public static function create($name, Config $backendConfig) { if ($backendConfig->name !== null) { $name = $backendConfig->name; diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php index 0157bcd72..5fb08730e 100644 --- a/library/Icinga/Data/Db/DbConnection.php +++ b/library/Icinga/Data/Db/DbConnection.php @@ -4,14 +4,14 @@ namespace Icinga\Data\Db; +use PDO; +use Zend_Db; +use Icinga\Application\Config; use Icinga\Application\Benchmark; use Icinga\Data\Db\DbQuery; use Icinga\Data\ResourceFactory; use Icinga\Data\Selectable; use Icinga\Exception\ConfigurationError; -use PDO; -use Zend_Config; -use Zend_Db; /** * Encapsulate database connections and query creation @@ -21,7 +21,7 @@ class DbConnection implements Selectable /** * Connection config * - * @var Zend_Config + * @var Config */ private $config; @@ -59,9 +59,9 @@ class DbConnection implements Selectable /** * Create a new connection object * - * @param Zend_Config $config + * @param Config $config */ - public function __construct(Zend_Config $config = null) + public function __construct(Config $config = null) { $this->config = $config; if (isset($config->prefix)) { diff --git a/library/Icinga/Data/ResourceFactory.php b/library/Icinga/Data/ResourceFactory.php index 1c443f9d0..f938ea9a5 100644 --- a/library/Icinga/Data/ResourceFactory.php +++ b/library/Icinga/Data/ResourceFactory.php @@ -4,7 +4,6 @@ namespace Icinga\Data; -use Zend_Config; use Icinga\Application\Config; use Icinga\Exception\ProgrammingError; use Icinga\Util\ConfigAwareFactory; @@ -22,14 +21,14 @@ class ResourceFactory implements ConfigAwareFactory /** * Resource configuration * - * @var Zend_Config + * @var Config */ private static $resources; /** * Set resource configurations * - * @param Zend_Config $config + * @param Config $config */ public static function setConfig($config) { @@ -41,7 +40,7 @@ class ResourceFactory implements ConfigAwareFactory * * @param $resourceName String The resource's name * - * @return Zend_Config The configuration of the resource + * @return Config The configuration of the resource * * @throws ConfigurationError */ @@ -62,7 +61,7 @@ class ResourceFactory implements ConfigAwareFactory * * @param String|null $type Fetch only resources that have the given type. * - * @return Zend_Config The configuration containing all resources + * @return Config The configuration containing all resources */ public static function getResourceConfigs($type = null) { @@ -76,7 +75,7 @@ class ResourceFactory implements ConfigAwareFactory $resources[$name] = $resource; } } - return new Zend_Config($resources); + return new Config($resources); } } @@ -100,13 +99,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 Zend_Config $config The configuration for the created resource. + * @param Config $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(Zend_Config $config) + public static function createResource(Config $config) { switch (strtolower($config->type)) { case 'db': diff --git a/library/Icinga/File/Ini/IniWriter.php b/library/Icinga/File/Ini/IniWriter.php index 7dc79034d..0db8be139 100644 --- a/library/Icinga/File/Ini/IniWriter.php +++ b/library/Icinga/File/Ini/IniWriter.php @@ -7,6 +7,7 @@ namespace Icinga\File\Ini; use Zend_Config; use Zend_Config_Ini; use Zend_Config_Writer_FileAbstract; +use Icinga\Application\Config; /** * A INI file adapter that respects the file structure and the comments of already existing ini files @@ -33,6 +34,12 @@ class IniWriter extends Zend_Config_Writer_FileAbstract */ public function __construct(array $options = null) { + if (isset($options['config']) && $options['config'] instanceof Config) { + // As this class inherits from Zend_Config_Writer_FileAbstract we must + // not pass the config directly as it needs to be of type Zend_Config + $options['config'] = new Zend_Config($options['config']->toArray(), true); + } + $this->options = $options; parent::__construct($options); } diff --git a/library/Icinga/Protocol/File/FileReader.php b/library/Icinga/Protocol/File/FileReader.php index 49da989ef..26445de8a 100644 --- a/library/Icinga/Protocol/File/FileReader.php +++ b/library/Icinga/Protocol/File/FileReader.php @@ -4,9 +4,9 @@ namespace Icinga\Protocol\File; -use Icinga\Data\Selectable; use Countable; -use Zend_Config; +use Icinga\Application\Config; +use Icinga\Data\Selectable; /** * Read file line by line @@ -30,11 +30,11 @@ class FileReader implements Selectable, Countable /** * Create a new reader * - * @param Zend_Config $config + * @param Config $config * * @throws FileReaderException If a required $config directive (filename or fields) is missing */ - public function __construct(Zend_Config $config) + public function __construct(Config $config) { foreach (array('filename', 'fields') as $key) { if (isset($config->{$key})) { diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 8f5c14c4f..2573b37a2 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -8,7 +8,6 @@ use Icinga\Protocol\Ldap\Exception as LdapException; use Icinga\Application\Platform; use Icinga\Application\Config; use Icinga\Application\Logger; -use Zend_Config; /** * Backend class managing all the LDAP stuff for you. @@ -101,9 +100,9 @@ class Connection * * TODO: Allow to pass port and SSL options * - * @param Zend_Config $config + * @param Config $config */ - public function __construct(Zend_Config $config) + public function __construct(Config $config) { $this->hostname = $config->hostname; $this->bind_dn = $config->bind_dn; @@ -364,7 +363,7 @@ class Connection */ protected function getConfigDir($sub = null) { - $dir = Config::getInstance()->getConfigDir() . '/ldap'; + $dir = Config::$configDir . '/ldap'; if ($sub !== null) { $dir .= '/' . $sub; } diff --git a/library/Icinga/Test/BaseTestCase.php b/library/Icinga/Test/BaseTestCase.php index a735550cb..ade096547 100644 --- a/library/Icinga/Test/BaseTestCase.php +++ b/library/Icinga/Test/BaseTestCase.php @@ -24,9 +24,9 @@ namespace Icinga\Test { use Exception; use RuntimeException; use Mockery; - use Zend_Config; use PHPUnit_Framework_TestCase; use Icinga\Application\Icinga; + use Icinga\Application\Config; use Icinga\Util\DateTimeFactory; use Icinga\Data\ResourceFactory; use Icinga\Data\Db\DbConnection; @@ -191,17 +191,17 @@ namespace Icinga\Test { } /** - * Create Zend_Config for database configuration + * Create Config for database configuration * * @param string $name * - * @return Zend_Config + * @return Config * @throws RuntimeException */ protected function createDbConfigFor($name) { if (array_key_exists($name, self::$dbConfiguration)) { - return new Zend_Config(self::$dbConfiguration[$name]); + return new Config(self::$dbConfiguration[$name]); } throw new RuntimeException('Configuration for database type not available: ' . $name); diff --git a/library/Icinga/User/Preferences/PreferencesStore.php b/library/Icinga/User/Preferences/PreferencesStore.php index b8121eb25..79bea2e40 100644 --- a/library/Icinga/User/Preferences/PreferencesStore.php +++ b/library/Icinga/User/Preferences/PreferencesStore.php @@ -4,13 +4,12 @@ namespace Icinga\User\Preferences; -use Zend_Config; +use Icinga\Application\Config; use Icinga\User; use Icinga\User\Preferences; use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; use Icinga\Data\Db\DbConnection; -use Icinga\Application\Config as IcingaConfig; /** * Preferences store factory @@ -19,13 +18,13 @@ use Icinga\Application\Config as IcingaConfig; * * 'ini', * 'config_path' => '/path/to/preferences' * ), @@ -42,7 +41,7 @@ abstract class PreferencesStore /** * Store config * - * @var Zend_Config + * @var Config */ protected $config; @@ -56,10 +55,10 @@ abstract class PreferencesStore /** * Create a new store * - * @param Zend_Config $config The config for this adapter - * @param User $user The user to which these preferences belong + * @param Config $config The config for this adapter + * @param User $user The user to which these preferences belong */ - public function __construct(Zend_Config $config, User $user) + public function __construct(Config $config, User $user) { $this->config = $config; $this->user = $user; @@ -69,7 +68,7 @@ abstract class PreferencesStore /** * Getter for the store config * - * @return Zend_Config + * @return Config */ public function getStoreConfig() { @@ -108,14 +107,14 @@ abstract class PreferencesStore /** * 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 + * @param 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) + public static function create(Config $config, User $user) { if (($type = $config->type) === null) { throw new ConfigurationError( @@ -133,7 +132,7 @@ abstract class PreferencesStore } if ($type === 'Ini') { - $config->location = IcingaConfig::resolvePath('preferences'); + $config->location = Config::resolvePath('preferences'); } elseif ($type === 'Db') { $config->connection = new DbConnection(ResourceFactory::getResourceConfig($config->resource)); } diff --git a/library/Icinga/User/Preferences/Store/IniStore.php b/library/Icinga/User/Preferences/Store/IniStore.php index acffff223..c668b0bc0 100644 --- a/library/Icinga/User/Preferences/Store/IniStore.php +++ b/library/Icinga/User/Preferences/Store/IniStore.php @@ -4,7 +4,7 @@ namespace Icinga\User\Preferences\Store; -use Zend_Config; +use Icinga\Application\Config; use Icinga\Exception\NotReadableError; use Icinga\Exception\NotWritableError; use Icinga\File\Ini\IniWriter; @@ -116,7 +116,7 @@ class IniStore extends PreferencesStore $this->writer = new IniWriter( array( - 'config' => new Zend_Config($this->preferences), + 'config' => new Config($this->preferences), 'filename' => $this->preferencesFile ) ); diff --git a/library/Icinga/Web/Form/Validator/WritablePathValidator.php b/library/Icinga/Web/Form/Validator/WritablePathValidator.php index 8387c5cf5..239ab77c8 100644 --- a/library/Icinga/Web/Form/Validator/WritablePathValidator.php +++ b/library/Icinga/Web/Form/Validator/WritablePathValidator.php @@ -5,7 +5,6 @@ namespace Icinga\Web\Form\Validator; use Zend_Validate_Abstract; -use Icinga\Application\Config as IcingaConfig; /** * Validator that interprets the value as a path and checks if it's writable diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index 870c2f1f3..4cd660116 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -6,7 +6,6 @@ namespace Icinga\Web; use Icinga\Web\Menu\MenuItemRenderer; use RecursiveIterator; -use Zend_Config; use Icinga\Application\Config; use Icinga\Application\Icinga; use Icinga\Application\Logger; @@ -79,10 +78,10 @@ class Menu implements RecursiveIterator /** * Create a new menu * - * @param int $id The id of this menu - * @param Zend_Config $config The configuration for this menu + * @param int $id The id of this menu + * @param Config $config The configuration for this menu */ - public function __construct($id, Zend_Config $config = null, Menu $parent = null) + public function __construct($id, Config $config = null, Menu $parent = null) { $this->id = $id; if ($parent !== null) { @@ -94,7 +93,7 @@ class Menu implements RecursiveIterator /** * Set all given properties * - * @param array|Zend_Config $props Property list + * @param array|Config $props Property list */ public function setProperties($props = null) { @@ -415,11 +414,11 @@ class Menu implements RecursiveIterator * Add a sub menu to this menu * * @param string $id The id of the menu to add - * @param Zend_Config $itemConfig The config with which to initialize the menu + * @param Config $itemConfig The config with which to initialize the menu * * @return self */ - public function addSubMenu($id, Zend_Config $menuConfig = null) + public function addSubMenu($id, Config $menuConfig = null) { if (false === ($pos = strpos($id, '.'))) { $subMenu = new self($id, $menuConfig, $this); @@ -509,7 +508,7 @@ class Menu implements RecursiveIterator */ public function add($name, $config = array()) { - return $this->addSubMenu($name, new Zend_Config($config)); + return $this->addSubMenu($name, new Config($config)); } /** diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index a86204d87..0221e4744 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -5,7 +5,7 @@ namespace Icinga\Web\Widget; use Icinga\Application\Icinga; -use Icinga\Application\Config as IcingaConfig; +use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; use Icinga\Exception\ProgrammingError; use Icinga\Web\Widget\Dashboard\Pane; @@ -26,7 +26,7 @@ class Dashboard extends AbstractWidget /** * The configuration containing information about this dashboard * - * @var IcingaConfig; + * @var Config; */ private $config; @@ -140,11 +140,11 @@ class Dashboard extends AbstractWidget /** * Populate this dashboard via the given configuration file * - * @param IcingaConfig $config The configuration file to populate this dashboard with + * @param Config $config The configuration file to populate this dashboard with * * @return self */ - public function readConfig(IcingaConfig $config) + public function readConfig(Config $config) { $this->config = $config; $this->panes = array(); diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 7410c6210..6edf140f5 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -4,16 +4,12 @@ namespace Icinga\Web\Widget\Dashboard; -use Icinga\Exception\IcingaException; -use Icinga\Util\Dimension; +use Zend_Form_Element_Button; +use Icinga\Application\Config; use Icinga\Web\Form; use Icinga\Web\Url; use Icinga\Web\Widget\AbstractWidget; -use Icinga\Web\View; -use Zend_Config; -use Zend_Form_Element_Submit; -use Zend_Form_Element_Button; -use Exception; +use Icinga\Exception\IcingaException; /** * A dashboard pane component @@ -218,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 Zend_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 Config $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 + * @return Component A newly created Component for use in the Dashboard */ - public static function fromIni($title, Zend_Config $config, Pane $pane) + public static function fromIni($title, Config $config, Pane $pane) { $height = null; $width = null; diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 8c1e66bad..3b0e97c73 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -4,7 +4,7 @@ namespace Icinga\Web\Widget\Dashboard; -use Zend_Config; +use Icinga\Application\Config; 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 Zend_Config $config The configuration to use for setup + * @param Config $config The configuration to use for setup * * @return Pane */ - public static function fromIni($title, Zend_Config $config) + public static function fromIni($title, Config $config) { $pane = new Pane($title); if ($config->get('title', false)) { diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index 77a963d94..6f45a388b 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -9,17 +9,14 @@ use Icinga\Module\Monitoring\Form\Command\DisableNotificationWithExpireForm; use Icinga\Module\Monitoring\Form\Command\SingleArgumentCommandForm; use Icinga\Web\Form; use Icinga\Web\Url; -use Icinga\Data\Filter\Filter; use Icinga\Web\Notification; use Icinga\Module\Monitoring\Controller; use Icinga\Protocol\Commandpipe\CommandPipe; use Icinga\Exception\ConfigurationError; use Icinga\Exception\MissingParameterException; -use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Form\Command\AcknowledgeForm; use Icinga\Module\Monitoring\Form\Command\CommentForm; use Icinga\Module\Monitoring\Form\Command\CommandForm; -use Icinga\Module\Monitoring\Form\Command\CommandWithIdentifierForm; use Icinga\Module\Monitoring\Form\Command\CustomNotificationForm; use Icinga\Module\Monitoring\Form\Command\DelayNotificationForm; use Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm; diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index 061765f1c..e57943aa6 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -4,16 +4,13 @@ use \DateTime; use \DateInterval; -use \Zend_Config; use Icinga\Web\Url; use Icinga\Util\Format; -use Icinga\Application\Config; use Icinga\Util\DateTimeFactory; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Timeline\TimeLine; use Icinga\Module\Monitoring\Timeline\TimeRange; use Icinga\Module\Monitoring\Web\Widget\SelectBox; -use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView; class Monitoring_TimelineController extends Controller { @@ -257,22 +254,6 @@ class Monitoring_TimelineController extends Controller ); } - /** - * Get the application's global configuration or an empty one - * - * @return Zend_Config - */ - private function getGlobalConfiguration() - { - $globalConfig = Config::app()->global; - - if ($globalConfig === null) { - $globalConfig = new Zend_Config(array()); - } - - return $globalConfig; - } - /** * Get the user's preferred time format or the application's default * diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index f6aa6b447..3af728860 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -9,7 +9,7 @@ use Icinga\Data\Selectable; use Icinga\Data\Queryable; use Icinga\Data\ConnectionInterface; -use Icinga\Application\Config as IcingaConfig; +use Icinga\Application\Config; use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; @@ -69,7 +69,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface */ public static function createBackend($backendName = null) { - $config = IcingaConfig::module('monitoring', 'backends'); + $config = Config::module('monitoring', 'backends'); if ($config->count() === 0) { throw new ConfigurationError(mt('monitoring', 'No backend has been configured')); } diff --git a/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php b/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php index e5c9f7ba1..166bbb6a3 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/CommandTransport.php @@ -4,7 +4,6 @@ namespace Icinga\Module\Monitoring\Command\Transport; -use Zend_Config; use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; @@ -45,12 +44,12 @@ abstract class CommandTransport /** * Create a transport from config * - * @param Zend_Config $config + * @param Config $config * * @return LocalCommandFile|RemoteCommandFile * @throws ConfigurationError */ - public static function fromConfig(Zend_Config $config) + public static function fromConfig(Config $config) { switch (strtolower($config->transport)) { case RemoteCommandFile::TRANSPORT: diff --git a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php index 0335d1f82..6668e4903 100644 --- a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php @@ -10,6 +10,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php'); use Mockery; use Icinga\Test\BaseTestCase; +use Icinga\Application\Config; use Icinga\Form\Config\Authentication\LdapBackendForm; use Icinga\Exception\AuthenticationException; @@ -67,7 +68,7 @@ class LdapBackendFormTest extends BaseTestCase { Mockery::mock('alias:Icinga\Data\ResourceFactory') ->shouldReceive('getResourceConfig') - ->andReturn(new \Zend_Config(array())) + ->andReturn(new Config(array())) ->shouldReceive('create') ->andReturn(Mockery::mock('Icinga\Protocol\Ldap\Connection')); } diff --git a/test/php/application/forms/Config/Resource/DbResourceFormTest.php b/test/php/application/forms/Config/Resource/DbResourceFormTest.php index 1b624c49f..78bf0d23a 100644 --- a/test/php/application/forms/Config/Resource/DbResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/DbResourceFormTest.php @@ -60,7 +60,7 @@ class DbResourceFormTest extends BaseTestCase { Mockery::mock('alias:Icinga\Data\ResourceFactory') ->shouldReceive('createResource') - ->with(Mockery::type('\Zend_Config')) + ->with(Mockery::type('Icinga\Application\Config')) ->andReturn($resourceMock); } } diff --git a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php index 078a11146..52da49673 100644 --- a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php @@ -60,7 +60,7 @@ class LdapResourceFormTest extends BaseTestCase { Mockery::mock('alias:Icinga\Data\ResourceFactory') ->shouldReceive('createResource') - ->with(Mockery::type('\Zend_Config')) + ->with(Mockery::type('Icinga\Application\Config')) ->andReturn($resourceMock); } } diff --git a/test/php/application/forms/Config/Resource/LivestatusResourceFormTest.php b/test/php/application/forms/Config/Resource/LivestatusResourceFormTest.php index 300adebed..e13595ef3 100644 --- a/test/php/application/forms/Config/Resource/LivestatusResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/LivestatusResourceFormTest.php @@ -61,7 +61,7 @@ class LivestatusResourceFormTest extends BaseTestCase { Mockery::mock('alias:Icinga\Data\ResourceFactory') ->shouldReceive('createResource') - ->with(Mockery::type('\Zend_Config')) + ->with(Mockery::type('Icinga\Application\Config')) ->andReturn($resourceMock); } } diff --git a/test/php/library/Icinga/File/Ini/IniWriterTest.php b/test/php/library/Icinga/File/Ini/IniWriterTest.php index 0146ed009..53bd750d8 100644 --- a/test/php/library/Icinga/File/Ini/IniWriterTest.php +++ b/test/php/library/Icinga/File/Ini/IniWriterTest.php @@ -4,10 +4,9 @@ namespace Tests\Icinga\Config; -use Zend_Config; -use Zend_Config_Ini; use Icinga\File\Ini\IniWriter; use Icinga\Test\BaseTestCase; +use Icinga\Application\Config; class IniWriterTest extends BaseTestCase { @@ -32,23 +31,25 @@ class IniWriterTest extends BaseTestCase public function testWhetherSimplePropertiesAreInsertedInEmptyFiles() { + $this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore'); $target = $this->writeConfigToTemporaryFile(''); - $config = new Zend_Config(array('key' => 'value')); + $config = new Config(array('key' => 'value')); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals('value', $newConfig->get('key'), 'IniWriter does not insert in empty files'); } public function testWhetherSimplePropertiesAreInsertedInExistingFiles() { + $this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore'); $target = $this->writeConfigToTemporaryFile('key1 = "1"'); - $config = new Zend_Config(array('key2' => '2')); + $config = new Config(array('key2' => '2')); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals('2', $newConfig->get('key2'), 'IniWriter does not insert in existing files'); } @@ -57,12 +58,13 @@ class IniWriterTest extends BaseTestCase */ public function testWhetherSimplePropertiesAreUpdated() { + $this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore'); $target = $this->writeConfigToTemporaryFile('key = "value"'); - $config = new Zend_Config(array('key' => 'eulav')); + $config = new Config(array('key' => 'eulav')); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals('eulav', $newConfig->get('key'), 'IniWriter does not update simple properties'); } @@ -71,25 +73,26 @@ class IniWriterTest extends BaseTestCase */ public function testWhetherSimplePropertiesAreDeleted() { + $this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore'); $target = $this->writeConfigToTemporaryFile('key = "value"'); - $config = new Zend_Config(array()); + $config = new Config(array()); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertNull($newConfig->get('key'), 'IniWriter does not delete simple properties'); } public function testWhetherNestedPropertiesAreInserted() { $target = $this->writeConfigToTemporaryFile(''); - $config = new Zend_Config(array('a' => array('b' => 'c'))); + $config = new Config(array('a' => array('b' => 'c'))); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('a'), 'IniWriter does not insert nested properties' ); @@ -105,14 +108,15 @@ class IniWriterTest extends BaseTestCase */ public function testWhetherNestedPropertiesAreUpdated() { + $this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore'); $target = $this->writeConfigToTemporaryFile('a.b = "c"'); - $config = new Zend_Config(array('a' => array('b' => 'cc'))); + $config = new Config(array('a' => array('b' => 'cc'))); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('a'), 'IniWriter does not update nested properties' ); @@ -128,12 +132,13 @@ class IniWriterTest extends BaseTestCase */ public function testWhetherNestedPropertiesAreDeleted() { + $this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore'); $target = $this->writeConfigToTemporaryFile('a.b = "c"'); - $config = new Zend_Config(array()); + $config = new Config(array()); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertNull( $newConfig->get('a'), 'IniWriter does not delete nested properties' @@ -143,13 +148,13 @@ class IniWriterTest extends BaseTestCase public function testWhetherSimpleSectionPropertiesAreInserted() { $target = $this->writeConfigToTemporaryFile(''); - $config = new Zend_Config(array('section' => array('key' => 'value'))); + $config = new Config(array('section' => array('key' => 'value'))); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('section'), 'IniWriter does not insert sections' ); @@ -170,11 +175,11 @@ class IniWriterTest extends BaseTestCase key = "value" EOD ); - $config = new Zend_Config(array('section' => array('key' => 'eulav'))); + $config = new Config(array('section' => array('key' => 'eulav'))); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals( 'eulav', $newConfig->get('section')->get('key'), @@ -192,11 +197,11 @@ EOD key = "value" EOD ); - $config = new Zend_Config(array('section' => array())); + $config = new Config(array('section' => array())); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertNull( $newConfig->get('section')->get('key'), 'IniWriter does not delete simple section properties' @@ -205,19 +210,20 @@ EOD public function testWhetherNestedSectionPropertiesAreInserted() { + $this->markTestSkipped('Implementation has changed. Config::fromIni cannot handle nested properties anymore'); $target = $this->writeConfigToTemporaryFile(''); - $config = new Zend_Config(array('section' => array('a' => array('b' => 'c')))); + $config = new Config(array('section' => array('a' => array('b' => 'c')))); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('section'), 'IniWriter does not insert sections' ); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('section')->get('a'), 'IniWriter does not insert nested section properties' ); @@ -238,11 +244,11 @@ EOD a.b = "c" EOD ); - $config = new Zend_Config(array('section' => array('a' => array('b' => 'cc')))); + $config = new Config(array('section' => array('a' => array('b' => 'cc')))); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals( 'cc', $newConfig->get('section')->get('a')->get('b'), @@ -260,11 +266,11 @@ EOD a.b = "c" EOD ); - $config = new Zend_Config(array('section' => array())); + $config = new Config(array('section' => array())); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertNull( $newConfig->get('section')->get('a'), 'IniWriter does not delete nested section properties' @@ -273,8 +279,11 @@ EOD public function testWhetherSimplePropertiesOfExtendingSectionsAreInserted() { + $this->markTestSkipped( + 'Implementation has changed. There is no "Extend" functionality anymore in our Config object' + ); $target = $this->writeConfigToTemporaryFile(''); - $config = new Zend_Config( + $config = new Config( array( 'foo' => array('key1' => '1'), 'bar' => array('key2' => '2') @@ -284,14 +293,14 @@ EOD $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('foo'), 'IniWriter does not insert extended sections' ); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('bar'), 'IniWriter does not insert extending sections' ); @@ -312,6 +321,9 @@ EOD */ public function testWhetherSimplePropertiesOfExtendingSectionsAreUpdated() { + $this->markTestSkipped( + 'Implementation has changed. There is no "Extend" functionality anymore in our Config object' + ); $target = $this->writeConfigToTemporaryFile(<<<'EOD' [foo] key1 = "1" @@ -320,7 +332,7 @@ key1 = "1" key2 = "2" EOD ); - $config = new Zend_Config( + $config = new Config( array( 'foo' => array('key1' => '1'), 'bar' => array('key2' => '22') @@ -330,7 +342,7 @@ EOD $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals( '22', $newConfig->get('bar')->get('key2'), @@ -343,6 +355,9 @@ EOD */ public function testWhetherSimplePropertiesOfExtendingSectionsAreDeleted() { + $this->markTestSkipped( + 'Implementation has changed. There is no "Extend" functionality anymore in our Config object' + ); $target = $this->writeConfigToTemporaryFile(<<<'EOD' [foo] key1 = "1" @@ -351,7 +366,7 @@ key1 = "1" key2 = "2" EOD ); - $config = new Zend_Config( + $config = new Config( array( 'foo' => array('key1' => '1'), 'bar' => array() @@ -361,7 +376,7 @@ EOD $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertNull( $newConfig->get('bar')->get('key2'), 'IniWriter does not delete simple properties of extending sections' @@ -370,8 +385,11 @@ EOD public function testWhetherNestedPropertiesOfExtendingSectionsAreInserted() { + $this->markTestSkipped( + 'Implementation has changed. There is no "Extend" functionality anymore in our Config object' + ); $target = $this->writeConfigToTemporaryFile(''); - $config = new Zend_Config( + $config = new Config( array( 'foo' => array('a' => array('b' => 'c')), 'bar' => array('d' => array('e' => 'f')) @@ -381,19 +399,19 @@ EOD $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('foo'), 'IniWriter does not insert extended sections' ); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('bar'), 'IniWriter does not insert extending sections' ); $this->assertInstanceOf( - '\Zend_Config', + get_class($newConfig), $newConfig->get('bar')->get('d'), 'IniWriter does not insert nested properties into extending sections' ); @@ -422,7 +440,7 @@ a.b = "c" d.e = "f" EOD ); - $config = new Zend_Config( + $config = new Config( array( 'foo' => array('a' => array('b' => 'c')), 'bar' => array('d' => array('e' => 'ff')) @@ -432,7 +450,7 @@ EOD $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertEquals( 'ff', $newConfig->get('bar')->get('d')->get('e'), @@ -445,6 +463,9 @@ EOD */ public function testWhetherNestedPropertiesOfExtendingSectionsAreDeleted() { + $this->markTestSkipped( + 'Implementation has changed. There is no "Extend" functionality anymore in our Config object' + ); $target = $this->writeConfigToTemporaryFile(<<<'EOD' [foo] a.b = "c" @@ -453,7 +474,7 @@ a.b = "c" d.e = "f" EOD ); - $config = new Zend_Config( + $config = new Config( array( 'foo' => array('a' => array('b' => 'c')), 'bar' => array() @@ -463,7 +484,7 @@ EOD $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); - $newConfig = new Zend_Config_Ini($target); + $newConfig = Config::fromIni($target); $this->assertNull( $newConfig->get('bar')->get('d'), 'IniWriter does not delete nested properties of extending sections' @@ -506,7 +527,7 @@ EOD; $target = $this->writeConfigToTemporaryFile($config); $writer = new IniWriter( array( - 'config' => new Zend_Config( + 'config' => new Config( array( 'three' => array( 'foo' => array( @@ -561,7 +582,7 @@ EOD; $target = $this->writeConfigToTemporaryFile($config); $writer = new IniWriter( array( - 'config' => new Zend_Config( + 'config' => new Config( array( 'two' => array(), 'one' => array() @@ -589,7 +610,7 @@ key = "value" EOD; $target = $this->writeConfigToTemporaryFile($config); $writer = new IniWriter( - array('config' => new Zend_Config(array('key' => 'value')), 'filename' => $target) + array('config' => new Config(array('key' => 'value')), 'filename' => $target) ); $this->assertEquals( @@ -610,7 +631,7 @@ EOD; $target = $this->writeConfigToTemporaryFile($config); $writer = new IniWriter( array( - 'config' => new Zend_Config( + 'config' => new Config( array( 'foo' => 1337, 'bar' => 7331, @@ -638,7 +659,7 @@ key = "value" EOD; $target = $this->writeConfigToTemporaryFile($config); $writer = new IniWriter( - array('config' => new Zend_Config(array('section' => array('key' => 'value'))), 'filename' => $target) + array('config' => new Config(array('section' => array('key' => 'value'))), 'filename' => $target) ); $this->assertEquals( @@ -660,7 +681,7 @@ EOD; $target = $this->writeConfigToTemporaryFile($config); $writer = new IniWriter( array( - 'config' => new Zend_Config( + 'config' => new Config( array( 'section' => array( 'foo' => 1337, @@ -685,7 +706,7 @@ EOD; { $normalKeys = new IniWriter( array ( - 'config' => new Zend_Config(array ( + 'config' => new Config(array ( 'foo' => 'bar', 'nest' => array ( 'nested' => array ( @@ -706,7 +727,7 @@ EOD; $nestedKeys = new IniWriter( array ( - 'config' => new Zend_Config(array ( + 'config' => new Config(array ( 'foo' => 'bar', 'nest.nested.stuff' => 'nested configuration element', 'preserving.ini.writer' => 'n', diff --git a/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php b/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php index 9dd43ae83..44831a5e7 100644 --- a/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php +++ b/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php @@ -4,7 +4,7 @@ namespace Tests\Icinga\Logger\Writer; -use Zend_Config; +use Icinga\Application\Config; 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 Zend_Config(array('file' => $this->target))); + new FileWriter(new Config(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 Zend_Config(array('file' => $this->target))); + $writer = new FileWriter(new Config(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'); diff --git a/test/php/library/Icinga/Protocol/Ldap/QueryTest.php b/test/php/library/Icinga/Protocol/Ldap/QueryTest.php index f3fa2c727..4871abaa0 100644 --- a/test/php/library/Icinga/Protocol/Ldap/QueryTest.php +++ b/test/php/library/Icinga/Protocol/Ldap/QueryTest.php @@ -4,15 +4,15 @@ namespace Tests\Icinga\Protocol\Ldap; -use Zend_Config; use Icinga\Test\BaseTestCase; +use Icinga\Application\Config; use Icinga\Protocol\Ldap\Connection; class QueryTest extends BaseTestCase { private function emptySelect() { - $config = new Zend_Config( + $config = new Config( array( 'hostname' => 'localhost', 'root_dn' => 'dc=example,dc=com', diff --git a/test/php/library/Icinga/User/Store/DbStoreTest.php b/test/php/library/Icinga/User/Store/DbStoreTest.php index d98c3fdfc..37c5f7470 100644 --- a/test/php/library/Icinga/User/Store/DbStoreTest.php +++ b/test/php/library/Icinga/User/Store/DbStoreTest.php @@ -6,8 +6,8 @@ namespace Tests\Icinga\User\Preferences\Store; use Mockery; use Exception; -use Zend_Config; use Icinga\Test\BaseTestCase; +use Icinga\Application\Config; use Icinga\User\Preferences\Store\DbStore; class DatabaseMock @@ -165,7 +165,7 @@ class DbStoreTest extends BaseTestCase protected function getStore($dbMock) { return new DbStoreWithSetPreferences( - new Zend_Config( + new Config( array( 'connection' => Mockery::mock(array('getDbAdapter' => $dbMock)) ) diff --git a/test/php/library/Icinga/User/Store/IniStoreTest.php b/test/php/library/Icinga/User/Store/IniStoreTest.php index d6637d2f2..c3d8827d2 100644 --- a/test/php/library/Icinga/User/Store/IniStoreTest.php +++ b/test/php/library/Icinga/User/Store/IniStoreTest.php @@ -5,8 +5,8 @@ namespace Tests\Icinga\User\Preferences\Store; use Mockery; -use Zend_Config; use Icinga\Test\BaseTestCase; +use Icinga\Application\Config; use Icinga\User\Preferences\Store\IniStore; class IniStoreWithSetGetPreferencesAndEmptyWrite extends IniStore @@ -56,7 +56,7 @@ class IniStoreTest extends BaseTestCase protected function getStore() { return new IniStoreWithSetGetPreferencesAndEmptyWrite( - new Zend_Config( + new Config( array( 'location' => 'some/Path/To/Some/Directory' ) diff --git a/test/php/library/Icinga/Web/MenuTest.php b/test/php/library/Icinga/Web/MenuTest.php index eb6456773..b0727111b 100644 --- a/test/php/library/Icinga/Web/MenuTest.php +++ b/test/php/library/Icinga/Web/MenuTest.php @@ -4,21 +4,21 @@ namespace Tests\Icinga\Web; -use Zend_Config; use Icinga\Web\Menu; use Icinga\Test\BaseTestCase; +use Icinga\Application\Config; class MenuTest extends BaseTestCase { public function testWhetherMenusAreNaturallySorted() { $menu = new Menu('test'); - $menu->addSubMenu(5, new Zend_Config(array('title' => 'ccc5'))); - $menu->addSubMenu(0, new Zend_Config(array('title' => 'aaa'))); - $menu->addSubMenu(3, new Zend_Config(array('title' => 'ccc'))); - $menu->addSubMenu(2, new Zend_Config(array('title' => 'bbb'))); - $menu->addSubMenu(4, new Zend_Config(array('title' => 'ccc2'))); - $menu->addSubMenu(1, new Zend_Config(array('title' => 'bb'))); + $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'))); $this->assertEquals( array('aaa', 'bb', 'bbb', 'ccc', 'ccc2', 'ccc5'),