[Vtigercrm-developers] Extend getInstanceById()?
Alan Lord
alanslists at gmail.com
Thu Dec 10 14:39:23 GMT 2020
On 10/12/2020 14:23, Sukhdev Mohan wrote:
> What happens if you extend the Vtiger_Record_model and then override it?
As I said, it makes no difference because the normal way to call it is
by using calling Vtiger_Record_Model::getInstanceById() first.
It is _this_ function which finds your "MyCustomModule_Record_Model"
class and instantiates it. (But this is the child, not the parent).
Also in certain places in vtiger, where you might want to access an
existing Record Model, say in the DetailView module, you call
$this->getRecord(). This Record Model was instantiated by the
Vtiger_Record_Model::getInstanceById() call so again you can't really
extend the function because it has already been called. The only way is
to explicitly call your own custom method in your Record Model is to use
MyCustomModule_Record_Model::getInstanceById(). Which is what I am doing
for now.
being able to pass a callback/method parameter to this at the vtiger
level might work for most situations, but not all as described above.
Cheers
Al
More information about the vtigercrm-developers
mailing list