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

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.

主站蜘蛛池模板: 伊川县| 大化| 宿松县| 忻城县| 东山县| 阿鲁科尔沁旗| 绥棱县| 昭觉县| 利辛县| 新津县| 通辽市| 冕宁县| 长白| 乐安县| 东兰县| 新宾| 林州市| 巴彦淖尔市| 伊吾县| 宁化县| 新巴尔虎右旗| 增城市| 阿克苏市| 紫阳县| 吴忠市| 海淀区| 怀仁县| 徐州市| 富裕县| 商都县| 车险| 吴江市| 邢台县| 津南区| 凤冈县| 岳普湖县| 水富县| 洪江市| 清涧县| 琼中| 高密市|