Home  >  Article  >  Backend Development  >  Tag behavior scheduling of PHP.MVC template tag system_PHP tutorial

Tag behavior scheduling of PHP.MVC template tag system_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:04:10978browse

TagActionDispatcher is an implementation of the standard ActionDispatcher class that supports access to basic template tags. The TagActionDispatcher class supports the same ActionObjects collection and ViewResourcesConfig properties as the default ActionDispatcher. The TagActionDispatcher class can be used on systems with or without template tags, although there will be a small performance hit due to its extra processing.
The template tag library is PHP. A subsystem of the MVC framework structure, the template tag library works together with TagActionDispatcher to support some simple template tags.
The diagram below shows PHP. An overview of the MVC template tag system. Shown on the left is the program flow of the template tag system. On the right is the program flow of TagActionDispatcher, and how tag templates enable these classes to interact.

PHP.MVC的模板标签系统之标签行为调度


1. Initialization
When the controller passes control to the TagActionDispatcher, some initialization is triggered to set the ActionObjects and ViewResourcesConfig properties in order to use our template:
Retrieve the $form, $errors and $data objects from request. If any of these objects have been created before (such as in the Action class), then the objects will now be invisible in the resource template, otherwise the objects will be Set to NULL.
Retrieve the reference to the ViewResourcesConfig object, which contains the configuration parameters.
Set the path to the template source file and compiled template file in the ViewResourcesConfig parameter.
2. Set tag page
The extension of the template source file (may be ".ssp") is used to compare with the ViewResourcesConfig->tagFlagStr parameter to determine whether this page needs to be processed, otherwise the page will be processed as Standard (unlabeled) template file. We can configure the tag file extension in the view-resources element, like this:
. . .
tagFlagStr = ".ssp"
tagFlagCnt = "-4"
. . .
</view-resources>
tagFlagStr indicates that the tag template source file can be preprocessed, such as: myPage. ssp. This extension triggers tag processing. The attribute tagFlagCnt defines the number of characters at the end of the file name, including "." (xxxYyy.ssp). According to an example, -4 represents the last 4 characters of the source file name. The default value is . ssp and -4, so if we use a template file name like myPage. ssp, we don't need to set these parameters.
3. Process tag files
The template tag system decides whether to run the tag processor based on the ViewResourcesConfig->processTags attribute. If this property is true, the template page (and the pages it contains) will be processed by the tag handler class, otherwise the tag handler will not be called. Developers only need to set it to true during development, otherwise it will not be processed. But it should be noted that when the processTags attribute is set to true, the modified tag page will be compiled (this depends on the compileAll attribute setting). We can define the processTags attribute on the view-resources element, like this:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445229.htmlTechArticleTagActionDispatcher is an implementation of the standard ActionDispatcher class, which supports access to basic template tags. The TagActionDispatcher class supports the same ActionObjects collection and ViewResourcesConfi...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn