An example from Sebastian Bergmann of how we can inject dependancies

This commit is contained in:
nathangray 2017-10-23 09:52:39 +02:00
parent 24de1dff3b
commit 3c096b3466

View File

@ -95,7 +95,7 @@ class infolog_ui
* *
* @return infolog_ui * @return infolog_ui
*/ */
function __construct() function __construct(Etemplate $etemplate = null)
{ {
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog'); if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog');
@ -107,7 +107,11 @@ class infolog_ui
$this->bo = new infolog_bo(); $this->bo = new infolog_bo();
$this->tmpl = new Etemplate(); if($etemplate === null)
{
$etemplate = new Etemplate();
}
$this->tmpl = $etemplate;
$this->user = $GLOBALS['egw_info']['user']['account_id']; $this->user = $GLOBALS['egw_info']['user']['account_id'];