| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Stu\Component\Player\Register; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Override; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use RuntimeException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Stu\Component\Map\MapEnum; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Stu\Module\Message\Lib\PrivateMessageFolderTypeEnum; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Stu\Orm\Entity\UserInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Stu\Orm\Repository\LayerRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Stu\Orm\Repository\PrivateMessageFolderRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Stu\Orm\Repository\ResearchedRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Stu\Orm\Repository\UserLayerRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Stu\Orm\Repository\TutorialStepRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Stu\Orm\Repository\UserTutorialRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | final class PlayerDefaultsCreator implements PlayerDefaultsCreatorInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 | 1 |  |     public function __construct(private PrivateMessageFolderRepositoryInterface $privateMessageFolderRepository, private ResearchedRepositoryInterface $researchedRepository, private LayerRepositoryInterface $layerRepository, private UserLayerRepositoryInterface $userLayerRepository,  private TutorialStepRepositoryInterface $tutorialStepRepository,  private UserTutorialRepositoryInterface $userTutorialRepository) {} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 1 |  |     #[Override] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     public function createDefault(UserInterface $user): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 1 |  |         $this->createDefaultPmCategories($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 1 |  |         $this->createDefaultUserLayer($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 1 |  |         $this->createDefaultStartResearch($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 1 |  |         $this->createTutorialsForPlayer($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 1 |  |     private function createDefaultPmCategories(UserInterface $user): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 1 |  |         foreach (PrivateMessageFolderTypeEnum::cases() as $folderType) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 1 |  |             if (!$folderType->isDefault()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 1 |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 1 |  |             $cat = $this->privateMessageFolderRepository->prototype(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 1 |  |             $cat->setUser($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 1 |  |             $cat->setDescription(gettext($folderType->getDescription())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 1 |  |             $cat->setSpecial($folderType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 1 |  |             $cat->setSort($folderType->value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  |             $this->privateMessageFolderRepository->save($cat); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 1 |  |     private function createDefaultUserLayer(UserInterface $user): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |         $defaultLayer = $this->layerRepository->find(MapEnum::DEFAULT_LAYER); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |         if ($defaultLayer === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             throw new RuntimeException('the default layer should be available'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 1 |  |         $userLayer = $this->userLayerRepository->prototype(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 1 |  |         $userLayer->setLayer($defaultLayer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 1 |  |         $userLayer->setUser($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 1 |  |         $this->userLayerRepository->save($userLayer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 1 |  |         $user->getUserLayers()->set(MapEnum::DEFAULT_LAYER, $userLayer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 67 | 1 |  |     private function createDefaultStartResearch(UserInterface $user): void | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 69 | 1 |  |         $faction = $user->getFaction(); | 
            
                                                                        
                            
            
                                    
            
            
                | 70 | 1 |  |         $startResarch = $faction->getStartResearch(); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 | 1 |  |         if ($startResarch === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 75 | 1 |  |         $db = $this->researchedRepository->prototype(); | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 77 | 1 |  |         $db->setResearch($startResarch); | 
            
                                                                        
                            
            
                                    
            
            
                | 78 | 1 |  |         $db->setUser($user); | 
            
                                                                        
                            
            
                                    
            
            
                | 79 | 1 |  |         $db->setFinished(time()); | 
            
                                                                        
                            
            
                                    
            
            
                | 80 | 1 |  |         $db->setActive(0); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 | 1 |  |         $this->researchedRepository->save($db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 1 |  |     private function createTutorialsForPlayer(UserInterface $player): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 1 |  |         $firstSteps = $this->tutorialStepRepository->findAllFirstSteps(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  |         foreach ($firstSteps as $step) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |             $userTutorial = $this->userTutorialRepository->prototype(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 1 |  |             $userTutorial->setUser($player); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 1 |  |             $userTutorial->setTutorialStep($step); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 1 |  |             $userTutorial->setUserId($player->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 1 |  |             $userTutorial->setTutorialStepId($step->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 1 |  |             $this->userTutorialRepository->save($userTutorial); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 98 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 99 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths