1: <?php
2: /**
3: * Ansel_Widget:: class wraps the display of widgets to be displayed in various
4: * Ansel_Views.
5: *
6: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Michael J. Rubinsky <mrubinsk@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/gpl GPL
14: * @package Ansel
15: */
16: class Ansel_Widget
17: {
18: /**
19: * Factory method for creating Ansel_Widgets
20: *
21: * @param string $driver The type of widget to create.
22: * @param array $params Any parameters the widget needs.
23: *
24: * @return Ansel_Widget object
25: * @throws Ansel_Exception
26: */
27: static public function factory($driver, $params = array())
28: {
29: $driver = basename($driver);
30: $class = 'Ansel_Widget_' . $driver;
31: if (class_exists($class)) {
32: return new $class($params);
33: }
34:
35: throw new Ansel_Exception('Class definition of ' . $class . ' not found.');
36: }
37:
38: }
39: