- 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.
- iOS面試一戰到底
- 深入理解Bootstrap
- Rust編程從入門到實戰
- PostgreSQL 11從入門到精通(視頻教學版)
- Magento 1.8 Development Cookbook
- Mathematica Data Analysis
- HTML5+CSS3 Web前端開發技術(第2版)
- HTML 5與CSS 3權威指南(第3版·上冊)
- .NET Standard 2.0 Cookbook
- SEO教程:搜索引擎優化入門與進階(第3版)
- 量子計算機編程:從入門到實踐
- Pandas 1.x Cookbook
- OpenCV:Computer Vision Projects with Python
- C++教程
- JavaScript實戰-JavaScript、jQuery、HTML5、Node.js實例大全(第2版)