<div class="gmail_quote">On Thu, Jun 14, 2012 at 8:26 AM, Alan Lord <span dir="ltr"><<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there a "proper" way to override a core vtiger function?<br>...<br>
What do others do in this kind of situation?<br></blockquote><div><br></div><div>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</div>
<div><br></div><div>- class Calendar</div><div>+abstract class VTCalendar</div><div><br></div><div>and at the bottom of the file</div><div><br></div><div>+require_once('modules/MyCalendar/MyCalendar.php');</div><div>
<br></div><div>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.</div><div><br></div>
<div>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</div><div><br></div><div><div>function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)</div>
<div>+{</div><div>+ // override behavior here</div><div>+ _getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)</div><div>+ // more override behavior here</div><div>+}</div><div>+</div><div>+function _getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)</div>
<div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>global $log,$current_user;</div></div><div><br></div><div>This will leave you with only one hunk that should merge easily.</div><div><br></div>
<div>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.</div></div>