Commit 0707f471 authored by Hendrik Rombach's avatar Hendrik Rombach
Browse files

Merge branch 'release/1.0.0-001'

parents 58183025 b9493ce3
# Created by .ignore support plugin (hsz.mobi)
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/gradle.xml
.idea/**/libraries
.idea/**/mongoSettings.xml
*.iws
/out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
/vendor
\ No newline at end of file
<?php
/**
* @copyright Copyright (c) 2017, Net Inventors GmbH
* @category Shopware
* @author hrombach
*/
namespace NetiGoogleSdk\Exceptions;
class GoogleSdkFactoryException extends \Exception
{
}
\ No newline at end of file
MIT License
Copyright (c) 2016 Net Inventors GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
NOTE: For License information of included libraries, please refer to the text files
included in each library. - This only applies to the packaged version of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
<?php
/**
* @copyright Copyright (c) 2017, Net Inventors GmbH
* @category Shopware
* @author hrombach
*/
namespace NetiGoogleSdk;
use Shopware\Components\Plugin;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class NetiGoogleSdk extends Plugin
{
const MINIMUM_SDK_VERSION = "2.0.0";
const BREAKING_SDK_VERSION = "2.1.0";
public function build(ContainerBuilder $container)
{
$container->setParameter('neti_google_sdk.vendor_dir', $this->getPath() . '/vendor');
parent::build($container);
}
}
\ No newline at end of file
<?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>
<!-- Custom Services -->
<service class="NetiGoogleSdk\Service\GoogleSdkFactory" id="neti_google_sdk.service.sdk_factory">
<argument>%neti_google_sdk.vendor_dir%</argument>
</service>
</services>
</container>
\ No newline at end of file
<?php
/**
* @copyright Copyright (c) 2017, Net Inventors GmbH
* @category Shopware
* @author hrombach
*/
namespace NetiGoogleSdk\Service;
use NetiGoogleSdk\Exceptions\GoogleSdkFactoryException;
use NetiGoogleSdk\NetiGoogleSdk;
class GoogleSdkFactory
{
/**
* @var \Google_Client[]
*/
private static $clients;
/**
* @var string
*/
private $vendorPath;
/**
* SdkFactory constructor.
*
* @param string $vendorPath
*/
public function __construct($vendorPath)
{
$this->vendorPath = $vendorPath;
}
/**
* @param string $applicationName
* @param string $developerKey
* @param array $config
* @param string|null $cacheKey
*
* @return \Google_Client
* @throws \NetiGoogleSdk\Exceptions\GoogleSdkFactoryException
*/
public function getClient($applicationName, $developerKey, array $config = [], $cacheKey = null)
{
$this->loadLibrary();
$config += [
'application_name' => $applicationName,
'developer_key' => $developerKey,
];
$cacheKey = (null === $cacheKey) ? $developerKey : $cacheKey;
$client = self::$clients[$cacheKey];
if (!$client instanceof \Google_Client) {
$client = self::$clients[$cacheKey] = new \Google_Client($config);
}
return $client;
}
/**
* @return bool
* @throws GoogleSdkFactoryException
*/
private function loadLibrary()
{
if (!class_exists('Google_Client')) {
require_once $this->vendorPath . '/autoload.php';
} else {
if (!$this->assertCompatible()) {
throw new GoogleSdkFactoryException(
sprintf(
'Loaded Google Client version "%s" is incompatible with required version "%s".',
\Google_Client::LIBVER, NetiGoogleSdk::MINIMUM_SDK_VERSION
)
);
}
}
return true;
}
/**
* @return bool
*/
private function assertCompatible()
{
return (
version_compare(\Google_Client::LIBVER, NetiGoogleSdk::MINIMUM_SDK_VERSION, '>=') &&
version_compare(\Google_Client::LIBVER, NetiGoogleSdk::BREAKING_SDK_VERSION, '<=')
);
}
}
\ No newline at end of file
#!/bin/bash
WORKING_DIR=$(dirname $0)
PLUGIN_NAME=$(basename ${WORKING_DIR})
VERSION=$(php -r "echo preg_replace('/.*<version>([^<]+)<\/version>.*/ims', '\\1', file_get_contents('${WORKING_DIR}/plugin.xml'), 1);")
TEMP_DIR='/tmp/ShopwarePlugins/'${PLUGIN_NAME}
CURRENT_DIR=$(pwd)
EXCLUDES="sftp-config.json nbproject .idea composer.json composer.lock vendor/autoload.php vendor/composer"
# Remove existing package file
if [ -f "${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip" ]; then
rm "${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip"
fi
# Create temporary build folder
mkdir -p ${TEMP_DIR}
# Copy all files from source folder to temporary folder
cp -Rp ${WORKING_DIR}/* ${TEMP_DIR}
# Remove build.sh from temporary folder
rm "${TEMP_DIR}/build.sh"
# Remove excludes from temporary folder
for i in ${EXCLUDES}; do
if [ -e "${TEMP_DIR}/$i" ]; then
rm -R "${TEMP_DIR}/$i"
fi
done
# Step into the temporary build folder
cd ${TEMP_DIR}
# Move one level up in folder structure
cd ..
# Zip temporary folder contents to package file in plugin folder
zip -qr "${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip" $(basename ${TEMP_DIR})
# Step back into the current plugin folder
cd ${CURRENT_DIR}
echo "Package wurde erstellt unter ${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip"
# Remove temporary build folder
rm -R $(dirname ${TEMP_DIR})
{
"name": "netinventors/google-sdk",
"description": "Wrapper plugin for Google API Client PHP Library",
"type": "project",
"require": {
"google/apiclient": "^2.0"
},
"require-dev": {
"shopware/shopware": "^5.2.6"
},
"config": {
"prepend-autoloader": false
},
"license": "MIT License",
"authors": [
{
"name": "Net Inventors GmbH",
"email": "info@netinventors.de"
},
{
"name": "Hendrik Rombach",
"email": "hr@netinventors.de"
}
],
"minimum-stability": "stable"
}
This diff is collapsed.
plugin.png

1.12 KB

<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../engine/Shopware/Components/Plugin/schema/plugin.xsd">
<label lang="de">Google SDK</label>
<label lang="en">Google SDK</label>
<version>1.0.0</version>
<link>http://www.shopinventors.de</link>
<author>Net Inventors GmbH</author>
<compatibility minVersion="5.2.6"/>
<changelog version="1.0.0">
<changes lang="de">Erstes Release</changes>
<changes lang="en">Initial release</changes>
</changelog>
</plugin>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment