$fields = BaseFieldDefinition::create('entity_reference') ->setLabel(t(<label>)) ->setDescription(t(<description>)) ->setRevisionable(TRUE) ->setSetting('target_type', 'taxonomy_term') ->setTranslatable(TRUE) ->setTargetEntityTypeId(<vocabulary machine name>);
DON'T HACK CORE! It's THE cardinal rule of Drupal. Like another rule, Don't eat yellow snow, it's inviolate...immutable...or is it?
There is one circumstance when hacking core is a good thing. "Really?" you ask. Yes, definitely. Hacking core is a great way to find out how a particular part of Drupal is working, particularly if you can't use something like xdebug. In that case, if you want to see what the world looks like when you get to a certain place in the code, there's nothing better than sticking in some debug code. There are, however, some precautions you should take: