TCPDF integration Codeigniter constructor only use default parameters -
TCPDF integration Codeigniter constructor only use default parameters -
i integrate library. created class pdf:
require_once dirname(__file__) . '/tcpdf/tcpdf.php'; class pdf extends tcpdf { public function __construct($params) { parent::__construct(); } } but when phone call constructor other parameters, constructor utilize default params.
$this->load->library('pdf'); $pdf = new pdf('l', 'mm', array(216, 330), true, 'utf-8', false); but if alter class pdf tcpdf works fine.
$this->load->library('pdf'); $pdf = new tcpdf('l', 'mm', array(216, 330), true, 'utf-8', false); the problem want alter header , create new class extends tcpdf new header information. , cant phone call constructor of class (pdf class) custom params.
you must of course of study pass parameters parent class. , note tcpdf expects long list of separate parameters, not array. 1 way solve invokation call_user_func_array:
class pdf extends tcpdf { public function __construct() { call_user_func_array('parent::__construct', func_get_args()); } } note $params parameter removed pdf::__construct, because doesn't create sense anyway. instead, func_get_args() collect arbitrary number of parameters , pass them parent constructor.
of course, if $params array holds values passed tcpdf, can utilize 1 instead of func_get_args(). create sure array values in right order.
codeigniter parameters constructor integration tcpdf
Comments
Post a Comment