| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace ConferenceTools\Checkin\Cli\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Carnage\Cqrs\MessageBus\MessageBusInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Carnage\Cqrs\Persistence\ReadModel\RepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use chillerlan\QRCode\QRCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use chillerlan\QRCode\QROptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use ConferenceTools\Checkin\Domain\ReadModel\Delegate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use ConferenceTools\Tickets\Domain\Command\Ticket\CancelTicket as CancelTicketCommand; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Doctrine\Common\Collections\Criteria; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Symfony\Component\Console\Command\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Symfony\Component\Console\Input\InputArgument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Symfony\Component\Console\Input\InputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Symfony\Component\Console\Output\OutputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class GenerateQR extends Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @var RepositoryInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     public static function build(RepositoryInterface $repository) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $instance = new static(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $instance->repository = $repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         return $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     protected function configure() | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $this->setName('checkin:generate-qr') | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             ->setDescription('Generates a QR code for all delegates') | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             ->setDefinition([ | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |                 new InputArgument('outputDir', InputArgument::OPTIONAL, 'Output dir', '/tmp'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     protected function execute(InputInterface $input, OutputInterface $output) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $outputDir = $input->getArgument('outputDir'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         if (!is_dir($outputDir) && !(mkdir($outputDir, '0777', true) && is_dir($outputDir))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             throw new \Exception('Invalid output directory'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $count = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         //@TODO inject? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $renderer = new QRCode(new QROptions(['outputType' => QRCode::OUTPUT_IMAGE_PNG, 'imageBase64' => false]));; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $delegates = $this->repository->matching(Criteria::create()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         foreach ($delegates as $delegate) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             /** @var Delegate $delegate */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             $filename = $outputDir . '/' . $delegate->getPurchaseId() . '.' . $delegate->getTicketId() . '.png'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             file_put_contents($filename, $renderer->render($delegate->getTicketId())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             $count++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $output->writeln(sprintf('Generated %d QR codes', $count)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 63 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |  | 
            
                        
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