- Drupal 8 Module Development
- Daniel Sipos
- 134字
- 2021-07-02 15:45:18
Event Dispatcher and redirects
A common thing you'll have to do as a module developer is to intercept a given request and redirect it to another page, and more often than not, this will have to be dynamic, depending on the current user or other contextual info. Drupal 7 developers know very well that this has always been an easy task. Simply implement hook_init(), which gets called on each request and then use the famous drupal_goto() function. This, however, is no longer the case in Drupal 8. What we have to do now is subscribe to the kernel.request event (remember this from the preceding chapter?) and then change the response directly. However, before seeing an example of this, let's take a look at how we can perform a simpler redirect from within a Controller.
推薦閱讀
- Facebook Application Development with Graph API Cookbook
- Reporting with Visual Studio and Crystal Reports
- 零基礎搭建量化投資系統:以Python為工具
- JavaScript高效圖形編程
- Raspberry Pi Networking Cookbook(Second Edition)
- 跟老齊學Python:輕松入門
- Full-Stack React Projects
- 程序員修煉之道:通向務實的最高境界(第2版)
- Babylon.js Essentials
- Emotional Intelligence for IT Professionals
- 寫給大家看的Midjourney設計書
- Python預測分析與機器學習
- DB2SQL性能調優秘笈
- Python機器學習與量化投資
- 征服C指針(第2版)