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

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.

主站蜘蛛池模板: 拜泉县| 章丘市| 临漳县| 墨竹工卡县| 青阳县| 上虞市| 绥化市| 右玉县| 枣强县| 昌平区| 嵩明县| 孟津县| 怀仁县| 八宿县| 台中县| 柳江县| 五河县| 五峰| 景洪市| 株洲市| 泾源县| 济源市| 内乡县| 察哈| 阳江市| 兰溪市| 榆林市| 郎溪县| 海南省| 长治县| 东明县| 金阳县| 精河县| 新乐市| 昌黎县| 宜兰县| 阿图什市| 屯昌县| 永春县| 分宜县| 博兴县|