Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Zend Framework Action Assistant Zend_Controller_Action_Helper

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use Zend Framework action assistant Zend_Controller_Action_Helper, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

The details are as follows:

Through the assistant mode, some frequently used functional modules can be encapsulated so that they can be used flexibly where needed, mainly in action.

There are two types of helpers in Zend Framework, the action assistant (Zend_Controller_Action_Helper) and the attempt assistant (Zend_View_Helper).

The action assistant can instantly add functions (runtime and/or on-demand functionality) to any Zend_Controller_Action derived action controller, so as to minimize the need for derived action controller classes when adding common action controller functions.

The action helper is loaded when called, and can be instantiated at the time of request (bootstrap) or when the action controller is created (init ()).

Related documents involved

In / library/Zend/Controller/Action/

│ Exception.php

│ HelperBroker.php

│ Interface.php

├─ Helper

│ │ Abstract.php

│ │ ActionStack.php

│ │ AjaxContext.php

│ │ AutoCompleteDojo.php

│ │ AutoCompleteScriptaculous.php

│ │ Cache.php

│ │ ContextSwitch.php

│ │ FlashMessenger.php

│ │ Json.php

│ │ Redirector.php

│ │ Url.php

│ │ ViewRenderer.php

│ │

│ └─ AutoComplete

│ Abstract.php

└─ HelperBroker

PriorityStack.php

Common action assistants are:

FlashMessenger is used to handle FlashMessenger sessions

Json is used to decode and send JSON responses

Url is used to create Urls

Redirector provides another implementation to help programs redirect to internal or external pages

ViewRenderer automatically completes the process of building and rendering view objects in the controller.

Automatic response of AutoComplete to automatic completion of AJAX

ContextSwitch and AjaxContext provide alternative response formats for your actions

Cache implements the related operations of cache

ActionStack is used to manipulate the action stack.

Several instantiation ways of hands-on use

1. Through the getHelper () method of the $_ helper member of Zend_Controller_Action. Call getHelper () directly, passing in the name of the helper.

$redirector = $this- > _ helper- > getHelper ('Redirector'); / / $redirector- > getName (); $redirector- > gotoSimple (' index2')

two。 The helper object corresponding to the property of the _ helper helper accessed directly.

$redirector = $this- > _ helper- > Redirector

Zend_Controller_Action_HelperBroker

The Chinese name translates as "assistant agent", as the name implies, is the middleman of the action assistant.

The second way to instantiate an action is through Zend_Controller_Action_HelperBroker 's magic method _ _ get ().

Assistant brokers are used to register assistant objects and assistant paths, get assistants, and so on.

The implementation of Zend_Controller_Action_HelperBroker and the list of common methods

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report