root/trunk/midcom/midcom.helper.filesync/exporter.php

Revision 17556, 2.1 kB (checked in by flack, 1 month ago)

yet more PHP5-style constructors

Line 
1 <?php
2 /**
3 * @package midcom.helper.filesync
4 * @author The Midgard Project, http://www.midgard-project.org
5 * @version $Id: viewer.php 3975 2006-09-06 17:36:03Z bergie $
6 * @copyright The Midgard Project, http://www.midgard-project.org
7 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
8 */
9
10 /**
11  * @package midcom.helper.filesync
12  */
13 class midcom_helper_filesync_exporter extends midcom_baseclasses_components_purecode
14 {
15     /**
16      * Initializes the class. The real startup is done by the initialize() call.
17      *
18      * @param midcom_helper_replication_type_dba $type type
19      */
20     function __construct()
21     {
22          $this->_component = 'midcom.helper.filesync';
23          parent::__construct();
24     }
25     
26     /**
27      * This is a static factory method which lets you dynamically create exporter instances.
28      * It takes care of loading the required class files. The returned instances will be created
29      * but not initialized.
30      *
31      * On any error (class not found etc.) the factory method will call generate_error.
32      *
33      * <b>This function must be called statically.</b>
34      *
35      * @param string $type type
36      * @return midcom_helper_filesync_exporter A reference to the newly created exporter instance.
37      * @static
38      */
39     function & create($type)
40     {
41         $filename = MIDCOM_ROOT . "/midcom/helper/filesync/exporter/{$type}.php";
42         
43         if (!file_exists($filename))
44         {
45             $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Requested exporter file {$type} is not installed.");
46             // This will exit.
47         }
48         require_once($filename);
49
50         $classname = "midcom_helper_filesync_exporter_{$type}";       
51         if (!class_exists($classname))
52         {
53             $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Requested exporter class {$type} is not installed.");
54             // This will exit.
55         }
56         
57         /**
58          * Php 4.4.1 does not allow you to return a reference to an expression.
59          * http://www.php.net/release_4_4_0.php
60          */
61         $class = new $classname();
62         return $class;
63     }
64 }
65 ?>
Note: See TracBrowser for help on using the browser.