- 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.
推薦閱讀
- Web前端開發技術:HTML、CSS、JavaScript(第3版)
- Visual C++數字圖像模式識別技術詳解
- 實戰Java程序設計
- iOS開發實戰:從零基礎到App Store上架
- 我的第一本算法書
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- 零基礎學Java程序設計
- Go并發編程實戰
- Haskell Data Analysis Cookbook
- Android應用案例開發大全(第二版)
- 區塊鏈技術進階與實戰(第2版)
- Python編程:從入門到實踐(第3版)
- Troubleshooting Citrix XenApp?
- Visual Basic 程序設計實踐教程
- Python機器學習開發實戰