Posted on 1/2/06 by Felix Geisendörfer
The authors of this post have marked it as deprecated. This means the information displayed is most likely outdated, inaccurate, boring or a combination of all three.
Policy: We never delete deprecated posts, but they are not listed in our categories or show up in the search anymore.
Update: I fixed a minor bug in the code. I don't think it changes anything but I've forgot to pass some variable as a reference which it should be passed as. I also corrected the code snippet below.
One thing I've been confronted with since the first time I've used CakePHP is that there where bugs that I would need to fix in order to make my apps work. Now I could have just gone into the file and change the stuff around, but the problem was that all these fixes would be lost with the next update, no matter if the problem still existed or not.
So what I found was that most of the Problems can be traced back to Model, Controller, View (and Helpers). Here is where Cake's very good architecture comes in handy, since you can just use classes that extend your "Fix-Classes". But how does one exactly do that? Since I think it's something a lot of people will come across I've created a little Zip package called FlexiFix which contains a vendor folder with a fix_controller, fix_model and fix_view and ... (this was the most difficult thing), a folder called "helper" where you can put in files that will overwrite existing helpers like Html, but extend the original ones.
So if you want to try out my little package the download it here: (flexifix 0.2.zip) [3,57 kbyte].
If you want to do it yourself but are interested in the way I overwrite exisiting helper classes have a look at this snippet out of fix_view.php:
$loadedHelpers = &parent::_loadHelpers($loaded, $helpers);
$fixHelperFolder = &new Folder(VENDORS.DS.'flexifix'.DS.'helpers');
$fixHelperFiles = $fixHelperFolder->find('^.*\.php$');
$emptyLoaded = array();
foreach($fixHelperFiles as $num => $file);
list($helperName, $ext) = explode('.', $file);
$helperName = Inflector::camelize($helperName);
$fixHelperName = 'Fix'.$helperName;
$fixHelper = &parent::_loadHelpers($emptyLoaded, array($fixHelperName));
$loadedHelpers[$helperName] = $fixHelper[$fixHelperName];
I hope this helps people to seperate their own bug fixes from the applications they write and therefore making updating an easier part of life.
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.