- Drupal 8 Module Development
- Daniel Sipos
- 141字
- 2021-07-02 12:22:42
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. You know, since we're on the subject.
- Mastering OpenLayers 3
- The Supervised Learning Workshop
- Java程序設計(慕課版)
- C#高級編程(第10版) C# 6 & .NET Core 1.0 (.NET開發經典名著)
- jQuery EasyUI網站開發實戰
- Visual C++實例精通
- Java應用開發與實踐
- Getting Started with PowerShell
- Git高手之路
- Java Web應用開發技術與案例教程(第2版)
- 從Excel到Python:用Python輕松處理Excel數據(第2版)
- 運用后端技術處理業務邏輯(藍橋杯軟件大賽培訓教材-Java方向)
- SQL Server與JSP動態網站開發
- Visual Basic程序設計
- PHP+MySQL+Dreamweaver動態網站開發從入門到精通(第3版)