I have a controller in one module that generates paragraphs that are using unique bundle classes that I want to be able to use in other modules.
In my controller I have this
$bundle_class = \Drupal::service('class_resolver')->getInstanceFromDefinition('Drupal\other_module\Entity\Paragraph\StandardHero');
$paragraph = $bundle_class::create([
'type' => 'standard_hero',
'field_title' => [
'value' => 'Test'
]
]);
It does recognize the class because if I change the class sting to gibberish it complains that that class is not found. But I get this error
ArgumentCountError: Too few arguments to function Drupal\Core\Entity\ContentEntityBase::__construct(), 0 passed in /core/lib/Drupal/Core/DependencyInjection/ClassResolver.php on line 31 and at least 2 expected in Drupal\Core\Entity\ContentEntityBase->__construct() (line 189 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
How can I create a paragraph of a specified bundle class that appears in a different module?