Autoloader: Rename module namespace

This commit is contained in:
Marius Hein 2013-07-15 12:16:14 +02:00
parent e049d8f3c4
commit 6742696e09
41 changed files with 61 additions and 51 deletions

View File

@ -40,6 +40,9 @@ class Loader
*/ */
private $namespaces = array(); private $namespaces = array();
/**
* Detach spl autoload method from stack
*/
public function __destruct() public function __destruct()
{ {
$this->unRegister(); $this->unRegister();

View File

@ -30,6 +30,11 @@ use Icinga\Application\Config;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Zend_Controller_Router_Route as Route; use Zend_Controller_Router_Route as Route;
/**
* Module handling
*
* Register modules and initialize it
*/
class Module class Module
{ {
/** /**
@ -112,6 +117,11 @@ class Module
return true; return true;
} }
/**
* Test for an enabled module by name
* @param string $name
* @return boolean
*/
public static function exists($name) public static function exists($name)
{ {
return Icinga::app()->moduleManager()->hasEnabled($name); return Icinga::app()->moduleManager()->hasEnabled($name);
@ -215,9 +225,6 @@ class Module
$this->app->getLoader()->registerNamespace($moduleName, $moduleLibraryDir); $this->app->getLoader()->registerNamespace($moduleName, $moduleLibraryDir);
// TODO(mh): Old namespace for convenience (#4409). Should be removed immediately
$this->app->getLoader()->registerNamespace('Icinga\\'. $moduleName, $moduleLibraryDir);
$this->app->getLoader()->registerNamespace($moduleName. '\\Form', $this->getFormDir()); $this->app->getLoader()->registerNamespace($moduleName. '\\Form', $this->getFormDir());
} }

View File

@ -3,7 +3,7 @@
use Icinga\Web\ModuleActionController; use Icinga\Web\ModuleActionController;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\File\Csv; use Icinga\File\Csv;
use Icinga\Monitoring\Backend; use Monitoring\Backend;
class Monitoring_ListController extends ModuleActionController class Monitoring_ListController extends ModuleActionController
{ {

View File

@ -1,10 +1,10 @@
<?php <?php
use Icinga\Monitoring\Backend; use Monitoring\Backend;
use Icinga\Web\ModuleActionController; use Icinga\Web\ModuleActionController;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\Monitoring\Object\Host; use Monitoring\Object\Host;
use Icinga\Monitoring\Object\Service; use Monitoring\Object\Service;
class Monitoring_ShowController extends ModuleActionController class Monitoring_ShowController extends ModuleActionController
{ {

View File

@ -2,7 +2,7 @@
use Icinga\Web\ModuleActionController; use Icinga\Web\ModuleActionController;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Monitoring\Backend; use Monitoring\Backend;
use Zend_Soap_Server as ZfSoapServer; use Zend_Soap_Server as ZfSoapServer;
use Zend_Soap_AutoDiscover as ZfSoapAutoDiscover; use Zend_Soap_AutoDiscover as ZfSoapAutoDiscover;

View File

@ -1,6 +1,6 @@
<?php <?php
use Icinga\Monitoring\Plugin\PerfdataSet; use Monitoring\Plugin\PerfdataSet;
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
{ {

View File

@ -27,7 +27,7 @@ $row_class = array_key_exists($event->state, $states) ? $states[$event->state] :
<? if (! $object): ?> <? if (! $object): ?>
<td><?= $this->escape($event->host_name) ?></td> <td><?= $this->escape($event->host_name) ?></td>
<? endif ?> <? endif ?>
<? if (! $object instanceof Icinga\Monitoring\Object\Service): ?> <? if (! $object instanceof Monitoring\Object\Service): ?>
<td><? if ($object): ?> <td><? if ($object): ?>
<?= $this->qlink( <?= $this->qlink(
$event->service_description, $event->service_description,

View File

@ -1,6 +1,6 @@
<?php <?php
use Icinga\Monitoring\Backend; use Monitoring\Backend;
use Icinga\Util\Format; use Icinga\Util\Format;
$backend = Backend::getInstance($params->shift('backend')); $backend = Backend::getInstance($params->shift('backend'));

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring; namespace Monitoring;
use Icinga\Application\Config as IcingaConfig; use Icinga\Application\Config as IcingaConfig;
use Icinga\Authentication\Manager as AuthManager; use Icinga\Authentication\Manager as AuthManager;
@ -62,7 +62,7 @@ class Backend
$config = self::$backendConfigs[$name]; $config = self::$backendConfigs[$name];
$type = $config->type; $type = $config->type;
$type[0] = strtoupper($type[0]); $type[0] = strtoupper($type[0]);
$class = '\\Icinga\\Monitoring\\Backend\\' . $type; $class = '\\Monitoring\\Backend\\' . $type;
self::$instances[$name] = new $class($config); self::$instances[$name] = new $class($config);
} }
return self::$instances[$name]; return self::$instances[$name];

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend; namespace Monitoring\Backend;
use Icinga\Data\DatasourceInterface; use Icinga\Data\DatasourceInterface;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
@ -66,7 +66,7 @@ class AbstractBackend implements DatasourceInterface
protected function tableToClassName($virtual_table) protected function tableToClassName($virtual_table)
{ {
return 'Icinga\\Monitoring\\View\\' return 'Monitoring\\View\\'
// . $this->getName() // . $this->getName()
// . '\\' // . '\\'
. ucfirst($virtual_table) . ucfirst($virtual_table)

View File

@ -1,13 +1,13 @@
<?php <?php
namespace Icinga\Monitoring\Backend; namespace Monitoring\Backend;
use Icinga\Data\Db\Connection; use Icinga\Data\Db\Connection;
/** /**
* This class provides an easy-to-use interface to the IDO database * This class provides an easy-to-use interface to the IDO database
* *
* You should usually not directly use this class but go through Icinga\Monitoring\Backend. * You should usually not directly use this class but go through Monitoring\Backend.
* *
* New MySQL indexes: * New MySQL indexes:
* <code> * <code>

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
use Icinga\Data\Db\Query; use Icinga\Data\Db\Query;
use Icinga\Application\Benchmark; use Icinga\Application\Benchmark;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class CommentQuery extends AbstractQuery class CommentQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class ContactQuery extends AbstractQuery class ContactQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class ContactgroupQuery extends AbstractQuery class ContactgroupQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class CustomvarQuery extends AbstractQuery class CustomvarQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class HostgroupQuery extends AbstractQuery class HostgroupQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class HoststatusQuery extends AbstractQuery class HoststatusQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class ServicegroupQuery extends AbstractQuery class ServicegroupQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class ServicestatusQuery extends AbstractQuery class ServicestatusQuery extends AbstractQuery
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Ido\Query; namespace Monitoring\Backend\Ido\Query;
class StatusQuery extends AbstractQuery class StatusQuery extends AbstractQuery
{ {

View File

@ -3,9 +3,9 @@
/** /**
* Icinga Livestatus Backend * Icinga Livestatus Backend
* *
* @package Icinga\Monitoring * @package Monitoring
*/ */
namespace Icinga\Monitoring\Backend; namespace Monitoring\Backend;
use Icinga\Protocol\Livestatus\Connection; use Icinga\Protocol\Livestatus\Connection;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Backend\Livestatus\Query; namespace Monitoring\Backend\Livestatus\Query;
use Icinga\Data\AbstractQuery; use Icinga\Data\AbstractQuery;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring; namespace Monitoring;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Web\Session; use Icinga\Web\Session;

View File

@ -1,9 +1,9 @@
<?php <?php
namespace Icinga\Monitoring\Object; namespace Monitoring\Object;
use Icinga\Data\AbstractQuery as Query; use Icinga\Data\AbstractQuery as Query;
use Icinga\Monitoring\Backend\AbstractBackend; use Monitoring\Backend\AbstractBackend;
abstract class AbstractObject abstract class AbstractObject
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Object; namespace Monitoring\Object;
use Icinga\Data\AbstractQuery as Query; use Icinga\Data\AbstractQuery as Query;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Object; namespace Monitoring\Object;
use Icinga\Data\AbstractQuery as Query; use Icinga\Data\AbstractQuery as Query;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring; namespace Monitoring;
require_once ICINGA_LIBDIR . '/Icinga/Application/Cli.php'; require_once ICINGA_LIBDIR . '/Icinga/Application/Cli.php';

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Plugin; namespace Monitoring\Plugin;
class Perfdata class Perfdata
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\Plugin; namespace Monitoring\Plugin;
class PerfdataSet class PerfdataSet
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class CommentView extends MonitoringView class CommentView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class ContactView extends MonitoringView class ContactView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class ContactgroupView extends MonitoringView class ContactgroupView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class CustomvarView extends MonitoringView class CustomvarView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class EventHistoryView extends MonitoringView class EventHistoryView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class HostgroupView extends MonitoringView class HostgroupView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class HoststatusView extends MonitoringView class HoststatusView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
use Icinga\Data\AbstractQuery; use Icinga\Data\AbstractQuery;
use Icinga\Data\Filter; use Icinga\Data\Filter;
@ -13,11 +13,11 @@ use Icinga\Data\Filter;
* *
* You should not directly instantiate such a view but always go through the * You should not directly instantiate such a view but always go through the
* Monitoring Backend. Using the Backend's select() method selecting from * Monitoring Backend. Using the Backend's select() method selecting from
* 'virtualtable' returns a Icinga\Monitoring\View\VirtualtableView instance. * 'virtualtable' returns a Monitoring\View\VirtualtableView instance.
* *
* Usage example: * Usage example:
* <code> * <code>
* use Icinga\Monitoring\Backend; * use Monitoring\Backend;
* $backend = Backend::getInstance(); * $backend = Backend::getInstance();
* $query = $backend->select()->from('viewname', array( * $query = $backend->select()->from('viewname', array(
* 'one_column', * 'one_column',

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class ServicegroupView extends MonitoringView class ServicegroupView extends MonitoringView
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Icinga\Monitoring\View; namespace Monitoring\View;
class StatusView extends MonitoringView class StatusView extends MonitoringView
{ {