| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Doctrine\Bundle\DoctrineSkeletonMapperBundle; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Common\EventManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\SkeletonMapper\DataSource\DataSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Doctrine\SkeletonMapper\DataSource\DataSourceObjectDataRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Doctrine\SkeletonMapper\Hydrator\BasicObjectHydrator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Doctrine\SkeletonMapper\ObjectFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Doctrine\SkeletonMapper\ObjectManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Doctrine\SkeletonMapper\ObjectRepository\ObjectRepositoryFactory as BaseObjectRepositoryFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Doctrine\SkeletonMapper\ObjectRepository\ObjectRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class ObjectRepositoryFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     /** @var ObjectManager */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     private $objectManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** @var ObjectFactory */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $objectFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** @var BaseObjectRepositoryFactory */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     private $objectRepositoryFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** @var EventManager */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     private $eventManager; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 | 1 |  |     public function __construct( | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         ObjectManager $objectManager, | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         ObjectFactory $objectFactory, | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         BaseObjectRepositoryFactory $objectRepositoryFactory, | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         EventManager $eventManager | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 36 | 1 |  |         $this->objectManager           = $objectManager; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 | 1 |  |         $this->objectFactory           = $objectFactory; | 
            
                                                                        
                            
            
                                    
            
            
                | 38 | 1 |  |         $this->objectRepositoryFactory = $objectRepositoryFactory; | 
            
                                                                        
                            
            
                                    
            
            
                | 39 | 1 |  |         $this->eventManager            = $eventManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 1 |  |     public function createRepository( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         DataSource $dataSource, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         string $repositoryClassName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         string $modelClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     ) : ObjectRepositoryInterface { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  |         $objectRepository = new $repositoryClassName( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 1 |  |             $this->objectManager, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 1 |  |             new DataSourceObjectDataRepository( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 1 |  |                 $this->objectManager, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 1 |  |                 $dataSource, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 1 |  |                 $modelClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 1 |  |             $this->objectFactory, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |             new BasicObjectHydrator($this->objectManager), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 1 |  |             $this->eventManager, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 1 |  |             $modelClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 1 |  |         $this->objectRepositoryFactory->addObjectRepository($modelClassName, $objectRepository); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 1 |  |         return $objectRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |  |