Re: Help in DRY'ing a controllers
Thanks for replying, this information might come in handy later. I just noticed that I have a typo in my title. It's supposed to be 'help in dry'ing controllers' On Mar 5, 1:08 am, majna wrote: > CommonController extends AppController > all common methods here... > (remeber to set parent::beforefilter() etc. if there is controller > callabacks) > > App:import('Controller', 'Common'); > PostController extends CommonController > > On Mar 4, 3:16 pm, ramonmaruko wrote: > > > > > > > I have three controllers that have the same code for the index/add/ > > edit/delete/view actions. How should I refactor the code so that it'll > > be in just one place, and those three controllers would just inherit > > the actions from somewhere? Currently, I have the actions defined > > inside my AppController class. Each action checks to see if the > > controller that called the action is one the three controllers > > 'expected' to inherit them. Is there a better way of doing this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Help in DRY'ing a controllers
Thanks for the links, I think I'll go with grigri's approach. On Mar 5, 1:03 am, keymaster wrote: > These links may help: > > http://groups.google.com/group/cake-php/browse_thread/thread/5339fd41...http://groups.google.com/group/cake-php/browse_thread/thread/5339fd41... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Help in DRY'ing a controllers
CommonController extends AppController all common methods here... (remeber to set parent::beforefilter() etc. if there is controller callabacks) App:import('Controller', 'Common'); PostController extends CommonController On Mar 4, 3:16 pm, ramonmaruko wrote: > I have three controllers that have the same code for the index/add/ > edit/delete/view actions. How should I refactor the code so that it'll > be in just one place, and those three controllers would just inherit > the actions from somewhere? Currently, I have the actions defined > inside my AppController class. Each action checks to see if the > controller that called the action is one the three controllers > 'expected' to inherit them. Is there a better way of doing this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Help in DRY'ing a controllers
These links may help: http://groups.google.com/group/cake-php/browse_thread/thread/5339fd41fa534323# http://groups.google.com/group/cake-php/browse_thread/thread/5339fd41fa534323# --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help in DRY'ing a controllers
I have three controllers that have the same code for the index/add/ edit/delete/view actions. How should I refactor the code so that it'll be in just one place, and those three controllers would just inherit the actions from somewhere? Currently, I have the actions defined inside my AppController class. Each action checks to see if the controller that called the action is one the three controllers 'expected' to inherit them. Is there a better way of doing this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---