8

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.

  • hook_entity_type_info_alter or something like that. – user21641 Feb 15 '16 at 22:32
17

You want something like this:

<?php

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

Your Answer

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

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