From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/Icinga/Web/Widget.php | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 library/Icinga/Web/Widget.php (limited to 'library/Icinga/Web/Widget.php') diff --git a/library/Icinga/Web/Widget.php b/library/Icinga/Web/Widget.php new file mode 100644 index 0000000..242138b --- /dev/null +++ b/library/Icinga/Web/Widget.php @@ -0,0 +1,48 @@ + + * $tabs = Widget::create('tabs'); + * + * + * @copyright Copyright (c) 2013 Icinga-Web Team + * @author Icinga-Web Team + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License + */ +class Widget +{ + /** + * Create a new widget + * + * @param string $name Widget name + * @param array $options Widget constructor options + * + * @return Icinga\Web\Widget\AbstractWidget + */ + public static function create($name, $options = array(), $module_name = null) + { + $class = 'Icinga\\Web\\Widget\\' . ucfirst($name); + + if (! class_exists($class)) { + throw new ProgrammingError( + 'There is no such widget: %s', + $name + ); + } + + $widget = new $class($options, $module_name); + return $widget; + } +} -- cgit v1.2.3