How can I directly create an object instance in a certain way? This object is a task handler, the processor of each task may be different. Is it similar to the method of Yii::createObject(). I don’t want to register handlers in service.yarml, because there may be many handlers.
Here is what I would like to acheive:
$task = new Task;
// $handler = $this->container->get($task->getHandlerName()); 
$handler = createObject($task->getHandlerName());
$handler->handle($task);
// Handler
class MyHandler {
     private $manager;
      // autowiring
     public function __construct(EntityManagerInterface $manager) {
            $this->manager = $manager;
     }
     public function handle() {
     }
}