11

There's an entity created by another module and I'd like to change some of the fields used on a listing page. Currently that page is using the entity's list builder class. Is there a way I can define a new list builder class, make my changes, and use that for this entity? I have tracked this down to where D8 get's entity definition and loads the list builder class from that. I can't find a way to alter the definitions or another way to inject a different class here.

In more specific terms, I have created an entity with ECK and want to override the functionality around EckEntityListBuilder.

0

1 Answer 1

23

You want something like this:

<?php

/**
 * Implements hook_entity_type_alter().
 */
function MY_MODULE_entity_type_alter(array &$entity_types) {
  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  $entity_types['node']->setListBuilderClass('Drupal\MY_MODULE\NewListBuilder');
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.