Skip to content

Commit

Permalink
Merge pull request #4 from philipgatzka/new-plugin-system-compatibility
Browse files Browse the repository at this point in the history
Migrate plugin to the structure used since Shopware v5.2
  • Loading branch information
mitelg authored Nov 14, 2017
2 parents d3d410c + fc9f896 commit 73b0b4a
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 106 deletions.
106 changes: 0 additions & 106 deletions Bootstrap.php

This file was deleted.

13 changes: 13 additions & 0 deletions Resources/services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="swag_media_sftp.subscriber.adapter_collection_subscriber" class="SwagMediaSftp\Subscriber\AdapterCollectionSubscriber">
<tag name="shopware.event_subscriber" />
</service>
</services>

</container>
52 changes: 52 additions & 0 deletions Subscriber/AdapterCollectionSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace SwagMediaSftp\Subscriber;

use Enlight\Event\SubscriberInterface;
use Enlight_Event_EventArgs;

use League\Flysystem\AdapterInterface;
use League\Flysystem\Sftp\SftpAdapter;

require __DIR__ . "/../vendor/autoload.php";

class AdapterCollectionSubscriber implements SubscriberInterface {

public static function getSubscribedEvents()
{
return [
'Shopware_Collect_MediaAdapter_sftp' => 'createSftpAdapter'
];
}

/**
* 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']
]);
}

}
14 changes: 14 additions & 0 deletions SwagMediaSftp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/*
* (c) shopware AG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/

namespace SwagMediaSftp;

use Shopware\Components\Plugin;

class SwagMediaSftp extends Plugin {}
18 changes: 18 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>

<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/5.2/engine/Shopware/Components/Plugin/schema/plugin.xsd">

<version>1.0.0</version>
<author>shopware AG</author>
<license>MIT</license>

<label lang="de">Media Adapter: SFTP</label>
<label lang="en">Media adapter: SFTP</label>

<description lang="de">SFTP-Erweiterung für die Media Adapter</description>
<description lang="en">SFTP-Extension for the Shopware media adapters</description>

<compatibility minVersion="5.2.0" />

</plugin>

0 comments on commit 73b0b4a

Please sign in to comment.