1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2019 Lars Roettig |
4
|
|
|
* |
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
* in the Software without restriction, including without limitation the rights |
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
* furnished to do so, subject to the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be included in all |
13
|
|
|
* copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
21
|
|
|
* SOFTWARE. |
22
|
|
|
*/ |
23
|
|
|
declare(strict_types=1); |
24
|
|
|
|
25
|
|
|
namespace LarsRoettig\GraphQLStorePickup\Setup\Patch\Data; |
26
|
|
|
|
27
|
|
|
use LarsRoettig\GraphQLStorePickup\Api\Data\StoreInterface; |
28
|
|
|
use LarsRoettig\GraphQLStorePickup\Api\Data\StoreInterfaceFactory; |
|
|
|
|
29
|
|
|
use LarsRoettig\GraphQLStorePickup\Api\StoreRepositoryInterface; |
30
|
|
|
use Magento\Framework\Api\DataObjectHelper; |
31
|
|
|
use Magento\Framework\Setup\ModuleDataSetupInterface; |
32
|
|
|
use Magento\Framework\Setup\Patch\DataPatchInterface; |
33
|
|
|
|
34
|
|
|
class InitializePickUpStores implements DataPatchInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var ModuleDataSetupInterface |
38
|
|
|
*/ |
39
|
|
|
private $moduleDataSetup; |
40
|
|
|
/** |
41
|
|
|
* @var StoreInterfaceFactory |
42
|
|
|
*/ |
43
|
|
|
private $storeInterfaceFactory; |
44
|
|
|
/** |
45
|
|
|
* @var StoreRepositoryInterface |
46
|
|
|
*/ |
47
|
|
|
private $storeRepository; |
48
|
|
|
/** |
49
|
|
|
* @var DataObjectHelper |
50
|
|
|
*/ |
51
|
|
|
private $dataObjectHelper; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* EnableSegmentation constructor. |
55
|
|
|
* |
56
|
|
|
* @param ModuleDataSetupInterface $moduleDataSetup |
57
|
|
|
*/ |
58
|
|
|
public function __construct( |
59
|
|
|
ModuleDataSetupInterface $moduleDataSetup, |
60
|
|
|
StoreInterfaceFactory $storeInterfaceFactory, |
61
|
|
|
StoreRepositoryInterface $storeRepository, |
62
|
|
|
DataObjectHelper $dataObjectHelper |
63
|
|
|
) { |
64
|
|
|
$this->moduleDataSetup = $moduleDataSetup; |
65
|
|
|
$this->storeInterfaceFactory = $storeInterfaceFactory; |
66
|
|
|
$this->storeRepository = $storeRepository; |
67
|
|
|
$this->dataObjectHelper = $dataObjectHelper; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
public static function getDependencies() |
74
|
|
|
{ |
75
|
|
|
return []; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
* @throws Exception |
81
|
|
|
* @throws Exception |
82
|
|
|
*/ |
83
|
|
|
public function apply() |
84
|
|
|
{ |
85
|
|
|
$this->moduleDataSetup->startSetup(); |
86
|
|
|
$maxStore = 50; |
87
|
|
|
|
88
|
|
|
$citys = ['Rosenheim', 'Kolbermoor', 'München', 'Erfurt', 'Berlin']; |
89
|
|
|
|
90
|
|
|
for ($i = 1; $i <= $maxStore; $i++) { |
91
|
|
|
|
92
|
|
|
$storeData = [ |
93
|
|
|
StoreInterface::NAME => 'Brick and Mortar ' . $i, |
94
|
|
|
StoreInterface::STREET => 'Test Street' . $i, |
95
|
|
|
StoreInterface::STREET_NUM => $i * random_int(1, 100), |
96
|
|
|
StoreInterface::CITY => $citys[random_int(0, 4)], |
97
|
|
|
StoreInterface::POSTCODE => $i * random_int(1000, 9999), |
98
|
|
|
StoreInterface::LATITUDE => random_int(4757549, 5041053) / 100000, |
99
|
|
|
StoreInterface::LONGITUDE => random_int(1157549, 1341053) / 100000, |
100
|
|
|
]; |
101
|
|
|
/** @var StoreInterface $store */ |
102
|
|
|
$store = $this->storeInterfaceFactory->create(); |
103
|
|
|
$this->dataObjectHelper->populateWithArray($store, $storeData, StoreInterface::class); |
104
|
|
|
$this->storeRepository->save($store); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
$this->moduleDataSetup->endSetup(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
*/ |
113
|
|
|
public function getAliases() |
114
|
|
|
{ |
115
|
|
|
return []; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
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