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

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.

主站蜘蛛池模板: 赫章县| 婺源县| 安仁县| 英吉沙县| 溧水县| 无为县| 南康市| 洪江市| 竹溪县| 闽侯县| 鄄城县| 广昌县| 襄汾县| 肃北| 岳池县| 垫江县| 息烽县| 资溪县| 宝鸡市| 潮安县| 德清县| 新乐市| 大竹县| 曲沃县| 恩施市| 改则县| 招远市| 黄平县| 曲阳县| 津市市| 彝良县| 伊宁市| 德兴市| 吉木萨尔县| 上思县| 綦江县| 台江县| 潞西市| 股票| 吉林省| 逊克县|