[Vtigercrm-developers] Extend getInstanceById()?

Uma S uma.s at vtiger.com
Fri Dec 11 17:47:38 GMT 2020


Hi Alan,

So to make use of my extended method, I have to use
"MyCustom_Record_Model::getInstanceById(...)" explicitly to achieve the
required result.

Is this design choice deliberate? Is there another way?

Yes! The design choice is deliberate, Core record api getInstanceById()
should generate the requested module object and instantiate to current
record.

In the current approach, the only way to invoke the custom
defined getInstanceById() is as you specified above.

But i do agree with your thought for callback in this case, where the
constructor trigger is not of much use.

Please do file an issue on code.vtiger.com. So that we can review to take
it forward.

On Thu, Dec 10, 2020 at 10:36 PM Sukhdev Mohan <s.mohan at myti.it> wrote:

> Ah Sorry I didn’t understood the problem at first. This is indeed an issue
> worth finding a clever solution.
>
>
> Best Regards,
> *Sukhdev Mohan* | *Software Developer*
>
>
>
>
>
>
> Il giorno 10 dic 2020, alle ore 15:39, Alan Lord <alanslists at gmail.com>
> ha scritto:
>
> 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
> _______________________________________________
> http://www.vtiger.com/
>
>
> _______________________________________________
> http://www.vtiger.com/



-- 
With
Best Regards
Uma.S
Vtiger Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20201211/cd4b9e9f/attachment.html>


More information about the vtigercrm-developers mailing list