官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 盘锦市| 雅安市| 广东省| 封开县| 滦平县| 宜春市| 甘洛县| 温宿县| 平罗县| 大港区| 栾城县| 积石山| 博客| 和平区| 成安县| 大理市| 吴川市| 遂川县| 德兴市| 台北县| 德昌县| 望城县| 四会市| 普陀区| 泾川县| 浦县| 湖北省| 五莲县| 于田县| 启东市| 正阳县| 图片| 台东县| 扶沟县| 江孜县| 汤原县| 宁强县| 孙吴县| 扶余县| 宁阳县| 泌阳县|