Skip to content

Commit

Permalink
Update to new plugin system
Browse files Browse the repository at this point in the history
  • Loading branch information
janbuecker committed Feb 1, 2017
1 parent aa67de3 commit 235e631
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 117 deletions.
110 changes: 0 additions & 110 deletions Bootstrap.php

This file was deleted.

60 changes: 60 additions & 0 deletions SwagMediaS3.php
@@ -0,0 +1,60 @@
<?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.
*
*/

namespace SwagMediaS3;
require __DIR__. '/vendor/autoload.php';

use Shopware\Components\Plugin;
use League\Flysystem\AdapterInterface;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;

class SwagMediaS3 extends Plugin
{
public static function getSubscribedEvents()
{
return [
'Shopware_Collect_MediaAdapter_s3' => 'createS3Adapter'
];
}

/**
* Creates adapter instance
*
* @param \Enlight_Event_EventArgs $args
* @return AdapterInterface
*/
public function createS3Adapter(\Enlight_Event_EventArgs $args)
{
$defaultConfig = [
'key' => '',
'secret' => '',
'region' => '',
'version' => 'latest',
'bucket' => '',
'prefix' => '',
'endpoint' => null,
'metaOptions' => []
];

$config = array_merge($defaultConfig, $args->get('config'));

$client = S3Client::factory([
'credentials' => [
'key' => $config['key'],
'secret' => $config['secret'],
],
'region' => $config['region'],
'endpoint' => $config['endpoint'],
'version' => $config['version']
]);

return new AwsS3Adapter($client, $config['bucket'], $config['prefix'], $config['metaOptions']);
}
}
18 changes: 11 additions & 7 deletions build.sh
Expand Up @@ -4,11 +4,15 @@ lastTag=$(git tag | tail -n 1)
customTag=$1

if [ "$customTag" != "" ]; then lastTag=$customTag; fi
if [ "$lastTag" = "" ]; then lastTag="master"; fi

rm -rf Frontend/SwagMediaS3
mkdir -p Frontend/SwagMediaS3
git archive $lastTag | tar -x -C Frontend/SwagMediaS3
cd Frontend/SwagMediaS3
composer install -o
cd ../../
zip -r SwagMediaS3-${lastTag}.zip Frontend
rm -f SwagMediaS3-${lastTag}.zip
rm -rf SwagMediaS3
mkdir -p SwagMediaS3
git archive $lastTag | tar -x -C SwagMediaS3

cd SwagMediaS3
composer install --no-dev -n -o
cd ../
zip -r SwagMediaS3-${lastTag}.zip SwagMediaS3
rm -r SwagMediaS3
14 changes: 14 additions & 0 deletions plugin.xml
@@ -0,0 +1,14 @@
<?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">

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

<version>1.0.1</version>
<copyright>(c) by shopware AG</copyright>
<license>proprietary</license>
<author>shopware AG</author>
<compatibility minVersion="5.2.0" />

</plugin>

0 comments on commit 235e631

Please sign in to comment.