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

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.

主站蜘蛛池模板: 睢宁县| 藁城市| 陇川县| 清新县| 镇赉县| 丹东市| 绩溪县| 晴隆县| 屏南县| 区。| 略阳县| 广德县| 汾西县| 宜都市| 紫阳县| 西盟| 鹤庆县| 正定县| 青冈县| 岢岚县| 浑源县| 香河县| 祁东县| 南郑县| 荔浦县| 延川县| 凤山市| 承德县| 通道| 都安| 吉安市| 怀宁县| 宜兴市| 固安县| 比如县| 揭东县| 金寨县| 武乡县| 荔浦县| 布尔津县| 青神县|