回答:
hook_module_implements_alter()
モジュールの重量を変更するのではなく使用してください。
content_translation.moduleの実装例:
function content_translation_module_implements_alter(&$implementations, $hook) {
switch ($hook) {
// Move our hook_entity_type_alter() implementation to the end of the list.
case 'entity_type_alter':
$group = $implementations['content_translation'];
unset($implementations['content_translation']);
$implementations['content_translation'] = $group;
break;
// Move our hook_entity_bundle_info_alter() implementation to the top of the
// list, so that any other hook implementation can rely on bundles being
// correctly marked as translatable.
case 'entity_bundle_info_alter':
$group = $implementations['content_translation'];
$implementations = [
'content_translation' => $group,
] + $implementations;
break;
}
}
hook_module_implements_alter()
(実際に私に起こったのは、i18nモジュールの1つだと思います)。
このためのAPIが現在あります。
module_set_weight('your_module_name', 10);
Ivan Jarosが言ったように、フックを実装することもできます。これにより、よりきめ細かい制御が可能になります(たとえば、あるフックに対して最初に、別のフックに対して最後に、3番目の特定のモジュールの後に)。しかし、モジュールの重みも機能するはずです。
インポート/エクスポート構成を使用する場合、core.extension.yml
ファイル内のモジュールの重みを変更できます。モジュールの名前が重みの後に番号を付けます。
Modulesウェイトモジュールを使用できます。
場合によってはモジュールの実行順序を変更する必要があり、クエリを実行してシステムテーブルのモジュールの重みを変更するコードを作成する人もいれば、お気に入りのSQLクライアントに直接行ってレコードを直接変更する人もいます。このモジュールは、モジュールの重量を並べ替えるインターフェースを提供します。
開示:私はモジュールModules Weightのメンテナーです。