Fix coding style in Module.php

refs #9644
This commit is contained in:
Eric Lippmann 2015-07-24 15:06:25 +02:00
parent 519d025de5
commit 149a974a44
1 changed files with 113 additions and 118 deletions

View File

@ -114,7 +114,7 @@ class Module
private $triedToLaunchConfigScript = false;
/**
* Whether the module's namespace has been registered on our autoloader
* Whether the module's namespaces have been registered on our autoloader
*
* @var bool
*/
@ -236,20 +236,22 @@ class Module
* @param string $title
* @param string $url
* @param int $priority
*
* @return $this
*/
public function provideSearchUrl($title, $url, $priority = 0)
{
$searchUrl = (object) array(
$this->searchUrls[] = (object) array(
'title' => (string) $title,
'url' => (string) $url,
'priority' => (int) $priority
);
$this->searchUrls[] = $searchUrl;
return $this;
}
/**
* Return this module's search urls
* Get this module's search urls
*
* @return array
*/
@ -260,7 +262,7 @@ class Module
}
/**
* Get all Menu Items
* Get all pane items
*
* @return array
*/
@ -273,7 +275,8 @@ class Module
/**
* Add a pane to dashboard
*
* @param $name
* @param string $name
*
* @return Pane
*/
protected function dashboard($name)
@ -283,7 +286,7 @@ class Module
}
/**
* Get all Menu Items
* Get all menu items
*
* @return array
*/
@ -294,11 +297,12 @@ class Module
}
/**
* Add a menu Section to the Sidebar menu
* Add or get a menu section
*
* @param $name
* @param string $name
* @param array $properties
* @return mixed
*
* @return Menu
*/
protected function menuSection($name, array $properties = array())
{
@ -334,14 +338,14 @@ class Module
);
return false;
}
$this->registerWebIntegration();
$this->registered = true;
return true;
}
/**
* Return whether this module has been registered
* Get whether this module has been registered
*
* @return bool
*/
@ -355,7 +359,7 @@ class Module
*
* @param string $name
*
* @return boolean
* @return bool
*/
public static function exists($name)
{
@ -363,7 +367,7 @@ class Module
}
/**
* Get module by name
* Get a module by name
*
* @param string $name
* @param bool $autoload
@ -425,7 +429,7 @@ class Module
}
/**
* Getter for module name
* Get the module name
*
* @return string
*/
@ -435,7 +439,7 @@ class Module
}
/**
* Getter for module version
* Get the module version
*
* @return string
*/
@ -445,7 +449,7 @@ class Module
}
/**
* Get module description
* Get the module description
*
* @return string
*/
@ -455,7 +459,7 @@ class Module
}
/**
* Get module title (short description)
* Get the module title (short description)
*
* @return string
*/
@ -465,9 +469,9 @@ class Module
}
/**
* Getter for module version
* Get the module dependencies
*
* @return Array
* @return array
*/
public function getDependencies()
{
@ -562,7 +566,7 @@ class Module
}
/**
* Getter for css file name
* Get the module's CSS directory
*
* @return string
*/
@ -572,17 +576,7 @@ class Module
}
/**
* Getter for base directory
*
* @return string
*/
public function getBaseDir()
{
return $this->basedir;
}
/**
* Get the controller directory
* Get the module's controller directory
*
* @return string
*/
@ -592,7 +586,17 @@ class Module
}
/**
* Getter for library directory
* Get the module's base directory
*
* @return string
*/
public function getBaseDir()
{
return $this->basedir;
}
/**
* Get the module's library directory
*
* @return string
*/
@ -602,7 +606,7 @@ class Module
}
/**
* Getter for configuration directory
* Get the module's configuration directory
*
* @return string
*/
@ -612,7 +616,7 @@ class Module
}
/**
* Getter for form directory
* Get the module's form directory
*
* @return string
*/
@ -622,7 +626,7 @@ class Module
}
/**
* Getter for module config object
* Get the module config
*
* @param string $file
*
@ -634,9 +638,7 @@ class Module
}
/**
* Retrieve provided permissions
*
* @param string $name Permission name
* Get provided permissions
*
* @return array
*/
@ -647,9 +649,8 @@ class Module
}
/**
* Retrieve provided restrictions
* Get provided restrictions
*
* @param string $name Restriction name
* @return array
*/
public function getProvidedRestrictions()
@ -659,20 +660,7 @@ class Module
}
/**
* Whether the given permission name is supported
*
* @param string $name Permission name
*
* @return bool
*/
public function providesPermission($name)
{
$this->launchConfigScript();
return array_key_exists($name, $this->permissionList);
}
/**
* Whether the given restriction name is supported
* Whether the module provides the given restriction
*
* @param string $name Restriction name
*
@ -685,9 +673,22 @@ class Module
}
/**
* Retrieve this modules configuration tabs
* Whether the module provides the given permission
*
* @return Icinga\Web\Widget\Tabs
* @param string $name Permission name
*
* @return bool
*/
public function providesPermission($name)
{
$this->launchConfigScript();
return array_key_exists($name, $this->permissionList);
}
/**
* Get the module configuration tabs
*
* @return \Icinga\Web\Widget\Tabs
*/
public function getConfigTabs()
{
@ -705,7 +706,7 @@ class Module
}
/**
* Whether this module provides a setup wizard
* Whether the module provides a setup wizard
*
* @return bool
*/
@ -721,7 +722,7 @@ class Module
}
/**
* Return this module's setup wizard
* Get the module's setup wizard
*
* @return SetupWizard
*/
@ -731,7 +732,7 @@ class Module
}
/**
* Return this module's user backends
* Get the module's user backends
*
* @return array
*/
@ -742,7 +743,7 @@ class Module
}
/**
* Return this module's user group backends
* Get the module's user group backends
*
* @return array
*/
@ -756,9 +757,9 @@ class Module
* Provide a named permission
*
* @param string $name Unique permission name
* @param string $name Permission description
* @param string $description Permission description
*
* @return void
* @throws IcingaException If the permission is already provided
*/
protected function providePermission($name, $description)
{
@ -780,7 +781,7 @@ class Module
* @param string $name Unique restriction name
* @param string $description Restriction description
*
* @return void
* @throws IcingaException If the restriction is already provided
*/
protected function provideRestriction($name, $description)
{
@ -800,14 +801,15 @@ class Module
* Provide a module config tab
*
* @param string $name Unique tab name
* @param string $config Tab config
* @param array $config Tab config
*
* @return $this
* @throws ProgrammingError If $config lacks the key 'url'
*/
protected function provideConfigTab($name, $config = array())
{
if (! array_key_exists('url', $config)) {
throw new ProgrammingError('A module config tab MUST provide and "url"');
throw new ProgrammingError('A module config tab MUST provide a "url"');
}
$config['url'] = $this->getName() . '/' . ltrim($config['url'], '/');
$this->configTabs[$name] = $config;
@ -856,7 +858,7 @@ class Module
}
/**
* Register new namespaces on the autoloader
* Register module namespaces on the autoloader
*
* @return $this
*/
@ -897,7 +899,7 @@ class Module
}
/**
* return bool Whether this module has translations
* Get whether the module has translations
*/
public function hasLocales()
{
@ -907,7 +909,7 @@ class Module
/**
* List all available locales
*
* return array Locale list
* @return array Locale list
*/
public function listLocales()
{
@ -954,10 +956,9 @@ class Module
}
/**
* Add routes for static content and any route added via addRoute() to the route chain
* Add routes for static content and any route added via {@link addRoute()} to the route chain
*
* @return $this
* @see addRoute()
*/
protected function registerRoutes()
{
@ -1012,8 +1013,8 @@ class Module
*/
protected function includeScript($file)
{
if (file_exists($file) && is_readable($file) === true) {
include($file);
if (file_exists($file) && is_readable($file)) {
include $file;
}
return $this;
@ -1021,19 +1022,17 @@ class Module
/**
* Run module config script
*
* @return $this
*/
protected function launchConfigScript()
{
if ($this->triedToLaunchConfigScript) {
return;
return $this;
}
$this->triedToLaunchConfigScript = true;
if (! file_exists($this->configScript)
|| ! is_readable($this->configScript)) {
return;
}
$this->registerAutoloader();
include($this->configScript);
return $this->includeScript($this->configScript);
}
/**
@ -1072,12 +1071,8 @@ class Module
}
/**
* Translate a string with the global mt()
*
* @param $string
* @param null $context
*
* @return mixed|string
* (non-PHPDoc)
* @see Translator::translate() For the function documentation.
*/
protected function translate($string, $context = null)
{