MacroProg Posted July 26, 2012 Share Posted July 26, 2012 (edited) Hello. I need to override the PDF class to add it a new static function. My problem is the next : there is yet an override of the PDF class done. How can I do to add mine ? Can I name PDF2.php my file ? DO I have to add it to the existing file ? Thanks for your answers. Edited July 28, 2012 by MacroProg (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted July 26, 2012 Share Posted July 26, 2012 if PDF.php already exists in the override/classes folder, then you would just edit that existing one, and include your new function. Link to comment Share on other sites More sharing options...
MacroProg Posted July 26, 2012 Author Share Posted July 26, 2012 That's what I think about, but this isn't a very good solution because, if the other module that firstly installed the override of PDF is uninstall, it will broke my module. Well, I will think about it, and if I found another way or a solution for this problem, I will post it. Otherwise, if anyone has another solution, thanks to telling me. Link to comment Share on other sites More sharing options...
bellini13 Posted July 27, 2012 Share Posted July 27, 2012 it is the only solution if you want to override the PDF class. otherwise add your code somewhere else. why do you want to add a new static function to the PDF class? what would execute the function? Link to comment Share on other sites More sharing options...
MacroProg Posted July 27, 2012 Author Share Posted July 27, 2012 it's because I need to print a specific document whith Prestashop data from the front-end and the back-end. So, I thought that the override was the best way, isn't it ? Link to comment Share on other sites More sharing options...
bellini13 Posted July 27, 2012 Share Posted July 27, 2012 yes, creating an override is the appropriate action, however you do not want to because an override already exists. your options then are 1) edit the existing override and add your functionality 2) create your own custom PDF class (ie. PDF2.php) that perhaps extends PDF.php 1 Link to comment Share on other sites More sharing options...
MacroProg Posted July 27, 2012 Author Share Posted July 27, 2012 Well, I start with your first solution but I didn't thougth about your 2nd. It's interesting. Ok, thanks, for your help, I will see which one is better for me (probably the 2nd because this avoid the problem of uninstall). Thanks Link to comment Share on other sites More sharing options...
bellini13 Posted July 27, 2012 Share Posted July 27, 2012 one other thing to review. the module that overrides PDF.php, have you reviewed the module uninstall code to see if it actually deletes the override file? Link to comment Share on other sites More sharing options...
MacroProg Posted July 27, 2012 Author Share Posted July 27, 2012 yes, it overrides it, unfortunately. Link to comment Share on other sites More sharing options...
bellini13 Posted July 27, 2012 Share Posted July 27, 2012 but when the module is uninstalled, does it delete the override file? please provide the modules uninstall function here Link to comment Share on other sites More sharing options...
MacroProg Posted July 28, 2012 Author Share Posted July 28, 2012 yes, it's shure it delete the override file. but I writting my custom class that extends the first one. Thanks for your help. How can I check this conversation as solved ? I can't find a button for that. Link to comment Share on other sites More sharing options...
bellini13 Posted July 28, 2012 Share Posted July 28, 2012 I think you edit the first topic using full editor, and just change the subject Link to comment Share on other sites More sharing options...
MacroProg Posted July 28, 2012 Author Share Posted July 28, 2012 Thanks again, it's done Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now