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

SectionFixture::configureOptionsNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
c 0
b 0
f 0
rs 9.3142
cc 1
eloc 18
nc 1
nop 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 Patryk Drapik <[email protected]>
22
 */
23
final class SectionFixture extends AbstractFixture implements FixtureInterface
24
{
25
    /**
26
     * @var FixtureFactoryInterface
27
     */
28
    private $sectionFixtureFactory;
29
30
    /**
31
     * @param FixtureFactoryInterface $sectionFixtureFactory
32
     */
33
    public function __construct(FixtureFactoryInterface $sectionFixtureFactory)
34
    {
35
        $this->sectionFixtureFactory = $sectionFixtureFactory;
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function load(array $options): void
42
    {
43
        $this->sectionFixtureFactory->load($options['custom']);
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function getName(): string
50
    {
51
        return 'section';
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
                            ->arrayNode('translations')
66
                                ->prototype('array')
67
                                    ->children()
68
                                        ->scalarNode('name')->defaultNull()->end()
69
                                    ->end()
70
                                ->end()
71
                            ->end()
72
                        ->end()
73
                    ->end()
74
                ->end()
75
            ->end()
76
        ;
77
    }
78
}
79