1

I am trying to delete a configuration from a module in hook_uninstall. My module creates a content type bundle which has to be deleted. I tried to use an approach described here: How to delete a content type, programmatically? but without luck, the content type still exists.

dependencies:
  enforced:
    module:
      - modulename

Of course, I delete entities of the given type before uninstall. Is there any way to do it programmatically: delete a content type with fields?

  • Did you tried $content_type = \Drupal::entityTypeManager() ->getStorage('node_type') ->load('MACHINE_NAME_OF_TYPE'); $content_type->delete(); in your hook_uninstall ? – berramou Mar 25 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.