Skip to content

Alter Entity Types

Willi edited this page Apr 10, 2018 · 1 revision

This can be used to change e.g. a form of an entity type, which is defined in the meta tags

/**
 * Implements hook_entity_type_alter()
 *
 * @param array $entity_types
 */
function my_module_entity_type_alter(array &$entity_types) {
  // change form for entity_type
  $entity_types['<entity_type>']->setFormClass('default', 'Drupal\<some_module>\Form\<some_form>');
  
  // changes the class
  $entity_types['registration']->setClass('Drupal\<some_module>\Entity\<some_entity>');
}