1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Setup\Task; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Adds Laravel customer test data. |
14
|
|
|
*/ |
15
|
|
|
class CustomerAddLaravelTestData extends \Aimeos\MW\Setup\Task\CustomerAddTestData |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Returns the list of task names which this task depends on |
19
|
|
|
* |
20
|
|
|
* @return string[] List of task names |
21
|
|
|
*/ |
22
|
|
|
public function getPreDependencies() |
23
|
|
|
{ |
24
|
|
|
return ['MShopSetLocale']; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns the list of task names which depends on this task. |
30
|
|
|
* |
31
|
|
|
* @return string[] List of task names |
32
|
|
|
*/ |
33
|
|
|
public function getPostDependencies() |
34
|
|
|
{ |
35
|
|
|
return ['CustomerAddTestData']; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Adds customer test data |
41
|
|
|
*/ |
42
|
|
|
public function migrate() |
43
|
|
|
{ |
44
|
|
|
\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $this->additional ); |
45
|
|
|
|
46
|
|
|
$this->msg( 'Adding Laravel customer test data', 0 ); |
47
|
|
|
|
48
|
|
|
$this->additional->setEditor( 'ai-laravel:lib/custom' ); |
|
|
|
|
49
|
|
|
$this->process( __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'customer.php' ); |
50
|
|
|
|
51
|
|
|
$this->status( 'done' ); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Adds the customer data |
57
|
|
|
* |
58
|
|
|
* @param string $path Path to data file |
59
|
|
|
* @throws \Aimeos\MShop\Exception |
60
|
|
|
*/ |
61
|
|
|
protected function process( $path ) |
62
|
|
|
{ |
63
|
|
|
if( ( $testdata = include( $path ) ) == false ) { |
64
|
|
|
throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer domain', $path ) ); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$manager = $this->getManager( 'customer' ); |
68
|
|
|
$listManager = $manager->getSubManager( 'lists' ); |
69
|
|
|
$groupManager = $manager->getSubManager( 'group' ); |
70
|
|
|
$addrManager = $manager->getSubManager( 'address' ); |
71
|
|
|
$propManager = $manager->getSubManager( 'property' ); |
72
|
|
|
|
73
|
|
|
$manager->begin(); |
74
|
|
|
|
75
|
|
|
$search = $manager->createSearch(); |
76
|
|
|
$search->setConditions( $search->compare( '=~', 'customer.code', 'test' ) ); |
77
|
|
|
$manager->deleteItems( array_keys( $manager->searchItems( $search ) ) ); |
78
|
|
|
|
79
|
|
|
$this->storeTypes( $testdata, ['customer/lists/type', 'customer/property/type'] ); |
80
|
|
|
$this->addGroupItems( $groupManager, $testdata ); |
81
|
|
|
|
82
|
|
|
$items = []; |
83
|
|
|
foreach( $testdata['customer'] as $entry ) |
84
|
|
|
{ |
85
|
|
|
$item = $manager->createItem()->fromArray( $entry, true ); |
86
|
|
|
$item = $this->addGroupData( $groupManager, $item, $entry ); |
87
|
|
|
$item = $this->addPropertyData( $propManager, $item, $entry ); |
88
|
|
|
$item = $this->addAddressData( $addrManager, $item, $entry ); |
89
|
|
|
$items[] = $this->addListData( $listManager, $item, $entry ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$manager->saveItems( $items ); |
93
|
|
|
$manager->commit(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Returns the manager for the current setup task |
99
|
|
|
* |
100
|
|
|
* @param string $domain Domain name of the manager |
101
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager object |
102
|
|
|
*/ |
103
|
|
|
protected function getManager( $domain ) |
104
|
|
|
{ |
105
|
|
|
if( $domain === 'customer' ) { |
106
|
|
|
return \Aimeos\MShop\Customer\Manager\Factory::create( $this->additional, 'Laravel' ); |
|
|
|
|
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return parent::getManager( $domain ); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Adds the customer group test data. |
115
|
|
|
* |
116
|
|
|
* @param array $testdata Associative list of key/list pairs |
117
|
|
|
* @param \Aimeos\MShop\Common\Manager\Iface $customerGroupManager Customer group manager |
118
|
|
|
* @throws \Aimeos\MW\Setup\Exception If a required ID is not available |
119
|
|
|
*/ |
120
|
|
|
protected function addCustomerGroupData( array $testdata, \Aimeos\MShop\Common\Manager\Iface $customerGroupManager ) |
121
|
|
|
{ |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.