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
|
|
|
|