mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 13:54:26 +02:00
Fix phpcs errors for Icinga\Web\Hook
This commit is contained in:
parent
0581d9a130
commit
4cdab8d904
@ -1,13 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
/**
|
/**
|
||||||
* Icinga Web Hook registry
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
*/
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
use Icinga\Application\Logger as Log;
|
use \stdClass;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use \Icinga\Application\Logger as Log;
|
||||||
use Icinga\Exception\NotImplementedError;
|
use \Icinga\Exception\ProgrammingError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icinga Web Hook registry
|
* Icinga Web Hook registry
|
||||||
@ -18,10 +41,6 @@ use Icinga\Exception\NotImplementedError;
|
|||||||
* <code>
|
* <code>
|
||||||
* Hook::register('grapher', 'My\\Grapher\\Class');
|
* Hook::register('grapher', 'My\\Grapher\\Class');
|
||||||
* </code>
|
* </code>
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2013 Icinga-Web Team <info@icinga.org>
|
|
||||||
* @author Icinga-Web Team <info@icinga.org>
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|
||||||
*/
|
*/
|
||||||
class Hook
|
class Hook
|
||||||
{
|
{
|
||||||
@ -40,10 +59,15 @@ class Hook
|
|||||||
protected static $instances = array();
|
protected static $instances = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Namespace prefix
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $BASE_NS = 'Icinga\\Web\\Hook\\';
|
public static $BASE_NS = 'Icinga\\Web\\Hook\\';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset object state
|
||||||
|
*/
|
||||||
public static function clean()
|
public static function clean()
|
||||||
{
|
{
|
||||||
self::$hooks = array();
|
self::$hooks = array();
|
||||||
@ -73,6 +97,7 @@ class Hook
|
|||||||
* @param string $name One of the predefined hook names
|
* @param string $name One of the predefined hook names
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws ProgrammingError
|
||||||
*/
|
*/
|
||||||
public static function get($name)
|
public static function get($name)
|
||||||
{
|
{
|
||||||
@ -112,9 +137,11 @@ class Hook
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create or return an instance of the hook
|
* Create or return an instance of the hook
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return \stdClass
|
* @return stdClass
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public static function createInstance($name, $key)
|
public static function createInstance($name, $key)
|
||||||
{
|
{
|
||||||
@ -145,9 +172,10 @@ class Hook
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for a valid class name
|
* Test for a valid class name
|
||||||
* @param \stdClass $instance
|
*
|
||||||
|
* @param stdClass $instance
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @throws \Icinga\Exception\ProgrammingError
|
* @throws ProgrammingError
|
||||||
*/
|
*/
|
||||||
private static function assertValidHook(&$instance, $name)
|
private static function assertValidHook(&$instance, $name)
|
||||||
{
|
{
|
||||||
@ -165,7 +193,9 @@ class Hook
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all instances of a specific name
|
* Return all instances of a specific name
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function all($name)
|
public static function all($name)
|
||||||
@ -182,8 +212,11 @@ class Hook
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the first hook
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return \stdClass
|
*
|
||||||
|
* @return stdClass
|
||||||
*/
|
*/
|
||||||
public static function first($name)
|
public static function first($name)
|
||||||
{
|
{
|
||||||
@ -194,12 +227,10 @@ class Hook
|
|||||||
* Register your hook
|
* Register your hook
|
||||||
*
|
*
|
||||||
* @param string $name One of the predefined hook names
|
* @param string $name One of the predefined hook names
|
||||||
|
* @param string $key
|
||||||
* @param string $class Your class name, must inherit one of the classes
|
* @param string $class Your class name, must inherit one of the classes
|
||||||
* in the Icinga/Web/Hook folder
|
* in the Icinga/Web/Hook folder
|
||||||
*
|
*
|
||||||
* @throws NotImplementedError unless we support multiple instances
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public static function register($name, $key, $class)
|
public static function register($name, $key, $class)
|
||||||
{
|
{
|
||||||
@ -224,10 +255,12 @@ class Hook
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register an object
|
* Register an object
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param object $object
|
* @param object $object
|
||||||
* @throws \Icinga\Exception\ProgrammingError
|
*
|
||||||
|
* @throws ProgrammingError
|
||||||
*/
|
*/
|
||||||
public static function registerObject($name, $key, $object)
|
public static function registerObject($name, $key, $object)
|
||||||
{
|
{
|
||||||
@ -242,5 +275,4 @@ class Hook
|
|||||||
self::$instances[$name][$key] =& $object;
|
self::$instances[$name][$key] =& $object;
|
||||||
self::registerClass($name, $key, get_class($object));
|
self::registerClass($name, $key, get_class($object));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user