首页 > 解决方案 > Drupal yml 安装文件

问题描述

我的模块有几个配置项,向用户实体添加一个字段并添加一个角色。两个配置都添加到 \MY_MODULE\config\install 中,安装效果很好耶!!!!!!

现在,当我卸载模块时,系统中仍然启用了字段和用户角色。这对我来说毫无意义。

有谁知道为什么或我需要做什么才能卸载它而不在 hook_uninstall 中编写代码(这就是我最终为这些字段所做的,但对我来说仍然没有意义)。

\MY_MODULE\config\install\user.role.tiimeoffadmin.yml 的内容

langcode: en
status: true
dependencies: {  }
id: timeoffadministrator
label: 'Time Off Administrator'
weight: 1
is_admin: false
permissions:
- 'access comments'
- 'access content'
- 'add time off entities'
- 'edit time off entities'
- 'view published time off entities'

感谢您的任何帮助,您可以提供。

标签: drupal-8

解决方案


我终于遇到了解决此问题的项目。对于 yml 文件,有需要添加的依赖项部分。因此,添加以下内容解决了我在字段和角色方面的问题。

dependencies:
  module:
  - timeoff
  enforced:
    module:
    - timeoff

我将答案归功于此线程(两个人在那里发布了该解决方案@Robert Ben Parkinson 和@Ahmad)

https://drupal.stackexchange.com/questions/164612/how-do-i-remove-a-configuration-object-from-the-active-configuration


推荐阅读