use Doctrine\ORM\EntityManager; $entityManager = new EntityManager(); $unitOfWork = $entityManager->getUnitOfWork();
use Doctrine\Common\Persistence\ObjectManager; class MyObjectManager implements ObjectManager { public function getUnitOfWork() { return new MyUnitOfWork(); } } $objectManager = new MyObjectManager(); $unitOfWork = $objectManager->getUnitOfWork();In this example, we implement the ObjectManager interface in our own class (MyObjectManager) and provide a custom implementation for the getUnitOfWork() method. We then create an instance of our custom object manager and retrieve the corresponding UnitOfWork instance using the getUnitOfWork() method. The Doctrine\Common\Persistence namespace is part of the Doctrine Common library, which provides various utility classes used by the different Doctrine projects.