Extending Controllers

2011-07-08 Thread Krissy Masters
Can you extend out controllers just like a controller extends
app_controller?

 

I have my users_controller and the user/person can edit various "settings"
in their account but I do not want these settings edited in the form to
update standard user info (name, location, and so on) simple actions to
update the "setting" fields so I would like a settings controller to extend
users and then settings_controller action edit would do what I need it to
do.

 

I would like to keep specific functions / logistical operations
compartmentalized so when updating the User settings 2 years down the road
someone coming along is not wondering where is the users settings since edit
just updates 

 

I know I can add the function into the users_controller, I also know I can
make a user has 1 setting belongs to user and break up the db in this case,
or settings_controller var $uses => array('User');  but that's not what im
asking so is it OK to extend it out?

 

Thanks guys!

 

K

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Extending controllers

2007-01-13 Thread the_woodsman

As no one else has added, I'll give my two pennies worth -
"extended controller takes longer to process because of having to go up
the chain.  I don't know how much overhead this really is, though."

I wouldn't worry about it, Cake's very OO and subclassing like this is
standard OO practice - go with the flow, not against it!
If you're still concerned, the Decorator design pattern can be useful
for stopping overly deep class families (check Wikipedia, Google).

"I'm wondering though, is there a way to get the parent's views
such that I only have to have a view in one place, such as 'article'
instead of duplicating views for content, announcement and event? "

Maybe I'm not getting you, but could you not just create some fields in
the top level class, or app_controller, which can be accessed from all
subclasses and tell them what folder to look into for the view?

Or you can put repeating view stuff in different layouts, seperating
them like that, or in Elements...  take your pick!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Extending controllers

2007-01-11 Thread Dave Rogers

I have an CMS application that has multiple 'modules' that can be used
on each 'page'.  These 'modules' seem to naturally extend each other.
A sample hierarchy of modules is below:

Item
--> Article
--> Content
--> Announcement
--> Event
--> File
--> Document
--> Image
--> Audio

So, in my item controller, I can define common things, like 'title'.
Then the article controller extends 'item' by adding 'title' and
'body'.  Then the event controller extends 'article' by adding
'start_date', 'end_date', 'location', etc.

Just because of OO design, each extended controller takes longer to
process because of having to go up the chain.  I don't know how much
overhead this really is, though.

It seems to work fairly well:  I only have to change things in one
place.  I'm wondering though, is there a way to get the parent's views
such that I only have to have a view in one place, such as 'article'
instead of duplicating views for content, announcement and event?

Is there a more defined way to do what I am attempting?


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---