Overview
  • Namespace
  • Class

Namespaces

  • rpf
    • api
      • module
    • extension
      • module
    • system
      • module

Classes

  • rpf\api\api
  • rpf\api\apiModule
  • rpf\api\bbRpc
  • rpf\api\module\bbCustomer_getFreeOrdNr
  • rpf\api\module\bbCustomer_readAddress
  • rpf\api\module\bbCustomer_readDiscount
  • rpf\api\module\bbCustomer_readEntry
  • rpf\api\module\bbCustomer_readPayment
  • rpf\api\module\bbCustomer_readTitle
  • rpf\api\module\bbCustomer_saveAdress
  • rpf\api\module\bbCustomer_validateAddress
  • rpf\api\module\bbCustomer_validateEntry
  • rpf\api\module\bbCustomer_validatePayinfo
  • rpf\api\module\bbDomain_readEntry
  • rpf\api\module\bbDomain_readFrontpage
  • rpf\api\module\bbDomain_readHandles
  • rpf\api\module\bbDomain_readPhpini
  • rpf\api\module\bbDomain_readSettings
  • rpf\api\module\bbDomain_readSubdomain
  • rpf\api\module\bbDomain_readWebalizerSettings
  • rpf\api\module\bbDomain_searchEntry
  • rpf\api\module\bbEmail_readAccount
  • rpf\api\module\bbMysql_inuseEntry
  • rpf\api\module\bbMysql_makeBackup
  • rpf\api\module\bbMysql_readEntry
  • rpf\api\module\bbOrder_readAccountAddress
  • rpf\api\module\bbOrder_readAccountEntry
  • rpf\api\module\bbOrder_readDisposition
  • rpf\api\module\bbOrder_readEntry
  • rpf\api\module\bbQuota_readEntry
  • rpf\api\module\customer
  • rpf\api\module\email
  • rpf\api\module\order
  • rpf\api\module\placeholder
  • rpf\api\module\user
  • rpf\extension\extension
  • rpf\extension\extensionModule
  • rpf\extension\invoiceTextExport
  • rpf\extension\mailExport
  • rpf\extension\module\domainExport
  • rpf\extension\module\index
  • rpf\extension\module\mgntRatioExport
  • rpf\system\module
  • rpf\system\module\log
  • rpf\system\module\moduleManager
  • rpf\system\rpf

Exceptions

  • rpf\system\module\exception
 1 <?php
 2 
 3 namespace rpf\system\module;
 4 use rpf\system\rpf;
 5 
 6 /**
 7  * RPF ModuleManager
 8  *
 9  * Manages all modules (rpf-core, api-modules, extension-modules)
10  * and stores them in $GLOBALS['rpfModule']
11  *
12  * This class can and should ONLY get instantiated by rpf\module()
13  *
14  * @author Andreas Doebeling <ad@1601.com>
15  * @copyright 1601.production siegler&thuemmler ohg
16  * @link https://github.com/ADoebeling/RP2-Framework
17  * @link https://xing-ad.1601.com
18  */
19 class moduleManager
20 {
21     /**
22      * @var array ['objectName' => object]
23      */
24     protected $module = array();
25 
26     public function __construct()
27     {
28         if (!isset($GLOBALS['rpfModule']) || $this != $GLOBALS['rpfModule'])
29         {
30             //throw new exception('Sorry, class can\'t get used outside of rpf / $GLOBALS');
31         }
32         if (!isset($this->module['rpf\system\rpf']))
33         {
34             //$this->add(rpf::class);
35         }
36     }
37 
38     public function get($name)
39     {
40         if (!is_string($name))
41         {
42             $type = gettype($name);
43             throw new exception("Name (=string) of object expected, $type given");
44         }
45         if (!isset($this->module[$name]))
46         {
47             $this->add($name);
48         }
49         return $this->module[$name];
50     }
51 
52     /**
53      * Add a module
54      *
55      * @param string|object $nameOrObject
56      * @throws \Exception
57      * @return bool true
58      */
59     public function add($nameOrObject)
60     {
61         if (is_string($nameOrObject))
62         {
63             if (!isset($this->module[$nameOrObject]))
64             {
65                 log::debug("Instantiating $nameOrObject()", __METHOD__."($nameOrObject)");
66                 $this->module[$nameOrObject] = new $nameOrObject();
67             }
68             else
69             {
70                 throw new exception("Can't set object by name '$nameOrObject' because it already exists");
71             }
72         }
73         else if (is_object($nameOrObject))
74         {
75             $name = get_class($nameOrObject);
76             if (!isset($this->module[$name]))
77             {
78                 $this->module[$name] = new $nameOrObject;
79             }
80             else
81             {
82                 throw new exception("Can't set object by instance of '$name' because it already exists");
83             }
84         }
85         else
86         {
87             $type = gettype($nameOrObject);
88             throw new exception("I've no idea what you're trying, but I'm sure that you can't add a $type to the global module-class");
89         }
90         return true;
91     }
92 
93     public function __destruct()
94     {
95         log::debug("Shutdown moduleManager\n\n\n    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n", __METHOD__);
96     }
97 }
API documentation generated by ApiGen