ice / framework

Source code of Ice framework
https://www.iceframework.org
BSD 3-Clause "New" or "Revised" License
341 stars 45 forks source link

show cases for $dispatcher->forward #229

Closed Yahasana closed 5 years ago

Yahasana commented 5 years ago

it seem that dispatcher::forward() is not a well work feature. show a user case would be very helpful.

mruz commented 5 years ago

It's in Phalcon but similar, https://github.com/mruz/las/blob/master/app/cli/tasks/CronTask.php look at main action, it forwards to firewall action and firewall action to Firewall task. You can pass current data like the params or reset if needed.

Yahasana commented 5 years ago

what kind of cases need to run the handler action repeatly. and there is no way to set dispatcher->finished in controller:: after to make it rerun until reach to loops times

mruz commented 5 years ago

Right, you can skip by returning false on before or after, but not brake.

How about if we move let this->finished = true, to the end of while loop and change to:

if this->finished === true {
    return handler;
}
Yahasana commented 5 years ago

I'm not sure why this->finished === false the dispatcher will start to re-run the action again. it look a little magic and ridiculous.

Yahasana commented 5 years ago

it seem that this feature works with forward, which will interrupt current handler (in before, executed, after) and go to execute the forward one