I'm attempting to create a taxonomy term inside a Form plugin like so
$term = Term::create([
'name' => 'my taxonomy term',
'vid' => 'vocabulary_to_put_it_in',
]);
$term->save();
When I do so I receive an error
Fatal error: Class 'Drupal\my_module\Form\Term' not found
My gut is telling me that I'm not including the namespace like I should but I'm not sure how to actually figure out how to discover that. I'm creating nodes by using
\Drupal\node\Entity\Node::create
And I receive no errors for that. I'm assuming that it's because I'm using \Drupal\node\Entity\ before it, but I was only able to figure that out by looking at examples. I looked at this page https://api.drupal.org/api/drupal/core%21modules%21taxonomy%21src%21Controller%21TaxonomyController.php/class/TaxonomyController/8.1.x and saw the class hierarchy class \Drupal\taxonomy\Controller\TaxonomyController but when using
\Drupal\taxonomy\Controller\TaxonomyController\Term::create
I still get an error saying
Fatal error: Class 'Drupal\taxonomy\Controller\TaxonomyController\Term' not found
If it is true, that the reason why it is failing, is because I'm not including the right namespace, then how do I use the official documentation to figure out what I should be including? Or is there something else I'm missing entirely?