Module and Operation ing

Source: Internet
Author: User
The template and Operation ing function is a ing mechanism for module and Operation settings supported by version 3.1.2. because the URL access address can be dynamically changed by changing the configuration (actually changed, not the alias, the security of the application is enhanced, and the ing mechanism has the URL case-insensitive access feature, which is also very helpful for application migration. The template and Operation ing function is a ing mechanism for module and Operation settings supported by version 3.1.2. because the URL access address can be dynamically changed by changing the configuration (actually changed, not the alias, the security of the application is enhanced, and the ing mechanism has the URL case-insensitive access feature, which is also very helpful for application migration.
Under normal circumstances, if you need to change the URL module or operation access, there are many files to be modified, which may easily lead to association errors. In particular, when many applications need to migrate to the new version, the URL address is greatly adjusted due to many changes to the model and controller. through the module and Operation ing function, it can easily solve such problems.

To define module ing, you only need to define it in the configuration file:
  1. 'URL _ MODULE_MAP '=> array (
  2. 'User' => 'Member ',
  3. 'Blog '=> 'info ',
  4. )
The copy code URL_MODULE_MAP is an array. each array item represents:
  1. 'Module ing name' => 'actual module name'
The copy code ing name is case-insensitive. Therefore, after setting the ing name, the URL access starts from the original:
  1. Http: // serverName/index. php/Member/index
  2. Http: // serverName/index. php/Info/index
The copied code is changed:
  1. Http: // serverName/index. php/user/index
  2. Http: // serverName/index. php/blog/index
Copy the code and the original access URL is invalid. this is also one of the differences between changing the URL and defining the routing mode. The access to modules without a ing definition remains unchanged.
After the module ING is defined, you can use MODULE_ALIASConstant reads the URL name of the current module.

Operation ing not only supports module name ing, but also supports ing of Operation names. operation ING is defined as follows:
  1. 'URL _ ACTION_MAP '=> array (
  2. 'Member' => array (
  3. 'Register '=> 'Add ',
  4. ),
  5. 'Info' => array (
  6. 'List' => 'index'
  7. ),
  8. )
The copy code URL_ACTION_MAP parameter is a two-dimensional array. each array item represents:
  1. 'Actual module name' => array (
  2. 'Operation ing name 1' => 'actual operation name 1'
  3. 'Operation ing name 2' => 'actual operation name 2'
  4. ......
  5. )
The copy code operation ing name is case insensitive.
  1. Http: // serverName/index. php/Member/add
  2. Http: // serverName/index. php/Info/index
The copied code is changed to (regardless of the previously defined module Ing ):
  1. Http: // serverName/index. php/Member/register
  2. Http: // serverName/index. php/Info/list
Copy the code, and access from the original URL fails. The operation access address that does not define the ING remains unchanged.
After the operation ING is defined, you can use ACTION_ALIASConstant reads the name of the operation in the URL of the current operation.
Operation ING and module ING can be defined at the same time without any impact, for example:
  1. 'URL _ MODULE_MAP '=> array (
  2. 'User' => 'Member ',
  3. ),
  4. 'URL _ ACTION_MAP '=> array (
  5. 'Member' => array (
  6. 'Register888' => 'Add ',
  7. ),
  8. )
Copy the code, the original registration address
  1. Http: // serverName/index. php/Member/add
The copied code becomes
  1. Http: // serverName/index. php/user/register888
Copy code
Many people may worry about the automatic support of the U function. after setting the module and Operation ING, the U function will need to be changed accordingly. In fact, you don't need to worry about it because the U function automatically supports module and Operation ING.
For example
  1. Href = "{: U ('Member/add')}"> user registration
No matter how you define the ing between the Member module and the add operation, the write method of the U method remains unchanged and still points to the mapped URL address correctly.

The summary module and Operation ING can be used in the following scenarios:
1. frequent URL changes
2. high URL security
3. applications to be transplanted do not want to change the URL address.
Precautions:
After the module and Operation ing are used, the routing definition of the relevant URL address may need to be adjusted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.