- 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.
推薦閱讀
- Learn ECMAScript(Second Edition)
- Instant Zepto.js
- SQL for Data Analytics
- Python金融數(shù)據分析
- C語言程序設計案例精粹
- Windows內核編程
- INSTANT Sinatra Starter
- Mastering Backbone.js
- Building Serverless Web Applications
- 玩轉.NET Micro Framework移植:基于STM32F10x處理器
- 計算機組裝與維護(第二版)
- Developing Java Applications with Spring and Spring Boot
- Visual C++ 開發(fā)從入門到精通
- AngularJS Web Application Development Cookbook
- Swift編程實戰(zhàn):iOS應用開發(fā)實例及完整解決方案