Completed
Pull Request — master (#95)
by
unknown
01:20
created

BlockFixture   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 67
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A load() 0 4 1
A getName() 0 4 1
B configureOptionsNode() 0 32 1
1
<?php
2
3
/**
4
 * This file was created by the developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusCmsPlugin\Fixture;
14
15
use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface;
16
use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture;
17
use Sylius\Bundle\FixturesBundle\Fixture\FixtureInterface;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
20
/**
21
 * @author Mikołaj Król <[email protected]>
22
 */
23
final class BlockFixture extends AbstractFixture implements FixtureInterface
24
{
25
    /**
26
     * @var FixtureFactoryInterface
27
     */
28
    private $blockFixtureFactory;
29
30
    /**
31
     * @param FixtureFactoryInterface $blockFixtureFactory
32
     */
33
    public function __construct(FixtureFactoryInterface $blockFixtureFactory)
34
    {
35
        $this->blockFixtureFactory = $blockFixtureFactory;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function load(array $options): void
42
    {
43
        $this->blockFixtureFactory->load($options['custom']);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getName(): string
50
    {
51
        return 'block';
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
58
    {
59
        $optionsNode
60
            ->children()
61
                ->arrayNode('custom')
62
                    ->prototype('array')
63
                        ->children()
64
                            ->booleanNode('remove_existing')->defaultTrue()->end()
65
                            ->integerNode('number')->defaultNull()->end()
66
                            ->booleanNode('last_four_products')->defaultFalse()->end()
67
                            ->scalarNode('type')->isRequired()->cannotBeEmpty()->end()
68
                            ->booleanNode('enabled')->defaultTrue()->end()
69
                            ->integerNode('products')->defaultNull()->end()
70
                            ->arrayNode('sections')
71
                                ->prototype('scalar')->end()
72
                            ->end()
73
                            ->arrayNode('translations')
74
                                ->prototype('array')
75
                                    ->children()
76
                                        ->scalarNode('name')->defaultNull()->end()
77
                                        ->scalarNode('content')->defaultNull()->end()
78
                                        ->scalarNode('link')->defaultNull()->end()
79
                                        ->scalarNode('image_path')->defaultNull()->end()
80
                                    ->end()
81
                                ->end()
82
                            ->end()
83
                        ->end()
84
                    ->end()
85
                ->end()
86
            ->end()
87
        ;
88
    }
89
}
90