$handler_settings =
[ 'target_bundles' =>
[ $this->vocabulary->
id() =>
$this->vocabulary->
id(),
],
'auto_create' => TRUE,
];
$this->
createEntityReferenceField('node', 'article',
$this->fieldName, NULL, 'taxonomy_term', 'default',
$handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED
);
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::
service('entity_display.repository'
);
$display_repository->
getFormDisplay('node', 'article'
) ->
setComponent($this->fieldName,
[ 'type' => 'options_select',
]) ->
save();
$display_repository->
getViewDisplay('node', 'article'
) ->
setComponent($this->fieldName,
[ 'type' => 'entity_reference_label',
]) ->
save();
} /**
* Creates some terms and a node, then tests the tokens generated from them.
*/