source: sandbox/workflow/branches/609/lib/factory/Factory.php @ 2222

Revision 2222, 2.7 KB checked in by pedroerp, 14 years ago (diff)

Ticket #609 - Atualizando comentários para seguir o padrão phpdoc.

  • Property svn:executable set to *
Line 
1<?php
2/**************************************************************************\
3* eGroupWare                                                               *
4* http://www.egroupware.org                                                *
5* --------------------------------------------                             *
6*  This program is free software; you can redistribute it and/or modify it *
7*  under the terms of the GNU General Public License as published by the   *
8*  Free Software Foundation; either version 2 of the License, or (at your  *
9*  option) any later version.                                              *
10\**************************************************************************/
11
12/**
13 * The Factory frontend class.
14 * This class controls which concrete Factory
15 * will be used, depending on the current
16 * 'security mode'. It lazy instantiates both
17 * factories (process and module) when they are
18 * required, and stores these objects. All the
19 * accesses to factories are done through this class,
20 * implementing a kind of Proxy design pattern.
21 * This class depends on Security frontend class
22 * to decide which factory to call.
23 *
24 * @package Factory
25 * @license http://www.gnu.org/copyleft/gpl.html GPL
26 * @author Pedro Eugênio Rocha - pedro.eugenio.rocha@gmail.com
27 */
28class Factory {
29
30
31        /**
32         * @var object $_unsecuredFactory Stores WorkflowFactory object.
33         * @access private
34         * @static
35         */
36        private static $_unsecuredFactory = null;
37
38
39        /**
40         * @var object $_securedFactory Stores ProcessFactory object.
41         * @access private
42         * @static
43         */
44        private static $_securedFactory = null;
45
46
47        /**
48         * Constructor. Just disable direct instantiation.
49         *
50         * @access public
51         * @return void
52         * @static
53         */
54        public function __construct() {
55                throw new Exception("Oops! Static only class.");
56        }
57
58
59        /**
60         * Just forward this call to the correct class.
61         *
62         * @access public
63         * @retun object
64         * @static
65         */
66        public static function getInstance() {
67
68                /* oops. we are in the process space. */
69                if (Security::isEnabled()) {
70
71                        /* must instatiate it */
72                        if (is_null(self::$_securedFactory))
73                                self::$_securedFactory = new ProcessFactory();
74
75                        $args = func_get_args();
76                        call_user_func_array(array(self::$_securedFactory, "getInstance"), $args);
77
78                }
79                /* regular module space */
80                else {
81
82                        /* must instatiate it */
83                        if (is_null(self::$_unsecuredFactory))
84                                self::$_unsecuredFactory = new WorkflowFactory();
85
86                        $args = func_get_args();
87                        call_user_func_array(array(self::$_unsecuredFactory, "getInstance"), $args);
88                }
89
90        }
91
92
93        /**
94         * Just forward this call to the correct class.
95         *
96         * @todo I must implement it!
97         * @access public
98         * @retun object
99         * @static
100         */
101        public static function newInstance() {
102        }
103}
104
105?>
Note: See TracBrowser for help on using the repository browser.