Re: Use Component in Model
nate wrote: > Actually, Model Behaviors already exist in 1.2 and are largely > functional. Yipe!!! Great work - thanks to the cakePHP team Tarique --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Use Component in Model
Actually, Model Behaviors already exist in 1.2 and are largely functional. Documentation on how to use them will be forthcoming, but for the time being, here's a little rundown. Let's say you have a behavior called List. you would create a class ListBehavior that extends ModelBehavior, and store it in app/models/behaviors. You would then include it in your model as follows: class Post extends Model { var $actsAs = array("List"); } And there you are. For a list of callbacks that you can specify in your behavior, refer to the base class, which is in cake/libs/model/behavior.php. I can't remember if all of them are implemented or not, but you can at least get your feet wet. Also, any methods defined in ListBehavior will be available as native methods in Post. For example, if you define a method called ListBehavior::moveFirst( ), it would be accessible as $this->Post->moveFirst( ); There are also facilities for mapping regular expressions to behavior methods, allow you to setup things like Model's magic findBy in your own classes. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Use Component in Model
Simplerules wrote: > But how can I use it in a model? To be perfectly exact: try to rethink Your application structure, please. If You want Your model will co-operate with some component, drive this behaviour from controller or from this component - Your component can implement method startup(&$controller) { $this->controller =& $controller; } and then in component methods You can call $this->controller->MyModel->read(). I'm not sure, but it looks to me like You just want to have access to controller's model in component, You know ;-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Use Component in Model
You can not. Model 'doesn't know' about controller (or it's component) or view (or it's helper). Model is only interface to repository of data (database/filesystem/network...) and has to be completely driven from controller (in some special cases is usable use model in different places then controller and You can create instance of Your model class for such a things). If You want some componentized functionality in Your models (as components for controllers or helpers for views), You will have to wait for CakePHP 1.2 - new term 'Behavior' is coming ;-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Use Component in Model
But how can I use it in a model? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Use Component in Model
If you have a component called Logins, for example, the class name would be LoginsComponent, and you would store it in app/controllers/components/logins.php. If you have all that right, it should be available in your controller as $this->Logins. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Use Component in Model
How do I use a component in a model? Even adding " var $components = array('Cookies', 'Logins');" doesn't load it. *Screwed up the last thread, confusing lingo. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---