Zend Framework Plugins and Helpers - More Information

I am trying to figure out these issues and have read the Zend Framework in action (Allen) and the online documentation. I think that:

  • Action Assistants provide on-demand controller functions; and
  • Controller plugins provide runtime functionality on all controllers.

Is it correct?

Secondly, I see that controller plugins and action assistants can have init (), preDispatch (), and postDispatch () methods. In what priority are they executed, compared to those that are in the action controller itself, as well as in other plugins and helpers?

Finally, View Helpers have similar characteristics, or is it a completely different beast?

Any pointers to additional documentation would be greatly appreciated!

+4
source share
1 answer

Action Assistants Provide On-Demand Controller Functions

Action assistants provide both on-demand functionality and run-time functionality to all controllers using pre and post dispatch methods.

Since most developers only need to get involved in these events, I often see ZF guys (especially Ralph and Matthew) recommending these plugins over controllers.

The main difference between the two on this front is the controller plugins, which offer a lot more hooks at different stages of the send cycle.

I see that controller plugins and action assistants can have init (), preDispatch (), and postDispatch () methods. In what priority are they executed, compared to those that are in the action controller itself, as well as in other plugins and helpers?

For controller plugins, see http://framework.zend.com/manual/en/zend.controller.plugins.html (FYI, for controller plugins there is no init() method).

For controller action helpers, see http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelper.writingyourown

Finally, View Helpers have similar characteristics, or is it a completely different beast?

View helpers are similar to action helpers, as they are both sorted by a broker, but this is the only similarity.

Viewing assistants is, in essence, vehicles for creating content. Under the hood, they can be as simple or complex as required, but the main goal is to create lines.


I highly recommend reading this article from Matthew - http://weierophinney.net/matthew/archives/246-Using-Action-Helpers-To-Implement-Re-Usable-Widgets.html

+6
source

Source: https://habr.com/ru/post/1345459/


All Articles