drupa8でhook_init()する方法
OTHER FAQ
| カテゴリ | Core Ver. | 関連モジュール | タイトル |
|---|---|---|---|
| 言語 | 7.15 | Language | まだ翻訳されていない英語文、どうにかならない? |
| テーマ | 7.15 | CSS Injector | 簡単にCSSを追加したい |
| コンテンツの管理 | 6.x | Views Flag Calendar | 空き室予約のような仕組みは実現できますか? |
| コンテンツの作成 | 6.x | Views | カルーセルのように回転するコンテンツを作りたい |
| アップデート | 7.15 | Webform Backup_and_Migrate | drupal7.12 -> drupal7.14アップデートメモ |
| フォーム | 7.15 | Webform | WebformのEntity Translation |
| フォーム | 7.15 | Webform | Webform - 確認ページの多言語化 |
| コンテンツの作成 | 7.15 | Automatic_Nodetitles Automatic_Entity_Label | ノード投稿フォームにタイトル入力フォームを表示しない方法 |
コメント
カスタムモジュールで対応
パーマリンク Submitted by actbrain on 2018/01/12 11:27.
カスタムモジュールで対応
module_name.info.yml
module_name.services.yml
services: module_name_event_subscriber: class: Drupal\module_name\EventSubscriber\Module_nameSubscriber tags: - {name: event_subscriber}src/EventSubscriber/Module_nameSubscriber.php
<?php namespace Drupal\min_init\EventSubscriber; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class Min_initSubscriber implements EventSubscriberInterface { public function checkForRedirection(GetResponseEvent $event) { $request_uri = $_SERVER['REQUEST_URI']; \Drupal::logger('min_init')->notice($request_uri); if (preg_match('!^(/node/[0-9]+/)(edit|clone/prepopulate).*?destination=node/[0-9]+$!', $request_uri, $m)) { $path = \Drupal\Core\Url::fromUserInput($m[1] . $m[2]); $response = new RedirectResponse($path->toString()); $response->send(); } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events[KernelEvents::REQUEST][] = array('checkForRedirection'); return $events; } }ページ