I've seen multiple ways to programmatically create entities.
In this case I'm creating a taxonomy term. One is using this method
$term = \Drupal\taxonomy\Entity\Term::create([ 'name' => $name, 'vid' => $vocabulary, ])->save();
Where I'm using the base entity class's public static create function. Another way to perform the action is using an entity storage manager. Like so:
$term = [ 'name' => $name, 'vid' => $vocabulary, ]; $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->create($term);
I looked up the 'create' function of the base Entity class and it seems to just be implementing what appears in the second example I provided. Is there a better practice between the two? Or does it not matter?
UPDATE: Also is there a difference between what the two return? Unless I'm doing things wrong I noticed that the top method returned an int which I'm assuming is the term id.