1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\MW\Setup\Task; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Adds default records plugin to table. |
15
|
|
|
*/ |
16
|
|
|
class MShopAddPluginData 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 array( 'TablesCreateMShop' ); |
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
|
|
|
* Executes the task for MySQL databases. |
42
|
|
|
*/ |
43
|
|
|
public function migrate() |
44
|
|
|
{ |
45
|
|
|
// executed by tasks in sub-directories for specific sites |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Adds locale data. |
51
|
|
|
*/ |
52
|
|
|
protected function process() |
53
|
|
|
{ |
54
|
|
|
\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $this->additional ); |
55
|
|
|
|
56
|
|
|
$this->msg( 'Adding default plugin data', 0 ); |
57
|
|
|
$this->status( '' ); |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
$ds = DIRECTORY_SEPARATOR; |
61
|
|
|
$pluginManager = \Aimeos\MShop\Plugin\Manager\Factory::create( $this->additional, 'Standard' ); |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
$filename = __DIR__ . $ds . 'default' . $ds . 'data' . $ds . 'plugin.php'; |
65
|
|
|
|
66
|
|
|
if( ( $data = include( $filename ) ) == false ) { |
67
|
|
|
throw new \Aimeos\MW\Setup\Exception( sprintf( 'No data file "%1$s" found', $filename ) ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if( isset( $data['plugin'] ) ) { |
71
|
|
|
$this->addPluginData( $pluginManager, $data['plugin'] ); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Adds plugin data. |
78
|
|
|
* |
79
|
|
|
* @param \Aimeos\MShop\Common\Manager\Iface $pluginManager Plugin manager |
80
|
|
|
* @param array $data Associative list of plugin data |
81
|
|
|
*/ |
82
|
|
|
protected function addPluginData( \Aimeos\MShop\Common\Manager\Iface $pluginManager, array $data ) |
83
|
|
|
{ |
84
|
|
|
$this->msg( 'Adding data for MShop plugins', 1 ); |
85
|
|
|
|
86
|
|
|
$types = []; |
87
|
|
|
$manager = $pluginManager->getSubManager( 'type' ); |
88
|
|
|
|
89
|
|
|
foreach( $manager->searchItems( $manager->createSearch() ) as $item ) { |
90
|
|
|
$types['plugin/' . $item->getCode()] = $item; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$num = $total = 0; |
94
|
|
|
$item = $pluginManager->createItem(); |
95
|
|
|
|
96
|
|
|
foreach( $data as $key => $dataset ) |
97
|
|
|
{ |
98
|
|
|
$total++; |
99
|
|
|
|
100
|
|
|
$item->setId( null ); |
101
|
|
|
$item->setType( $dataset['type'] ); |
102
|
|
|
$item->setProvider( $dataset['provider'] ); |
|
|
|
|
103
|
|
|
$item->setLabel( $dataset['label'] ); |
104
|
|
|
$item->setConfig( $dataset['config'] ); |
|
|
|
|
105
|
|
|
$item->setStatus( $dataset['status'] ); |
106
|
|
|
|
107
|
|
|
if( isset( $dataset['position'] ) ) { |
108
|
|
|
$item->setPosition( $dataset['position'] ); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
try { |
112
|
|
|
$pluginManager->saveItem( $item ); |
113
|
|
|
$num++; |
114
|
|
|
} catch( \Exception $e ) {; } // if plugin configuration was already available |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
$this->status( $num > 0 ? $num . '/' . $total : 'OK' ); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
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.