CoreBOSBB
Different instantiation of a module - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Development (https://discussions.corebos.org/forumdisplay.php?fid=18)
+--- Forum: coreBOS Development (https://discussions.corebos.org/forumdisplay.php?fid=4)
+--- Thread: Different instantiation of a module (/showthread.php?tid=526)



Different instantiation of a module - Guido1982 - 12-13-2016

I see that we have:

PHP Code:
        $modname 'SalesOrder';
        
$module Vtiger_Module::getInstance($modname); 

To get a module instance. But is that (and if so, how) different from

PHP Code:
$so_focus = new SalesOrder(); 
?


RE: Different instantiation of a module - joebordes - 12-13-2016

The difference is that getInstance() will include the class file for you. In other words,

$focus = new XX();

requires that you have previously done

require_once('modules/XX/XX.php');

while the getInstance will check if the file is not loaded yet and load it for you


RE: Different instantiation of a module - Guido1982 - 12-13-2016

Ah, good to know. But any way you instantiate, the same methods will be available?


RE: Different instantiation of a module - joebordes - 12-13-2016

yes, it is exactly the same, getInstance() ends creating a new XX()