[Vtigercrm-developers] Function Overriding?
Adam Heinz
amh at metricwise.net
Thu Jun 14 07:27:46 PDT 2012
On Thu, Jun 14, 2012 at 8:26 AM, Alan Lord <alanslists at gmail.com> wrote:
> Is there a "proper" way to override a core vtiger function?
> ...
> What do others do in this kind of situation?
>
Strictly speaking, the "proper" way to override a function is to subclass
the class and override it in the subclass. I've actually done something
along these lines to the calendar with two surgical modifications to
Calendar.php
- class Calendar
+abstract class VTCalendar
and at the bottom of the file
+require_once('modules/MyCalendar/MyCalendar.php');
which defines a class named Calendar that extends VTCalendar. It's very
easy to merge these two hunks, and I can now use all the standard OOP
tricks to change behavior as I see fit.
Now, to your point specifically, the function you want to modify isn't on a
class, so the trick I describe above won't work. You could do something
similar though
function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)
+{
+ // override behavior here
+ _getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)
+ // more override behavior here
+}
+
+function _getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)
{
global $log,$current_user;
This will leave you with only one hunk that should merge easily.
And to chime in with Joe, at some point you have to decide whether the
added flexibility of being able to do exactly what you want in the CRM is
worth the overhead of merging and maintaining the code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20120614/b71eca54/attachment.html
More information about the vtigercrm-developers
mailing list