Repository navigation
Expand file tree
/
Copy pathBootstrap.php
More file actions
106 lines (95 loc) · 2.49 KB
/
Copy pathBootstrap.php
File metadata and controls
106 lines (95 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/*
* (c) shopware AG <info@shopware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
require(__DIR__ . "/vendor/autoload.php");
use League\Flysystem\AdapterInterface;
use League\Flysystem\Sftp\SftpAdapter;
class Shopware_Plugins_Frontend_SwagMediaSftp_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
/**
* Returns the version of the plugin
*
* @return string
*/
public function getVersion()
{
return "1.0.0";
}
/**
* Returns a marketing friendly name of the plugin.
*
* @return string
*/
public function getLabel()
{
return "Media Adapter: SFTP";
}
/**
* Returns plugin info
*
* @return array
*/
public function getInfo()
{
return [
'version' => $this->getVersion(),
'label' => $this->getLabel(),
'supplier' => 'shopware AG',
'description' => 'SFTP-Erweiterung für die Media Adapter',
'support' => 'Shopware Forum',
'link' => 'http://www.shopware.com',
];
}
/**
* Template method which will be called when the plugin will be uninstalled.
*
* @return bool
*/
public function uninstall()
{
return true;
}
/**
* Template method which will be called when the plugin will be installed.
*
* @return bool
*/
public function install()
{
$this->subscribeEvent('Shopware_Collect_MediaAdapter_sftp', 'createSftpAdapter');
return true;
}
/**
* Creates adapter instance
*
* @param Enlight_Event_EventArgs $args
* @return AdapterInterface
*/
public function createSftpAdapter(Enlight_Event_EventArgs $args)
{
$defaultConfig = [
'host' => '',
'port' => 22,
'username' => '',
'password' => '',
'privateKey' => '',
'root' => '',
'timeout' => 10
];
$config = array_merge($defaultConfig, $args->get('config'));
return new SftpAdapter([
'host' => $config['host'],
'port' => $config['port'],
'username' => $config['username'],
'password' => $config['password'],
'privateKey' => $config['privateKey'],
'root' => $config['root'],
'timeout' => $config['timeout']
]);
}
}