1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||||||
5 | * @copyright Metaways Infosystems GmbH, 2012 |
||||||
6 | * @copyright Aimeos (aimeos.org), 2015-2018 |
||||||
7 | */ |
||||||
8 | |||||||
9 | |||||||
10 | namespace Aimeos\MW\Setup\Task; |
||||||
11 | |||||||
12 | |||||||
13 | /** |
||||||
14 | * Adds service test data. |
||||||
15 | */ |
||||||
16 | class ServiceAddTestData extends \Aimeos\MW\Setup\Task\Base |
||||||
17 | { |
||||||
18 | /** |
||||||
19 | * Returns the list of task names which this task depends on. |
||||||
20 | * |
||||||
21 | * @return string[] List of task names |
||||||
22 | */ |
||||||
23 | public function getPreDependencies() |
||||||
24 | { |
||||||
25 | return ['MShopSetLocale']; |
||||||
26 | } |
||||||
27 | |||||||
28 | |||||||
29 | /** |
||||||
30 | * Adds service test data. |
||||||
31 | */ |
||||||
32 | public function migrate() |
||||||
33 | { |
||||||
34 | \Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $this->additional ); |
||||||
35 | |||||||
36 | $this->msg( 'Adding service test data', 0 ); |
||||||
37 | $this->additional->setEditor( 'core:lib/mshoplib' ); |
||||||
38 | |||||||
39 | $ds = DIRECTORY_SEPARATOR; |
||||||
40 | $path = __DIR__ . $ds . 'data' . $ds . 'service.php'; |
||||||
41 | |||||||
42 | if( ( $testdata = include( $path ) ) == false ) { |
||||||
43 | throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for service domain', $path ) ); |
||||||
44 | } |
||||||
45 | |||||||
46 | $this->addServiceData( $testdata ); |
||||||
47 | |||||||
48 | $this->status( 'done' ); |
||||||
49 | } |
||||||
50 | |||||||
51 | |||||||
52 | /** |
||||||
53 | * Adds the service test data. |
||||||
54 | * |
||||||
55 | * @param array $testdata Associative list of key/list pairs |
||||||
56 | * @throws \Aimeos\MW\Setup\Exception If a required ID is not available |
||||||
57 | */ |
||||||
58 | private function addServiceData( array $testdata ) |
||||||
59 | { |
||||||
60 | $serviceManager = \Aimeos\MShop\Service\Manager\Factory::create( $this->additional, 'Standard' ); |
||||||
61 | $serviceTypeManager = $serviceManager->getSubManager( 'type', 'Standard' ); |
||||||
62 | |||||||
63 | $type = $serviceTypeManager->createItem(); |
||||||
64 | |||||||
65 | $serviceManager->begin(); |
||||||
66 | |||||||
67 | foreach( $testdata['service/type'] as $key => $dataset ) |
||||||
68 | { |
||||||
69 | $type->setId( null ); |
||||||
70 | $type->setCode( $dataset['code'] ); |
||||||
71 | $type->setDomain( $dataset['domain'] ); |
||||||
72 | $type->setLabel( $dataset['label'] ); |
||||||
73 | $type->setStatus( $dataset['status'] ); |
||||||
74 | |||||||
75 | $serviceTypeManager->saveItem( $type ); |
||||||
76 | } |
||||||
77 | |||||||
78 | $parent = $serviceManager->createItem(); |
||||||
79 | |||||||
80 | foreach( $testdata['service'] as $key => $dataset ) |
||||||
81 | { |
||||||
82 | $parent->setId( null ); |
||||||
83 | $parent->setType( $dataset['type'] ); |
||||||
84 | $parent->setPosition( $dataset['pos'] ); |
||||||
85 | $parent->setCode( $dataset['code'] ); |
||||||
86 | $parent->setLabel( $dataset['label'] ); |
||||||
87 | $parent->setProvider( $dataset['provider'] ); |
||||||
0 ignored issues
–
show
|
|||||||
88 | $parent->setConfig( $dataset['config'] ); |
||||||
0 ignored issues
–
show
The method
setConfig() does not exist on Aimeos\MShop\Attribute\Item\Iface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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.
Loading history...
|
|||||||
89 | $parent->setStatus( $dataset['status'] ); |
||||||
90 | |||||||
91 | $serviceManager->saveItem( $parent, false ); |
||||||
92 | } |
||||||
93 | |||||||
94 | $serviceManager->commit(); |
||||||
95 | } |
||||||
96 | } |
||||||
97 |
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.