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

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.

主站蜘蛛池模板: 宣城市| 克什克腾旗| 江达县| 扎兰屯市| 苏尼特左旗| 介休市| 南皮县| 台南县| 交口县| 江孜县| 河源市| 永康市| 温宿县| 鲁山县| 连山| 福清市| 天全县| 同仁县| 固阳县| 临猗县| 上高县| 白玉县| 黔江区| 浠水县| 福泉市| 柳林县| 徐水县| 古交市| 西乌珠穆沁旗| 当涂县| 弋阳县| 左权县| 天峻县| 龙门县| 武冈市| 新化县| 偃师市| 阿城市| 哈尔滨市| 阿巴嘎旗| 合阳县|