Controller calling an other controller?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Controller calling an other controller?

realien

Does someone have an example of 1 controller calling another?

I have a controller that gets meta data keys from a database, this is a
utility funciton that is used by other controllers, I'm was under the
assumption that the $uses variable is just for including additional
models in your controller, but say I have

MetaDataController

getAllMetaData();  /// does not get from database, its "man" made...


and I have

AssetWebserviceController

and it needs to use the getAllMetaData action to get some data before
it can produce the xml for the webservice, what is the approved way of
doing that in cake?

Grant


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

Reply | Threaded
Open this post in threaded view
|

Re: Controller calling an other controller?

Jon Bennett

> Does someone have an example of 1 controller calling another?

you'll be wanting 'requestAction' sir.

Bascially, you call the full url from a controller or view, and the
calls the method and returns the result, eg:

// tests_controller
function getData ()
{
    return $this->Test->findAll ();
}

// examples controller

function index ()
{
    $tests = $this->requestAction ('/tests/getData');
}

more info on http://manual.cakephp.org/chapter/controllers

hth

jon

--


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

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

Reply | Threaded
Open this post in threaded view
|

RE: Controller calling an other controller?

realien

Thankyou, for some reason I'd interpreted the request action as a way to
access another view and not just the action of a controller, thanks for
the clarification.

Grant

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Jon Bennett
Sent: Wednesday, November 08, 2006 11:13 AM
To: [hidden email]
Subject: Re: Controller calling an other controller?


> Does someone have an example of 1 controller calling another?

you'll be wanting 'requestAction' sir.

Bascially, you call the full url from a controller or view, and the
calls the method and returns the result, eg:

// tests_controller
function getData ()
{
    return $this->Test->findAll ();
}

// examples controller

function index ()
{
    $tests = $this->requestAction ('/tests/getData');
}

more info on http://manual.cakephp.org/chapter/controllers

hth

jon

--


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett



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