1: <?php
2: /**
3: * A Horde_Injector:: based Horde_Core_Ajax_Application:: factory.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Core
9: * @author Michael Slusarz <slusarz@horde.org>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Core
12: */
13:
14: /**
15: * A Horde_Injector:: based Horde_Core_Ajax_Application:: factory.
16: *
17: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Horde
23: * @package Core
24: * @author Michael Slusarz <slusarz@horde.org>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Core
27: */
28: class Horde_Core_Factory_Ajax extends Horde_Core_Factory_Base
29: {
30: /**
31: * Return a Horde_Core_Ajax_Application instance.
32: *
33: * @param string $app The application name.
34: * @param Horde_Variables $vars Form/request data.
35: * @param string $action The AJAX action to perform.
36: *
37: * @return Horde_Core_Ajax_Application The requested instance.
38: * @throws Horde_Exception
39: */
40: public function create($app, $vars, $action = null)
41: {
42: $class = $app . '_Ajax_Application';
43:
44: if (class_exists($class)) {
45: return new $class($app, $vars, $action);
46: }
47:
48: throw new Horde_Exception('Ajax configuration for ' . $app . ' not found.');
49: }
50:
51: }
52: