CS: Fix docstrings in Icinga/Application/Modules/Module.php and Manager.php

refs #4530
This commit is contained in:
Eric Lippmann 2013-08-14 16:07:17 +02:00
parent d604b01349
commit 6d98b923ca
3 changed files with 102 additions and 79 deletions

View File

@ -15,9 +15,9 @@ use \Icinga\Exception\ProgrammingError;
* Module manager that handles detecting, enabling and disabling of modules
*
* Modules can have 3 states:
* - installed Means that the module exists, but could be deactivated (see enabled and loaded)
* - enabled Means that the module is marked as being enabled and should be used
* - loaded Means that the module has been registered in the autoloader and is being used
* * installed, module exists but is disabled
* * enabled, module enabled and should be loaded
* * loaded, module enabled and loaded via the autoloader
*
*/
class Manager
@ -69,12 +69,10 @@ class Manager
/**
* Create a new instance of the module manager
*
* @param ApplicationBootstrap $app The application bootstrap. This one needs a properly defined interface
* In order to test it correctly, the application now only requires a stdClass
* @param string $enabledDir The path of the dir used for adding symlinks to enabled modules
* ( must be writable )
* @param array $availableDirs An array containing all paths where the modulemanager can look for available
* modules
* @param ApplicationBootstrap $app
* @param string $enabledDir Enabled modules location. The application maintains symlinks within
* the given path
* @param array $availableDirs Installed modules location
**/
public function __construct($app, $enabledDir = null, array $availableDirs = array())
{
@ -124,7 +122,6 @@ class Manager
/**
* Check for enabled modules and update the internal $enabledDirs property with the enabled modules
*
*/
private function detectEnabledModules()
{
@ -180,7 +177,8 @@ class Manager
* Try to load the module and register it in the application
*
* @param string $name The name of the module to load
* @param null|mixed $moduleBase An alternative class to use instead of @see Module, used for testing
* @param mixed $moduleBase Alternative class to use instead of \Icinga\Application\Modules\Module for
* instantiating modules, used for testing
*
* @return self
*/
@ -250,6 +248,7 @@ class Manager
* @param string $name The name of the module to disable
*
* @return self
*
* @throws \Icinga\Exception\ConfigurationError When the module is not installed or it's not symlinked
* @throws \Icinga\Exception\SystemPermissionException When the module can't be disabled
*/
@ -264,21 +263,21 @@ class Manager
}
$link = $this->enableDir . '/' . $name;
if (!file_exists($link)) {
throw new ConfigurationError("The module $name could not be found, can't disable it");
throw new ConfigurationError('The module ' . $name . ' could not be found, can\'t disable it');
}
if (!is_link($link)) {
throw new ConfigurationError(
"The module $name can't be disabled as this would delete the whole module. ".
"It looks like you have installed this module manually and moved it to your module folder.".
"In order to dynamically enable and disable modules, you have to create a symlink to ".
"the enabled_modules folder"
'The module ' . $name . ' can\'t be disabled as this would delete the whole module. '
. 'It looks like you have installed this module manually and moved it to your module folder. '
. 'In order to dynamically enable and disable modules, you have to create a symlink to '
. 'the enabled_modules folder'
);
}
if (file_exists($link) && is_link($link)) {
if (!@unlink($link)) {
$error = error_get_last();
throw new SystemPermissionException($error["message"], "unlink", $link);
throw new SystemPermissionException($error['message'], 'unlink', $link);
}
} else {
@ -294,6 +293,7 @@ class Manager
* @param string $subdir The sub directory to append to the path
*
* @return string
*
* @throws \Icinga\Exception\ProgrammingError When the module is not installed or existing
*/
public function getModuleDir($name, $subdir = '')
@ -318,6 +318,7 @@ class Manager
* Return true when the module with the given name is installed, otherwise false
*
* @param string $name The module to check for being installed
*
* @return bool
*/
public function hasInstalled($name)
@ -356,7 +357,8 @@ class Manager
* Return an array containing all loaded modules
*
* @return array
* @see Module
*
* @see \Icinga\Application\Modules\Module
*/
public function getLoadedModules()
{
@ -367,9 +369,10 @@ class Manager
* Return the module instance of the given module when it is loaded
*
* @param string $name The module name to return
* @return Module
*
* @throws \Icinga\Exception\ProgrammingError Thrown when the module hasn't been loaded
* @return \Icinga\Application\Modules\Module
*
* @throws \Icinga\Exception\ProgrammingError When the module hasn't been loaded
*/
public function getModule($name)
{
@ -388,10 +391,10 @@ class Manager
* Return an array containing information objects for each available module
*
* Each entry has the following fields
* - name: The name of the module as a string
* - path: The path where the module is located as a string
* - enabled: Whether the module is enabled or not as a boolean
* - loaded: Whether the module is loaded or not as a boolean
* * name, name of the module as a string
* * path, path where the module is located as a string
* * enabled, whether the module is enabled or not as a boolean
* * loaded, whether the module is loaded or not as a boolean
*
* @return array
*/
@ -438,10 +441,11 @@ class Manager
/**
* Return an array containing all installled module names as strings
*
* Calls @see Manager::detectInstalledModules if no module discovery has
* been performed yet
* Calls detectInstalledModules() if no module discovery has been performed yet
*
* @return array
*
* @see detectInstalledModules()
*/
public function listInstalledModules()
{

View File

@ -43,54 +43,63 @@ class Module
{
/**
* Module name
*
* @var string
*/
private $name;
/**
* Base directory of module
*
* @var string
*/
private $basedir;
/**
* Directory for styles
*
* @var string
*/
private $cssdir;
/**
* Library directory
*
* @var string
*/
private $libdir;
/**
* Directory containing translations
*
* @var string
*/
private $localedir;
/**
* Directory where controllers reside
*
* @var string
*/
private $controllerdir;
/**
* Directory containing form implementations
*
* @var string
*/
private $formdir;
/**
* Module bootstrapping script
*
* @var string
*/
private $registerscript;
/**
* Icinga application
*
* @var \Icinga\Application\Web
*/
private $app;
@ -133,6 +142,7 @@ class Module
* Test for an enabled module by name
*
* @param string $name
*
* @return boolean
*/
public static function exists($name)
@ -145,7 +155,9 @@ class Module
*
* @param string $name
* @param bool $autoload
*
* @return mixed
*
* @throws \Icinga\Exception\ProgrammingError When the module is not yet loaded
*/
public static function get($name, $autoload = false)
@ -238,7 +250,8 @@ class Module
/**
* Getter for module config object
*
* @param null|string $file
* @param string $file
*
* @return Config
*/
public function getConfig($file = null)
@ -376,6 +389,7 @@ class Module
* @param string $name
* @param string $class
* @param string $key
*
* @return self
*/
protected function registerHook($name, $key, $class)

View File

@ -1,10 +1,14 @@
<?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Soap_Server as ZfSoapServer;
use \Zend_Soap_AutoDiscover as ZfSoapAutoDiscover;
use \Icinga\Web\Controller\ModuleActionController;
use \Icinga\Web\Url;
use \Monitoring\Backend;
use Icinga\Web\Controller\ModuleActionController;
use Icinga\Web\Url;
use Monitoring\Backend;
use Zend_Soap_Server as ZfSoapServer;
use Zend_Soap_AutoDiscover as ZfSoapAutoDiscover;
class Api
{
@ -47,3 +51,4 @@ class Monitoring_SoapController extends ModuleActionController
exit;
}
}
// @codingStandardsIgnoreEnd