1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||||||
5 | * @copyright Metaways Infosystems GmbH, 2014 |
||||||
6 | * @copyright Aimeos (aimeos.org), 2015-2018 |
||||||
7 | */ |
||||||
8 | |||||||
9 | |||||||
10 | namespace Aimeos\MW\Setup\Task; |
||||||
11 | |||||||
12 | |||||||
13 | /** |
||||||
14 | * Adds demo records to service tables. |
||||||
15 | */ |
||||||
16 | class DemoAddServiceData extends \Aimeos\MW\Setup\Task\MShopAddDataAbstract |
||||||
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 array( 'MShopAddTypeDataDefault' ); |
||||||
26 | } |
||||||
27 | |||||||
28 | |||||||
29 | /** |
||||||
30 | * Returns the list of task names which depends on this task. |
||||||
31 | * |
||||||
32 | * @return array List of task names |
||||||
33 | */ |
||||||
34 | public function getPostDependencies() |
||||||
35 | { |
||||||
36 | return []; |
||||||
37 | } |
||||||
38 | |||||||
39 | |||||||
40 | /** |
||||||
41 | * Insert service data. |
||||||
42 | */ |
||||||
43 | public function migrate() |
||||||
44 | { |
||||||
45 | $this->msg( 'Processing service demo data', 0 ); |
||||||
46 | |||||||
47 | $context = $this->getContext(); |
||||||
48 | $value = $context->getConfig()->get( 'setup/default/demo', '' ); |
||||||
49 | |||||||
50 | if( $value === '' ) |
||||||
51 | { |
||||||
52 | $this->status( 'OK' ); |
||||||
53 | return; |
||||||
54 | } |
||||||
55 | |||||||
56 | |||||||
57 | $manager = \Aimeos\MShop::create( $context, 'service' ); |
||||||
58 | |||||||
59 | $search = $manager->createSearch(); |
||||||
60 | $search->setConditions( $search->compare( '=~', 'service.code', 'demo-' ) ); |
||||||
61 | $services = $manager->searchItems( $search ); |
||||||
62 | |||||||
63 | foreach( $services as $item ) |
||||||
64 | { |
||||||
65 | $this->removeItems( $item->getId(), 'service/lists', 'service', 'media' ); |
||||||
66 | $this->removeItems( $item->getId(), 'service/lists', 'service', 'price' ); |
||||||
67 | $this->removeItems( $item->getId(), 'service/lists', 'service', 'text' ); |
||||||
68 | } |
||||||
69 | |||||||
70 | $manager->deleteItems( array_keys( $services ) ); |
||||||
71 | |||||||
72 | |||||||
73 | if( $value === '1' ) |
||||||
74 | { |
||||||
75 | $ds = DIRECTORY_SEPARATOR; |
||||||
76 | $path = __DIR__ . $ds . 'data' . $ds . 'demo-service.php'; |
||||||
77 | |||||||
78 | if( ( $data = include( $path ) ) == false ) { |
||||||
79 | throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for service domain', $path ) ); |
||||||
80 | } |
||||||
81 | |||||||
82 | foreach( $data as $entry ) |
||||||
83 | { |
||||||
84 | $item = $manager->createItem(); |
||||||
85 | $item->setType( $entry['type'] ); |
||||||
86 | $item->setCode( $entry['code'] ); |
||||||
87 | $item->setLabel( $entry['label'] ); |
||||||
88 | $item->setProvider( $entry['provider'] ); |
||||||
0 ignored issues
–
show
|
|||||||
89 | $item->setPosition( $entry['position'] ); |
||||||
90 | $item->setConfig( $entry['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...
|
|||||||
91 | $item->setStatus( $entry['status'] ); |
||||||
92 | |||||||
93 | $manager->saveItem( $item ); |
||||||
94 | |||||||
95 | if( isset( $entry['media'] ) ) { |
||||||
96 | $this->addMedia( $item->getId(), $entry['media'], 'service' ); |
||||||
97 | } |
||||||
98 | |||||||
99 | if( isset( $entry['price'] ) ) { |
||||||
100 | $this->addPrices( $item->getId(), $entry['price'], 'service' ); |
||||||
101 | } |
||||||
102 | |||||||
103 | if( isset( $entry['text'] ) ) { |
||||||
104 | $this->addTexts( $item->getId(), $entry['text'], 'service' ); |
||||||
105 | } |
||||||
106 | } |
||||||
107 | |||||||
108 | $this->status( 'added' ); |
||||||
109 | } |
||||||
110 | else |
||||||
111 | { |
||||||
112 | $this->status( 'removed' ); |
||||||
113 | } |
||||||
114 | } |
||||||
115 | } |
||||||
116 |
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.