Request action isn't *that* bad ;-)

In this case request action should be fine as you wont be calling it
very often (as opposed to say from in an element that is displayed on
every page).

That said, Graham's suggestion is a better solution.

Note, to get the best performance from requestAction you should use
the following syntax:

$this->requestAction(array("controller"=>"sites", "action"=>"add"));


On Feb 2, 12:14 pm, Turgs <timb....@gmail.com> wrote:
> Hello all
>
> What's an appropriate use of requestAction()?
>
> I have 3 controllers:
>    * UsersController
>    * SiteController
>    * SitePagesController
>
> Within the add() function of UsersController, I want to (a) create a
> new user (b) create a new site for that user with (c) one new page for
> that site.
>
> What's the best way to do this?
>
> I was thinking of:
>
> ######
>
> if ($this->User->save($this->data))
> {
>    # create site
>    $this->requestAction('/sites/add');
>
>    # add a page (homepage) for this site
>    $this->requestAction('/sitepages/add');
>
>    # Login the user and redirect to the dashboard
>    // login code here
>    $this->Session->setFlash(SOTF_MSG_USER_WELCOME);
>    $this->redirect(array('controller' => 'users' ,'action' =>
> 'dashboard'));
>
> }
>
> ######
>
> While the code for this looks clean, what I've read seems to indicate
> this isn't such a good idea due to performance issues.
>
> What else would I do?
>
> Thanks
> Turgs
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to