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

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.

主站蜘蛛池模板: 阿拉善盟| 利川市| 和林格尔县| 余姚市| 定结县| 政和县| 富民县| 和平区| 安平县| 临清市| 龙川县| 新野县| 富平县| 黄大仙区| 阿勒泰市| 大荔县| 潼关县| 滦南县| 平安县| 巫溪县| 昌吉市| 盐边县| 开平市| 札达县| 元谋县| 大邑县| 瑞昌市| 石泉县| 曲阜市| 应城市| 合肥市| 开鲁县| 文昌市| 四子王旗| 西和县| 阿荣旗| 开封县| 共和县| 和田县| 镇江市| 临颍县|