| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file was created by developers working at BitBag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Do you need more information about us and what we do? Visit our https://bitbag.io website! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace BitBag\SyliusCmsPlugin\Fixture; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Symfony\Component\Config\Definition\Builder\NodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | final class BlockFixture extends AbstractFixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** @var FixtureFactoryInterface */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $blockFixtureFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     public function __construct(FixtureFactoryInterface $blockFixtureFactory) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->blockFixtureFactory = $blockFixtureFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     public function load(array $options): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->blockFixtureFactory->load($options['custom']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     public function getName(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         return 'block'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $optionsNode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |                 ->arrayNode('custom') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                     ->arrayPrototype() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                         ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                             ->booleanNode('remove_existing')->defaultTrue()->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                             ->integerNode('number')->defaultNull()->end() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                             ->booleanNode('last_four_products')->defaultFalse()->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                             ->booleanNode('enabled')->defaultTrue()->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                             ->integerNode('products')->defaultNull()->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                             ->append($this->createArrayOfScalars('productCodes')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                             ->append($this->createArrayOfScalars('taxons')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                             ->append($this->createArrayOfScalars('sections')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                             ->append($this->createArrayOfScalars('channels')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                             ->append($this->translationsConfiguration()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                         ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                     ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     private function createArrayOfScalars(string $name): NodeDefinition | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         $nodeDefinition = new ScalarNodeDefinition($name); | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         $nodeDefinition->defaultNull()->end(); | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |         return $nodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     private function translationsConfiguration(): NodeDefinition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $translationsNodeDefinition = new ArrayNodeDefinition('translations'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $translationsNodeDefinition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             ->arrayPrototype() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                     ->scalarNode('name')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                     ->scalarNode('content')->end() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                     ->scalarNode('link')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                     ->scalarNode('image_path')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                 ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         return $translationsNodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 87 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 88 |  |  |  |