Skip to content

Instantly share code, notes, and snippets.

@twfahey1
Created January 11, 2024 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twfahey1/47bd861e4fd72652401377f5f59cfdbb to your computer and use it in GitHub Desktop.
Save twfahey1/47bd861e4fd72652401377f5f59cfdbb to your computer and use it in GitHub Desktop.
Install a new custom entity in Drupal 10 existing module
<?php
/**
* Scenario: We just added a new content entity via drush generate entity:content. We want to install it.
* The module was already enabled, so we can easily install it with 2 lines.
*/
function superentity_demo_update_8001()
{
$entity_type_manager = \Drupal::entityTypeManager();
\Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type_manager->getDefinition('id_of_my_entity'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment