开发者

Kohana 3 internal actions

开发者 https://www.devze.com 2023-03-17 08:38 出处:网络
I think that framework shouldn\' be a cage for developer, and because Kohana gives a lot of freedom I am just wondering how do other guys handle two action-related things:

I think that framework shouldn' be a cage for developer, and because Kohana gives a lot of freedom I am just wondering how do other guys handle two action-related things:

  1. Internal actions. I mean if i have a realy long action, i divide it to some subactions like internal_action, internal_someotheraction. What do you think, is it a good practice? Or maybe you avoid other functions then standard actions in controllers? And then maybe detec is action called internaly?

  2. Do you have sometimes situasions, when you want to redirect to some other action by just doing $this->action_other;return; ? Or do you always create a new HMVC redirect?

  3. 开发者_运维技巧


I often find the need to share functionality between public actions within a single controller or set of controllers. So, I either create private or protected methods to perform the task within the controller, or I create a base controller that several of my controllers can extend in order to utilize and/or specify the desired functionality.

I also have situations, especially in a form processing scenario, where I will not generate or associate any output from a particular action, but will instead call another action to handle the output after I have processed the requested action as needed. I typically don't use HMVC in these scenarios because I can easily get to the logic needed. I end up using HMVC requests in scenarios where I rely on logic and code within another controller to gather and populate the appropriate output/views. If I already have the data necessary, then I just need to use a view from my current controller.

I can't speak to what the best practice may be, but I'm sure that it largely depends on your scenario. There certainly has to be unnecessary overhead in making HMVC requests for everything.

0

精彩评论

暂无评论...
验证码 换一张
取 消