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