Version Notes
Actonlytics Magento plugin
Download this release
Release Info
Developer | actonlytics |
Extension | Actonlytics_1_0 |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Actonlytics/Plugin/controllers/IndexController.php +28 -0
- app/code/community/Actonlytics/Plugin/etc/build.php +1 -0
- app/code/community/Actonlytics/Plugin/etc/config.xml +22 -0
- app/code/community/Actonlytics/Plugin/etc/system.xml +9 -0
- app/code/community/Actonlytics/Signup/Block/Button.php +18 -0
- app/code/community/Actonlytics/Signup/Block/Content.php +41 -0
- app/code/community/Actonlytics/Signup/Helper/Data.php +55 -0
- app/code/community/Actonlytics/Signup/controllers/Adminhtml/ActonlyticssignupController.php +25 -0
- app/code/community/Actonlytics/Signup/etc/adminhtml.xml +16 -0
- app/code/community/Actonlytics/Signup/etc/config.xml +59 -0
- app/code/community/Actonlytics/Signup/etc/system.xml +49 -0
- app/etc/modules/Actonlytics_Plugin.xml +9 -0
- app/etc/modules/Actonlytics_Signup.xml +12 -0
- lib/ac/autoload.php +7 -0
- lib/ac/composer/ClassLoader.php +413 -0
- lib/ac/composer/LICENSE +21 -0
- lib/ac/composer/autoload_classmap.php +50 -0
- lib/ac/composer/autoload_namespaces.php +10 -0
- lib/ac/composer/autoload_psr4.php +10 -0
- lib/ac/composer/autoload_real.php +52 -0
- lib/ac/composer/autoload_static.php +95 -0
- lib/ac/itembase/m1-ext-data/src/Itembase/PluginExtension/Data/Extension.php +238 -0
- lib/ac/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Extension.php +35 -0
- lib/ac/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Multishop.php +80 -0
- lib/ac/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Extension.php +33 -0
- lib/ac/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Platform.php +31 -0
- lib/ac/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Extension.php +33 -0
- lib/ac/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Storage.php +134 -0
- lib/ac/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/Extension.php +105 -0
- lib/ac/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/FetcherInterface.php +101 -0
- lib/ac/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Extension.php +84 -0
- lib/ac/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Filesystem.php +254 -0
- lib/ac/itembase/psdk2-ext-signup/src/Itembase/PsdkExtension/Signup/Extension.php +233 -0
- lib/ac/itembase/psdk2-ext-sysinfo/src/Itembase/PsdkExtension/SysInfo/Extension.php +183 -0
- lib/ac/itembase/psdk2/LICENSE.txt +201 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Container/ContainerAwareInterface.php +24 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Container/ServiceContainer.php +149 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Core.php +309 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/ExceptionHandler.php +81 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/Logger.php +87 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/OAuthClient.php +164 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/PingHandler.php +66 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Event/EventAwareInterface.php +24 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Event/EventDispatcher.php +86 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Event/EventListenerInterface.php +24 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionInterface.php +25 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionsLoader.php +103 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/HttpClient.php +145 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/HttpHandler.php +226 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/Request.php +153 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/RequestAwareInterface.php +60 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/Response.php +142 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/ResponseAwareInterface.php +54 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/Frontend/ControllerInterface.php +25 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/MultishopAbstract.php +120 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/Shop.php +68 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/PlatformInterface.php +48 -0
- lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/StorageInterface.php +113 -0
- package.xml +18 -0
app/code/community/Actonlytics/Plugin/controllers/IndexController.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Actonlytics_Plugin_IndexController
|
5 |
+
*/
|
6 |
+
class Actonlytics_Plugin_IndexController extends Mage_Core_Controller_Front_Action
|
7 |
+
{
|
8 |
+
public function apiAction()
|
9 |
+
{
|
10 |
+
include_once Mage::getBaseDir('code') . '/community/Actonlytics/Plugin/etc/build.php';
|
11 |
+
include_once Mage::getBaseDir('lib') . '/ac/autoload.php';
|
12 |
+
|
13 |
+
$core = new Itembase\Psdk\Core();
|
14 |
+
$core->init();
|
15 |
+
|
16 |
+
/** @var \Itembase\Psdk\Platform\StorageInterface $storage */
|
17 |
+
$storage = $core->getServiceContainer()->getService(\Itembase\Psdk\Core::SERVICE_STORAGE);
|
18 |
+
|
19 |
+
$storage->setKeyMapping(array(
|
20 |
+
\Itembase\Psdk\Core\OAuthClient::STORAGE_API_KEY => "actonlytics/signup/" . \Itembase\Psdk\Core\OAuthClient::STORAGE_API_KEY,
|
21 |
+
\Itembase\Psdk\Core\OAuthClient::STORAGE_API_SECRET => "actonlytics/signup/" . \Itembase\Psdk\Core\OAuthClient::STORAGE_API_SECRET,
|
22 |
+
));
|
23 |
+
|
24 |
+
$core->run()->done();
|
25 |
+
|
26 |
+
exit;
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Actonlytics/Plugin/etc/build.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php define('ITEMBASE_PLUGIN_BUILD', 'b7124013-74de-4825-843c-dc60987348e5');
|
app/code/community/Actonlytics/Plugin/etc/config.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<frontend>
|
4 |
+
<routers>
|
5 |
+
<plugin>
|
6 |
+
<use>standard</use>
|
7 |
+
<args>
|
8 |
+
<module>Actonlytics_Plugin</module>
|
9 |
+
<frontName>actonlytics</frontName>
|
10 |
+
</args>
|
11 |
+
</plugin>
|
12 |
+
</routers>
|
13 |
+
</frontend>
|
14 |
+
|
15 |
+
<global>
|
16 |
+
<helpers>
|
17 |
+
<plugin>
|
18 |
+
<class>Mage_Core_Helper</class>
|
19 |
+
</plugin>
|
20 |
+
</helpers>
|
21 |
+
</global>
|
22 |
+
</config>
|
app/code/community/Actonlytics/Plugin/etc/system.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<actonlytics>
|
5 |
+
<label>actonlytics</label>
|
6 |
+
<sort_order>500</sort_order>
|
7 |
+
</actonlytics>
|
8 |
+
</tabs>
|
9 |
+
</config>
|
app/code/community/Actonlytics/Signup/Block/Button.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Actonlytics_Signup_Block_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
3 |
+
{
|
4 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
5 |
+
{
|
6 |
+
$this->setElement($element);
|
7 |
+
$url = $this->getUrl('adminhtml/actonlyticssignup/index');
|
8 |
+
|
9 |
+
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
10 |
+
->setType('button')
|
11 |
+
->setClass('scalable')
|
12 |
+
->setLabel('Signup')
|
13 |
+
->setOnClick("setLocation('$url')")
|
14 |
+
->toHtml();
|
15 |
+
|
16 |
+
return $html;
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Actonlytics/Signup/Block/Content.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Actonlytics_Signup_Block_Content extends Mage_Adminhtml_Block_System_Config_Form
|
3 |
+
{
|
4 |
+
const ITEMBASE_SIGNUP_SERVICE = "signup";
|
5 |
+
|
6 |
+
protected function _toHtml()
|
7 |
+
{
|
8 |
+
// including build information
|
9 |
+
include_once Mage::getBaseDir('code') . '/community/Actonlytics/Plugin/etc/build.php';
|
10 |
+
include_once Mage::getBaseDir('lib') . '/ac/autoload.php';
|
11 |
+
|
12 |
+
$core = new Itembase\Psdk\Core();
|
13 |
+
$core->init();
|
14 |
+
|
15 |
+
/** @var \Itembase\Psdk\Platform\StorageInterface $storage */
|
16 |
+
$storage = $core->getServiceContainer()->getService(\Itembase\Psdk\Core::SERVICE_STORAGE);
|
17 |
+
|
18 |
+
$storage->setKeyMapping(array(
|
19 |
+
\Itembase\Psdk\Core\OAuthClient::STORAGE_API_KEY => "actonlytics/signup/" . \Itembase\Psdk\Core\OAuthClient::STORAGE_API_KEY,
|
20 |
+
\Itembase\Psdk\Core\OAuthClient::STORAGE_API_SECRET => "actonlytics/signup/" . \Itembase\Psdk\Core\OAuthClient::STORAGE_API_SECRET,
|
21 |
+
));
|
22 |
+
|
23 |
+
$core->run();
|
24 |
+
|
25 |
+
$content = "";
|
26 |
+
|
27 |
+
if ($core->getServiceContainer()->hasService(self::ITEMBASE_SIGNUP_SERVICE)) {
|
28 |
+
$registration = $core->getServiceContainer()->getService(self::ITEMBASE_SIGNUP_SERVICE);
|
29 |
+
$content = $registration->htmlSignupPage(
|
30 |
+
Mage::helper("adminhtml")->getUrl("adminhtml/actonlyticssignup/finish"),
|
31 |
+
substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2)
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
$core->done();
|
36 |
+
|
37 |
+
$content .= parent::_toHtml();
|
38 |
+
|
39 |
+
return $content;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Actonlytics/Signup/Helper/Data.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Actonlytics_Signup_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
public function registerCheck()
|
6 |
+
{
|
7 |
+
// including build information
|
8 |
+
include_once Mage::getBaseDir('code') . '/community/Actonlytics/Plugin/etc/build.php';
|
9 |
+
include_once Mage::getBaseDir('lib') . '/ac/autoload.php';
|
10 |
+
|
11 |
+
$core = new Itembase\Psdk\Core();
|
12 |
+
$core->init();
|
13 |
+
|
14 |
+
/** @var \Itembase\Psdk\Platform\StorageInterface $storage */
|
15 |
+
$storage = $core->getServiceContainer()->getService(\Itembase\Psdk\Core::SERVICE_STORAGE);
|
16 |
+
|
17 |
+
$storage->setKeyMapping(array(
|
18 |
+
\Itembase\Psdk\Core\OAuthClient::STORAGE_API_KEY => "actonlytics/signup/" . \Itembase\Psdk\Core\OAuthClient::STORAGE_API_KEY,
|
19 |
+
\Itembase\Psdk\Core\OAuthClient::STORAGE_API_SECRET => "actonlytics/signup/" . \Itembase\Psdk\Core\OAuthClient::STORAGE_API_SECRET,
|
20 |
+
));
|
21 |
+
|
22 |
+
$core->run();
|
23 |
+
|
24 |
+
/** @var \Itembase\Psdk\Platform\MultiShop\MultishopAbstract $ms */
|
25 |
+
$ms = $core->getServiceContainer()->getService(\Itembase\Psdk\Core::SERVICE_MULTISHOP);
|
26 |
+
$shops = $ms->getList();
|
27 |
+
|
28 |
+
/** @var \Itembase\Psdk\Platform\MultiShop\Shop $shop */
|
29 |
+
foreach ($shops as $shop) {
|
30 |
+
if ($shop->registered) {
|
31 |
+
return true;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$content = sprintf(
|
36 |
+
'<div class="entry-edit">
|
37 |
+
<div class="section-config">
|
38 |
+
<div class="entry-edit-head">
|
39 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Activation is required</h4>
|
40 |
+
</div>
|
41 |
+
<div id="base_fieldset" class="fieldset ">
|
42 |
+
<div class="notification-global" style="font-size: larger;">
|
43 |
+
To use that service please <a href="%s">signup</a> your shop with actonlytics!
|
44 |
+
</div>
|
45 |
+
</div>
|
46 |
+
</div>
|
47 |
+
</div>',
|
48 |
+
Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/actonlytics")
|
49 |
+
);
|
50 |
+
|
51 |
+
$core->done();
|
52 |
+
|
53 |
+
return $content;
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Actonlytics/Signup/controllers/Adminhtml/ActonlyticssignupController.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Actonlytics_Signup_Adminhtml_ItembasesignupController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Display success page if everything is good
|
7 |
+
*/
|
8 |
+
public function finishAction()
|
9 |
+
{
|
10 |
+
$success = $this->getRequest()->getParam('success');
|
11 |
+
$error = $this->getRequest()->getParam('error');
|
12 |
+
|
13 |
+
$session = Mage::getSingleton('adminhtml/session');
|
14 |
+
|
15 |
+
if (!empty($success)) {
|
16 |
+
$session->addSuccess($success);
|
17 |
+
}
|
18 |
+
|
19 |
+
if (!empty($error)) {
|
20 |
+
$session->addError($error);
|
21 |
+
}
|
22 |
+
|
23 |
+
$this->_redirect("adminhtml/system_config/edit/section/actonlytics");
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Actonlytics/Signup/etc/adminhtml.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<actonlyticssignup>
|
8 |
+
<children>
|
9 |
+
<index /><finish />
|
10 |
+
</children>
|
11 |
+
</actonlyticssignup>
|
12 |
+
</children>
|
13 |
+
</admin>
|
14 |
+
</resources>
|
15 |
+
</acl>
|
16 |
+
</config>
|
app/code/community/Actonlytics/Signup/etc/config.xml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Actonlytics_Signup>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Actonlytics_Signup>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<blocks>
|
11 |
+
<actonlytics_signup>
|
12 |
+
<class>Actonlytics_Signup_Block</class>
|
13 |
+
</actonlytics_signup>
|
14 |
+
</blocks>
|
15 |
+
|
16 |
+
<helpers>
|
17 |
+
<actonlytics_signup>
|
18 |
+
<class>Actonlytics_Signup_Helper</class>
|
19 |
+
</actonlytics_signup>
|
20 |
+
</helpers>
|
21 |
+
</global>
|
22 |
+
|
23 |
+
<adminhtml>
|
24 |
+
<acl>
|
25 |
+
<resources>
|
26 |
+
<all>
|
27 |
+
<title>Allow actonlytics signup</title>
|
28 |
+
</all>
|
29 |
+
<admin>
|
30 |
+
<children>
|
31 |
+
<system>
|
32 |
+
<children>
|
33 |
+
<config>
|
34 |
+
<children>
|
35 |
+
<actonlytics>
|
36 |
+
<title>actonlytics Signup</title>
|
37 |
+
</actonlytics>
|
38 |
+
</children>
|
39 |
+
</config>
|
40 |
+
</children>
|
41 |
+
</system>
|
42 |
+
</children>
|
43 |
+
</admin>
|
44 |
+
</resources>
|
45 |
+
</acl>
|
46 |
+
</adminhtml>
|
47 |
+
|
48 |
+
<admin>
|
49 |
+
<routers>
|
50 |
+
<adminhtml>
|
51 |
+
<args>
|
52 |
+
<modules>
|
53 |
+
<signup_ctrl after="Mage_Adminhtml">Actonlytics_Signup_Adminhtml</signup_ctrl>
|
54 |
+
</modules>
|
55 |
+
</args>
|
56 |
+
</adminhtml>
|
57 |
+
</routers>
|
58 |
+
</admin>
|
59 |
+
</config>
|
app/code/community/Actonlytics/Signup/etc/system.xml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<actonlytics>
|
5 |
+
<label>Connect</label>
|
6 |
+
<tab>actonlytics</tab>
|
7 |
+
<sort_order>60</sort_order>
|
8 |
+
<show_in_default>1</show_in_default>
|
9 |
+
<show_in_website>1</show_in_website>
|
10 |
+
<show_in_store>1</show_in_store>
|
11 |
+
<frontend_model>actonlytics_signup/content</frontend_model>
|
12 |
+
<groups>
|
13 |
+
<signup translate="label">
|
14 |
+
<label>Credentials</label>
|
15 |
+
<sort_order>1</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<fields>
|
20 |
+
<api_key translate="label">
|
21 |
+
<label>API key</label>
|
22 |
+
<sort_order>1</sort_order>
|
23 |
+
<show_in_default>0</show_in_default>
|
24 |
+
<show_in_website>0</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<frontend_input>text</frontend_input>
|
27 |
+
</api_key>
|
28 |
+
<api_secret translate="label">
|
29 |
+
<label>Secret key</label>
|
30 |
+
<sort_order>2</sort_order>
|
31 |
+
<show_in_default>0</show_in_default>
|
32 |
+
<show_in_website>0</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
<frontend_input>text</frontend_input>
|
35 |
+
</api_secret>
|
36 |
+
<no_shop translate="label">
|
37 |
+
<label>Please select your shop from Configuration Scope before changing configuration.</label>
|
38 |
+
<sort_order>0</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>0</show_in_store>
|
42 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
43 |
+
</no_shop>
|
44 |
+
</fields>
|
45 |
+
</signup>
|
46 |
+
</groups>
|
47 |
+
</actonlytics>
|
48 |
+
</sections>
|
49 |
+
</config>
|
app/etc/modules/Actonlytics_Plugin.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Actonlytics_Plugin>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Actonlytics_Plugin>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Actonlytics_Signup.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Actonlytics_Signup>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Actonlytics_Plugin />
|
9 |
+
</depends>
|
10 |
+
</Actonlytics_Signup>
|
11 |
+
</modules>
|
12 |
+
</config>
|
lib/ac/autoload.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload.php @generated by Composer
|
4 |
+
|
5 |
+
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
+
|
7 |
+
return ComposerAutoloaderInitfenrir::getLoader();
|
lib/ac/composer/ClassLoader.php
ADDED
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of Composer.
|
5 |
+
*
|
6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
+
*
|
9 |
+
* For the full copyright and license information, please view the LICENSE
|
10 |
+
* file that was distributed with this source code.
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Composer\Autoload;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
17 |
+
*
|
18 |
+
* $loader = new \Composer\Autoload\ClassLoader();
|
19 |
+
*
|
20 |
+
* // register classes with namespaces
|
21 |
+
* $loader->add('Symfony\Component', __DIR__.'/component');
|
22 |
+
* $loader->add('Symfony', __DIR__.'/framework');
|
23 |
+
*
|
24 |
+
* // activate the autoloader
|
25 |
+
* $loader->register();
|
26 |
+
*
|
27 |
+
* // to enable searching the include path (eg. for PEAR packages)
|
28 |
+
* $loader->setUseIncludePath(true);
|
29 |
+
*
|
30 |
+
* In this example, if you try to use a class in the Symfony\Component
|
31 |
+
* namespace or one of its children (Symfony\Component\Console for instance),
|
32 |
+
* the autoloader will first look for the class under the component/
|
33 |
+
* directory, and it will then fallback to the framework/ directory if not
|
34 |
+
* found before giving up.
|
35 |
+
*
|
36 |
+
* This class is loosely based on the Symfony UniversalClassLoader.
|
37 |
+
*
|
38 |
+
* @author Fabien Potencier <fabien@symfony.com>
|
39 |
+
* @author Jordi Boggiano <j.boggiano@seld.be>
|
40 |
+
* @see http://www.php-fig.org/psr/psr-0/
|
41 |
+
* @see http://www.php-fig.org/psr/psr-4/
|
42 |
+
*/
|
43 |
+
class ClassLoader
|
44 |
+
{
|
45 |
+
// PSR-4
|
46 |
+
private $prefixLengthsPsr4 = array();
|
47 |
+
private $prefixDirsPsr4 = array();
|
48 |
+
private $fallbackDirsPsr4 = array();
|
49 |
+
|
50 |
+
// PSR-0
|
51 |
+
private $prefixesPsr0 = array();
|
52 |
+
private $fallbackDirsPsr0 = array();
|
53 |
+
|
54 |
+
private $useIncludePath = false;
|
55 |
+
private $classMap = array();
|
56 |
+
|
57 |
+
private $classMapAuthoritative = false;
|
58 |
+
|
59 |
+
public function getPrefixes()
|
60 |
+
{
|
61 |
+
if (!empty($this->prefixesPsr0)) {
|
62 |
+
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
63 |
+
}
|
64 |
+
|
65 |
+
return array();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getPrefixesPsr4()
|
69 |
+
{
|
70 |
+
return $this->prefixDirsPsr4;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getFallbackDirs()
|
74 |
+
{
|
75 |
+
return $this->fallbackDirsPsr0;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getFallbackDirsPsr4()
|
79 |
+
{
|
80 |
+
return $this->fallbackDirsPsr4;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getClassMap()
|
84 |
+
{
|
85 |
+
return $this->classMap;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param array $classMap Class to filename map
|
90 |
+
*/
|
91 |
+
public function addClassMap(array $classMap)
|
92 |
+
{
|
93 |
+
if ($this->classMap) {
|
94 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
95 |
+
} else {
|
96 |
+
$this->classMap = $classMap;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Registers a set of PSR-0 directories for a given prefix, either
|
102 |
+
* appending or prepending to the ones previously set for this prefix.
|
103 |
+
*
|
104 |
+
* @param string $prefix The prefix
|
105 |
+
* @param array|string $paths The PSR-0 root directories
|
106 |
+
* @param bool $prepend Whether to prepend the directories
|
107 |
+
*/
|
108 |
+
public function add($prefix, $paths, $prepend = false)
|
109 |
+
{
|
110 |
+
if (!$prefix) {
|
111 |
+
if ($prepend) {
|
112 |
+
$this->fallbackDirsPsr0 = array_merge(
|
113 |
+
(array) $paths,
|
114 |
+
$this->fallbackDirsPsr0
|
115 |
+
);
|
116 |
+
} else {
|
117 |
+
$this->fallbackDirsPsr0 = array_merge(
|
118 |
+
$this->fallbackDirsPsr0,
|
119 |
+
(array) $paths
|
120 |
+
);
|
121 |
+
}
|
122 |
+
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
$first = $prefix[0];
|
127 |
+
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
128 |
+
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
129 |
+
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
if ($prepend) {
|
133 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
134 |
+
(array) $paths,
|
135 |
+
$this->prefixesPsr0[$first][$prefix]
|
136 |
+
);
|
137 |
+
} else {
|
138 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
139 |
+
$this->prefixesPsr0[$first][$prefix],
|
140 |
+
(array) $paths
|
141 |
+
);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Registers a set of PSR-4 directories for a given namespace, either
|
147 |
+
* appending or prepending to the ones previously set for this namespace.
|
148 |
+
*
|
149 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
150 |
+
* @param array|string $paths The PSR-4 base directories
|
151 |
+
* @param bool $prepend Whether to prepend the directories
|
152 |
+
*
|
153 |
+
* @throws \InvalidArgumentException
|
154 |
+
*/
|
155 |
+
public function addPsr4($prefix, $paths, $prepend = false)
|
156 |
+
{
|
157 |
+
if (!$prefix) {
|
158 |
+
// Register directories for the root namespace.
|
159 |
+
if ($prepend) {
|
160 |
+
$this->fallbackDirsPsr4 = array_merge(
|
161 |
+
(array) $paths,
|
162 |
+
$this->fallbackDirsPsr4
|
163 |
+
);
|
164 |
+
} else {
|
165 |
+
$this->fallbackDirsPsr4 = array_merge(
|
166 |
+
$this->fallbackDirsPsr4,
|
167 |
+
(array) $paths
|
168 |
+
);
|
169 |
+
}
|
170 |
+
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
171 |
+
// Register directories for a new namespace.
|
172 |
+
$length = strlen($prefix);
|
173 |
+
if ('\\' !== $prefix[$length - 1]) {
|
174 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
175 |
+
}
|
176 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
177 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
178 |
+
} elseif ($prepend) {
|
179 |
+
// Prepend directories for an already registered namespace.
|
180 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
181 |
+
(array) $paths,
|
182 |
+
$this->prefixDirsPsr4[$prefix]
|
183 |
+
);
|
184 |
+
} else {
|
185 |
+
// Append directories for an already registered namespace.
|
186 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
187 |
+
$this->prefixDirsPsr4[$prefix],
|
188 |
+
(array) $paths
|
189 |
+
);
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Registers a set of PSR-0 directories for a given prefix,
|
195 |
+
* replacing any others previously set for this prefix.
|
196 |
+
*
|
197 |
+
* @param string $prefix The prefix
|
198 |
+
* @param array|string $paths The PSR-0 base directories
|
199 |
+
*/
|
200 |
+
public function set($prefix, $paths)
|
201 |
+
{
|
202 |
+
if (!$prefix) {
|
203 |
+
$this->fallbackDirsPsr0 = (array) $paths;
|
204 |
+
} else {
|
205 |
+
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Registers a set of PSR-4 directories for a given namespace,
|
211 |
+
* replacing any others previously set for this namespace.
|
212 |
+
*
|
213 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
214 |
+
* @param array|string $paths The PSR-4 base directories
|
215 |
+
*
|
216 |
+
* @throws \InvalidArgumentException
|
217 |
+
*/
|
218 |
+
public function setPsr4($prefix, $paths)
|
219 |
+
{
|
220 |
+
if (!$prefix) {
|
221 |
+
$this->fallbackDirsPsr4 = (array) $paths;
|
222 |
+
} else {
|
223 |
+
$length = strlen($prefix);
|
224 |
+
if ('\\' !== $prefix[$length - 1]) {
|
225 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
226 |
+
}
|
227 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
228 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Turns on searching the include path for class files.
|
234 |
+
*
|
235 |
+
* @param bool $useIncludePath
|
236 |
+
*/
|
237 |
+
public function setUseIncludePath($useIncludePath)
|
238 |
+
{
|
239 |
+
$this->useIncludePath = $useIncludePath;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Can be used to check if the autoloader uses the include path to check
|
244 |
+
* for classes.
|
245 |
+
*
|
246 |
+
* @return bool
|
247 |
+
*/
|
248 |
+
public function getUseIncludePath()
|
249 |
+
{
|
250 |
+
return $this->useIncludePath;
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Turns off searching the prefix and fallback directories for classes
|
255 |
+
* that have not been registered with the class map.
|
256 |
+
*
|
257 |
+
* @param bool $classMapAuthoritative
|
258 |
+
*/
|
259 |
+
public function setClassMapAuthoritative($classMapAuthoritative)
|
260 |
+
{
|
261 |
+
$this->classMapAuthoritative = $classMapAuthoritative;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Should class lookup fail if not found in the current class map?
|
266 |
+
*
|
267 |
+
* @return bool
|
268 |
+
*/
|
269 |
+
public function isClassMapAuthoritative()
|
270 |
+
{
|
271 |
+
return $this->classMapAuthoritative;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Registers this instance as an autoloader.
|
276 |
+
*
|
277 |
+
* @param bool $prepend Whether to prepend the autoloader or not
|
278 |
+
*/
|
279 |
+
public function register($prepend = false)
|
280 |
+
{
|
281 |
+
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Unregisters this instance as an autoloader.
|
286 |
+
*/
|
287 |
+
public function unregister()
|
288 |
+
{
|
289 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Loads the given class or interface.
|
294 |
+
*
|
295 |
+
* @param string $class The name of the class
|
296 |
+
* @return bool|null True if loaded, null otherwise
|
297 |
+
*/
|
298 |
+
public function loadClass($class)
|
299 |
+
{
|
300 |
+
if ($file = $this->findFile($class)) {
|
301 |
+
includeFile($file);
|
302 |
+
|
303 |
+
return true;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Finds the path to the file where the class is defined.
|
309 |
+
*
|
310 |
+
* @param string $class The name of the class
|
311 |
+
*
|
312 |
+
* @return string|false The path if found, false otherwise
|
313 |
+
*/
|
314 |
+
public function findFile($class)
|
315 |
+
{
|
316 |
+
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
317 |
+
if ('\\' == $class[0]) {
|
318 |
+
$class = substr($class, 1);
|
319 |
+
}
|
320 |
+
|
321 |
+
// class map lookup
|
322 |
+
if (isset($this->classMap[$class])) {
|
323 |
+
return $this->classMap[$class];
|
324 |
+
}
|
325 |
+
if ($this->classMapAuthoritative) {
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
+
$file = $this->findFileWithExtension($class, '.php');
|
330 |
+
|
331 |
+
// Search for Hack files if we are running on HHVM
|
332 |
+
if ($file === null && defined('HHVM_VERSION')) {
|
333 |
+
$file = $this->findFileWithExtension($class, '.hh');
|
334 |
+
}
|
335 |
+
|
336 |
+
if ($file === null) {
|
337 |
+
// Remember that this class does not exist.
|
338 |
+
return $this->classMap[$class] = false;
|
339 |
+
}
|
340 |
+
|
341 |
+
return $file;
|
342 |
+
}
|
343 |
+
|
344 |
+
private function findFileWithExtension($class, $ext)
|
345 |
+
{
|
346 |
+
// PSR-4 lookup
|
347 |
+
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
348 |
+
|
349 |
+
$first = $class[0];
|
350 |
+
if (isset($this->prefixLengthsPsr4[$first])) {
|
351 |
+
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
352 |
+
if (0 === strpos($class, $prefix)) {
|
353 |
+
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
354 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
355 |
+
return $file;
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
// PSR-4 fallback dirs
|
363 |
+
foreach ($this->fallbackDirsPsr4 as $dir) {
|
364 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
365 |
+
return $file;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
// PSR-0 lookup
|
370 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
371 |
+
// namespaced class name
|
372 |
+
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
373 |
+
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
374 |
+
} else {
|
375 |
+
// PEAR-like class name
|
376 |
+
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
377 |
+
}
|
378 |
+
|
379 |
+
if (isset($this->prefixesPsr0[$first])) {
|
380 |
+
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
381 |
+
if (0 === strpos($class, $prefix)) {
|
382 |
+
foreach ($dirs as $dir) {
|
383 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
384 |
+
return $file;
|
385 |
+
}
|
386 |
+
}
|
387 |
+
}
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
// PSR-0 fallback dirs
|
392 |
+
foreach ($this->fallbackDirsPsr0 as $dir) {
|
393 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
394 |
+
return $file;
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
// PSR-0 include paths.
|
399 |
+
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
400 |
+
return $file;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Scope isolated include.
|
407 |
+
*
|
408 |
+
* Prevents access to $this/self from included files.
|
409 |
+
*/
|
410 |
+
function includeFile($file)
|
411 |
+
{
|
412 |
+
include $file;
|
413 |
+
}
|
lib/ac/composer/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
|
3 |
+
|
4 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
+
of this software and associated documentation files (the "Software"), to deal
|
6 |
+
in the Software without restriction, including without limitation the rights
|
7 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
+
copies of the Software, and to permit persons to whom the Software is furnished
|
9 |
+
to do so, subject to the following conditions:
|
10 |
+
|
11 |
+
The above copyright notice and this permission notice shall be included in all
|
12 |
+
copies or substantial portions of the Software.
|
13 |
+
|
14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20 |
+
THE SOFTWARE.
|
21 |
+
|
lib/ac/composer/autoload_classmap.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_classmap.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname(dirname($vendorDir));
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'Itembase\\Composer\\Installer' => $vendorDir . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/Installer.php',
|
10 |
+
'Itembase\\Composer\\PlatformInstaller\\AbstractInstaller' => $vendorDir . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/AbstractInstaller.php',
|
11 |
+
'Itembase\\Composer\\PlatformInstaller\\Magento' => $vendorDir . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/Magento.php',
|
12 |
+
'Itembase\\Composer\\PlatformInstaller\\Prestashop' => $vendorDir . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/Prestashop.php',
|
13 |
+
'Itembase\\Composer\\PlatformInstaller\\Woocommerce' => $vendorDir . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/Woocommerce.php',
|
14 |
+
'Itembase\\PluginExtension\\Data\\Extension' => $vendorDir . '/itembase/m1-ext-data/src/Itembase/PluginExtension/Data/Extension.php',
|
15 |
+
'Itembase\\PluginExtension\\Multishop\\Extension' => $vendorDir . '/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Extension.php',
|
16 |
+
'Itembase\\PluginExtension\\Multishop\\Multishop' => $vendorDir . '/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Multishop.php',
|
17 |
+
'Itembase\\PluginExtension\\Platform\\Extension' => $vendorDir . '/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Extension.php',
|
18 |
+
'Itembase\\PluginExtension\\Platform\\Platform' => $vendorDir . '/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Platform.php',
|
19 |
+
'Itembase\\PluginExtension\\Storage\\Extension' => $vendorDir . '/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Extension.php',
|
20 |
+
'Itembase\\PluginExtension\\Storage\\Storage' => $vendorDir . '/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Storage.php',
|
21 |
+
'Itembase\\PsdkExtension\\Data\\Extension' => $vendorDir . '/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/Extension.php',
|
22 |
+
'Itembase\\PsdkExtension\\Data\\FetcherInterface' => $vendorDir . '/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/FetcherInterface.php',
|
23 |
+
'Itembase\\PsdkExtension\\Registration\\PingHandler' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Core/PingHandler.php',
|
24 |
+
'Itembase\\PsdkExtension\\RemoteFS\\Extension' => $vendorDir . '/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Extension.php',
|
25 |
+
'Itembase\\PsdkExtension\\RemoteFS\\Filesystem' => $vendorDir . '/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Filesystem.php',
|
26 |
+
'Itembase\\PsdkExtension\\Signup\\Extension' => $vendorDir . '/itembase/psdk2-ext-signup/src/Itembase/PsdkExtension/Signup/Extension.php',
|
27 |
+
'Itembase\\PsdkExtension\\SysInfo\\Extension' => $vendorDir . '/itembase/psdk2-ext-sysinfo/src/Itembase/PsdkExtension/SysInfo/Extension.php',
|
28 |
+
'Itembase\\Psdk\\Container\\ContainerAwareInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Container/ContainerAwareInterface.php',
|
29 |
+
'Itembase\\Psdk\\Container\\ServiceContainer' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Container/ServiceContainer.php',
|
30 |
+
'Itembase\\Psdk\\Core' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Core.php',
|
31 |
+
'Itembase\\Psdk\\Core\\ExceptionHandler' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Core/ExceptionHandler.php',
|
32 |
+
'Itembase\\Psdk\\Core\\Logger' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Core/Logger.php',
|
33 |
+
'Itembase\\Psdk\\Core\\OAuthClient' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Core/OAuthClient.php',
|
34 |
+
'Itembase\\Psdk\\Event\\EventAwareInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Event/EventAwareInterface.php',
|
35 |
+
'Itembase\\Psdk\\Event\\EventDispatcher' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Event/EventDispatcher.php',
|
36 |
+
'Itembase\\Psdk\\Event\\EventListenerInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Event/EventListenerInterface.php',
|
37 |
+
'Itembase\\Psdk\\Extension\\ExtensionInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionInterface.php',
|
38 |
+
'Itembase\\Psdk\\Extension\\ExtensionsLoader' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionsLoader.php',
|
39 |
+
'Itembase\\Psdk\\Http\\HttpClient' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Http/HttpClient.php',
|
40 |
+
'Itembase\\Psdk\\Http\\HttpHandler' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Http/HttpHandler.php',
|
41 |
+
'Itembase\\Psdk\\Http\\Request' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Http/Request.php',
|
42 |
+
'Itembase\\Psdk\\Http\\RequestAwareInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Http/RequestAwareInterface.php',
|
43 |
+
'Itembase\\Psdk\\Http\\Response' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Http/Response.php',
|
44 |
+
'Itembase\\Psdk\\Http\\ResponseAwareInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Http/ResponseAwareInterface.php',
|
45 |
+
'Itembase\\Psdk\\Platform\\Frontend\\ControllerInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Platform/Frontend/ControllerInterface.php',
|
46 |
+
'Itembase\\Psdk\\Platform\\MultiShop\\MultishopAbstract' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/MultishopAbstract.php',
|
47 |
+
'Itembase\\Psdk\\Platform\\MultiShop\\Shop' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/Shop.php',
|
48 |
+
'Itembase\\Psdk\\Platform\\PlatformInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Platform/PlatformInterface.php',
|
49 |
+
'Itembase\\Psdk\\Platform\\StorageInterface' => $vendorDir . '/itembase/psdk2/src/Itembase/Psdk/Platform/StorageInterface.php',
|
50 |
+
);
|
lib/ac/composer/autoload_namespaces.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_namespaces.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname(dirname($vendorDir));
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'Itembase\\Composer' => array($vendorDir . '/itembase/composer-platform-ext-installer/src'),
|
10 |
+
);
|
lib/ac/composer/autoload_psr4.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_psr4.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname(dirname($vendorDir));
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'Itembase\\' => array($vendorDir . '/itembase/psdk2/src', $vendorDir . '/itembase/psdk2-ext-data/src', $vendorDir . '/itembase/m1-ext-data/src', $vendorDir . '/itembase/m1-ext-multishop/src', $vendorDir . '/itembase/m1-ext-platform/src', $vendorDir . '/itembase/m1-ext-storage/src', $vendorDir . '/itembase/psdk2-ext-remotefs/src', $vendorDir . '/itembase/psdk2-ext-signup/src', $vendorDir . '/itembase/psdk2-ext-sysinfo/src'),
|
10 |
+
);
|
lib/ac/composer/autoload_real.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_real.php @generated by Composer
|
4 |
+
|
5 |
+
class ComposerAutoloaderInitfenrir
|
6 |
+
{
|
7 |
+
private static $loader;
|
8 |
+
|
9 |
+
public static function loadClassLoader($class)
|
10 |
+
{
|
11 |
+
if ('Composer\Autoload\ClassLoader' === $class) {
|
12 |
+
require __DIR__ . '/ClassLoader.php';
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
public static function getLoader()
|
17 |
+
{
|
18 |
+
if (null !== self::$loader) {
|
19 |
+
return self::$loader;
|
20 |
+
}
|
21 |
+
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitfenrir', 'loadClassLoader'), true, true);
|
23 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitfenrir', 'loadClassLoader'));
|
25 |
+
|
26 |
+
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
|
27 |
+
if ($useStaticLoader) {
|
28 |
+
require_once __DIR__ . '/autoload_static.php';
|
29 |
+
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitfenrir::getInitializer($loader));
|
31 |
+
} else {
|
32 |
+
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
+
foreach ($map as $namespace => $path) {
|
34 |
+
$loader->set($namespace, $path);
|
35 |
+
}
|
36 |
+
|
37 |
+
$map = require __DIR__ . '/autoload_psr4.php';
|
38 |
+
foreach ($map as $namespace => $path) {
|
39 |
+
$loader->setPsr4($namespace, $path);
|
40 |
+
}
|
41 |
+
|
42 |
+
$classMap = require __DIR__ . '/autoload_classmap.php';
|
43 |
+
if ($classMap) {
|
44 |
+
$loader->addClassMap($classMap);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$loader->register(true);
|
49 |
+
|
50 |
+
return $loader;
|
51 |
+
}
|
52 |
+
}
|
lib/ac/composer/autoload_static.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_static.php @generated by Composer
|
4 |
+
|
5 |
+
namespace Composer\Autoload;
|
6 |
+
|
7 |
+
class ComposerStaticInitfenrir
|
8 |
+
{
|
9 |
+
public static $prefixLengthsPsr4 = array (
|
10 |
+
'I' =>
|
11 |
+
array (
|
12 |
+
'Itembase\\' => 9,
|
13 |
+
),
|
14 |
+
);
|
15 |
+
|
16 |
+
public static $prefixDirsPsr4 = array (
|
17 |
+
'Itembase\\' =>
|
18 |
+
array (
|
19 |
+
0 => __DIR__ . '/..' . '/itembase/psdk2/src',
|
20 |
+
1 => __DIR__ . '/..' . '/itembase/psdk2-ext-data/src',
|
21 |
+
2 => __DIR__ . '/..' . '/itembase/m1-ext-data/src',
|
22 |
+
3 => __DIR__ . '/..' . '/itembase/m1-ext-multishop/src',
|
23 |
+
4 => __DIR__ . '/..' . '/itembase/m1-ext-platform/src',
|
24 |
+
5 => __DIR__ . '/..' . '/itembase/m1-ext-storage/src',
|
25 |
+
6 => __DIR__ . '/..' . '/itembase/psdk2-ext-remotefs/src',
|
26 |
+
7 => __DIR__ . '/..' . '/itembase/psdk2-ext-signup/src',
|
27 |
+
8 => __DIR__ . '/..' . '/itembase/psdk2-ext-sysinfo/src',
|
28 |
+
),
|
29 |
+
);
|
30 |
+
|
31 |
+
public static $prefixesPsr0 = array (
|
32 |
+
'I' =>
|
33 |
+
array (
|
34 |
+
'Itembase\\Composer' =>
|
35 |
+
array (
|
36 |
+
0 => __DIR__ . '/..' . '/itembase/composer-platform-ext-installer/src',
|
37 |
+
),
|
38 |
+
),
|
39 |
+
);
|
40 |
+
|
41 |
+
public static $classMap = array (
|
42 |
+
'Itembase\\Composer\\Installer' => __DIR__ . '/..' . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/Installer.php',
|
43 |
+
'Itembase\\Composer\\PlatformInstaller\\AbstractInstaller' => __DIR__ . '/..' . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/AbstractInstaller.php',
|
44 |
+
'Itembase\\Composer\\PlatformInstaller\\Magento' => __DIR__ . '/..' . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/Magento.php',
|
45 |
+
'Itembase\\Composer\\PlatformInstaller\\Prestashop' => __DIR__ . '/..' . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/Prestashop.php',
|
46 |
+
'Itembase\\Composer\\PlatformInstaller\\Woocommerce' => __DIR__ . '/..' . '/itembase/composer-platform-ext-installer/src/Itembase/Composer/PlatformInstaller/Woocommerce.php',
|
47 |
+
'Itembase\\PluginExtension\\Data\\Extension' => __DIR__ . '/..' . '/itembase/m1-ext-data/src/Itembase/PluginExtension/Data/Extension.php',
|
48 |
+
'Itembase\\PluginExtension\\Multishop\\Extension' => __DIR__ . '/..' . '/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Extension.php',
|
49 |
+
'Itembase\\PluginExtension\\Multishop\\Multishop' => __DIR__ . '/..' . '/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Multishop.php',
|
50 |
+
'Itembase\\PluginExtension\\Platform\\Extension' => __DIR__ . '/..' . '/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Extension.php',
|
51 |
+
'Itembase\\PluginExtension\\Platform\\Platform' => __DIR__ . '/..' . '/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Platform.php',
|
52 |
+
'Itembase\\PluginExtension\\Storage\\Extension' => __DIR__ . '/..' . '/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Extension.php',
|
53 |
+
'Itembase\\PluginExtension\\Storage\\Storage' => __DIR__ . '/..' . '/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Storage.php',
|
54 |
+
'Itembase\\PsdkExtension\\Data\\Extension' => __DIR__ . '/..' . '/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/Extension.php',
|
55 |
+
'Itembase\\PsdkExtension\\Data\\FetcherInterface' => __DIR__ . '/..' . '/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/FetcherInterface.php',
|
56 |
+
'Itembase\\PsdkExtension\\Registration\\PingHandler' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Core/PingHandler.php',
|
57 |
+
'Itembase\\PsdkExtension\\RemoteFS\\Extension' => __DIR__ . '/..' . '/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Extension.php',
|
58 |
+
'Itembase\\PsdkExtension\\RemoteFS\\Filesystem' => __DIR__ . '/..' . '/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Filesystem.php',
|
59 |
+
'Itembase\\PsdkExtension\\Signup\\Extension' => __DIR__ . '/..' . '/itembase/psdk2-ext-signup/src/Itembase/PsdkExtension/Signup/Extension.php',
|
60 |
+
'Itembase\\PsdkExtension\\SysInfo\\Extension' => __DIR__ . '/..' . '/itembase/psdk2-ext-sysinfo/src/Itembase/PsdkExtension/SysInfo/Extension.php',
|
61 |
+
'Itembase\\Psdk\\Container\\ContainerAwareInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Container/ContainerAwareInterface.php',
|
62 |
+
'Itembase\\Psdk\\Container\\ServiceContainer' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Container/ServiceContainer.php',
|
63 |
+
'Itembase\\Psdk\\Core' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Core.php',
|
64 |
+
'Itembase\\Psdk\\Core\\ExceptionHandler' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Core/ExceptionHandler.php',
|
65 |
+
'Itembase\\Psdk\\Core\\Logger' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Core/Logger.php',
|
66 |
+
'Itembase\\Psdk\\Core\\OAuthClient' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Core/OAuthClient.php',
|
67 |
+
'Itembase\\Psdk\\Event\\EventAwareInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Event/EventAwareInterface.php',
|
68 |
+
'Itembase\\Psdk\\Event\\EventDispatcher' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Event/EventDispatcher.php',
|
69 |
+
'Itembase\\Psdk\\Event\\EventListenerInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Event/EventListenerInterface.php',
|
70 |
+
'Itembase\\Psdk\\Extension\\ExtensionInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionInterface.php',
|
71 |
+
'Itembase\\Psdk\\Extension\\ExtensionsLoader' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionsLoader.php',
|
72 |
+
'Itembase\\Psdk\\Http\\HttpClient' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Http/HttpClient.php',
|
73 |
+
'Itembase\\Psdk\\Http\\HttpHandler' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Http/HttpHandler.php',
|
74 |
+
'Itembase\\Psdk\\Http\\Request' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Http/Request.php',
|
75 |
+
'Itembase\\Psdk\\Http\\RequestAwareInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Http/RequestAwareInterface.php',
|
76 |
+
'Itembase\\Psdk\\Http\\Response' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Http/Response.php',
|
77 |
+
'Itembase\\Psdk\\Http\\ResponseAwareInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Http/ResponseAwareInterface.php',
|
78 |
+
'Itembase\\Psdk\\Platform\\Frontend\\ControllerInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Platform/Frontend/ControllerInterface.php',
|
79 |
+
'Itembase\\Psdk\\Platform\\MultiShop\\MultishopAbstract' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/MultishopAbstract.php',
|
80 |
+
'Itembase\\Psdk\\Platform\\MultiShop\\Shop' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/Shop.php',
|
81 |
+
'Itembase\\Psdk\\Platform\\PlatformInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Platform/PlatformInterface.php',
|
82 |
+
'Itembase\\Psdk\\Platform\\StorageInterface' => __DIR__ . '/..' . '/itembase/psdk2/src/Itembase/Psdk/Platform/StorageInterface.php',
|
83 |
+
);
|
84 |
+
|
85 |
+
public static function getInitializer(ClassLoader $loader)
|
86 |
+
{
|
87 |
+
return \Closure::bind(function () use ($loader) {
|
88 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitfenrir::$prefixLengthsPsr4;
|
89 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitfenrir::$prefixDirsPsr4;
|
90 |
+
$loader->prefixesPsr0 = ComposerStaticInitfenrir::$prefixesPsr0;
|
91 |
+
$loader->classMap = ComposerStaticInitfenrir::$classMap;
|
92 |
+
|
93 |
+
}, null, ClassLoader::class);
|
94 |
+
}
|
95 |
+
}
|
lib/ac/itembase/m1-ext-data/src/Itembase/PluginExtension/Data/Extension.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (C) 2016 itembase GmbH - All Rights Reserved
|
4 |
+
*/
|
5 |
+
namespace Itembase\PluginExtension\Data;
|
6 |
+
|
7 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
8 |
+
use Itembase\PsdkExtension\Data\FetcherInterface;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Extension
|
12 |
+
*
|
13 |
+
* @package Itembase\PluginExtension\Data
|
14 |
+
*/
|
15 |
+
class Extension implements ExtensionInterface, FetcherInterface
|
16 |
+
{
|
17 |
+
/**
|
18 |
+
* {@inheritdoc}
|
19 |
+
*/
|
20 |
+
public function getExtensionName()
|
21 |
+
{
|
22 |
+
return \Itembase\PsdkExtension\Data\Extension::DATA_FETCH_FETCHER;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* {@inheritdoc}
|
27 |
+
*/
|
28 |
+
public function getProfileData($shopId, $page, $limit, $minDateCreated, $minDateUpdated)
|
29 |
+
{
|
30 |
+
$shop = \Mage::app()->getStore($shopId);
|
31 |
+
|
32 |
+
$data[] = array(
|
33 |
+
'store' => $shop->getData(),
|
34 |
+
'currency' => $shop->getCurrentCurrencyCode(),
|
35 |
+
'timezone' => \Mage::getStoreConfig('general/locale/timezone', $shopId),
|
36 |
+
'language' => $language = substr(\Mage::getStoreConfig('general/locale/code', $shopId), 0, 2),
|
37 |
+
'email' => \Mage::getStoreConfig('trans_email/ident_general/email', $shopId),
|
38 |
+
'url' => \Mage::getStoreConfig('web/unsecure/base_url', $shopId) !== null
|
39 |
+
? \Mage::getStoreConfig('web/unsecure/base_url', $shopId)
|
40 |
+
: \Mage::getStoreConfig('web/unsecure/base_url'),
|
41 |
+
);
|
42 |
+
|
43 |
+
return $data;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* {@inheritdoc}
|
48 |
+
*/
|
49 |
+
public function getBuyersData($shopId, $page, $limit, $minDateCreated, $minDateUpdated)
|
50 |
+
{
|
51 |
+
$minDateCreated = date('Y-m-d H:i:s', $minDateCreated);
|
52 |
+
$minDateUpdated = date('Y-m-d H:i:s', $minDateUpdated);
|
53 |
+
|
54 |
+
$customerCollections = \Mage::getModel('customer/customer')
|
55 |
+
->getCollection()
|
56 |
+
->addAttributeToSort('created_at', 'desc')
|
57 |
+
->addAttributeToFilter('created_at', array('from' => $minDateCreated))
|
58 |
+
->addAttributeToFilter('updated_at', array('from' => $minDateUpdated))
|
59 |
+
->addAttributeToFilter('store_id', array('eq' => $shopId))
|
60 |
+
->setCurPage($page)
|
61 |
+
->setPageSize($limit);
|
62 |
+
|
63 |
+
$data = array();
|
64 |
+
|
65 |
+
foreach ($customerCollections as $customerCollection) {
|
66 |
+
$buyer_addresses = array();
|
67 |
+
|
68 |
+
foreach ($customerCollection->getAddressesCollection() as $address) {
|
69 |
+
$buyer_addresses[] = $address->getData();
|
70 |
+
}
|
71 |
+
|
72 |
+
$data[] = array(
|
73 |
+
'buyer' => $customerCollection->getData(),
|
74 |
+
'buyer_addresses' => $buyer_addresses,
|
75 |
+
);
|
76 |
+
}
|
77 |
+
|
78 |
+
return $data;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* {@inheritdoc}
|
83 |
+
*/
|
84 |
+
public function getTransactionsData($shopId, $page, $limit, $minDateCreated, $minDateUpdated)
|
85 |
+
{
|
86 |
+
$minDateCreated = date('Y-m-d H:i:s', $minDateCreated);
|
87 |
+
$minDateUpdated = date('Y-m-d H:i:s', $minDateUpdated);
|
88 |
+
|
89 |
+
$orderCollections = \Mage::getModel('sales/order')
|
90 |
+
->getCollection()
|
91 |
+
->addAttributeToFilter('store_id', array('eq' => $shopId))
|
92 |
+
->addAttributeToSort('created_at', 'desc')
|
93 |
+
->addAttributeToFilter('created_at', array('from' => $minDateCreated))
|
94 |
+
->addAttributeToFilter('updated_at', array('from' => $minDateUpdated))
|
95 |
+
->setPageSize($limit)
|
96 |
+
->setCurPage($page);
|
97 |
+
|
98 |
+
$data = array();
|
99 |
+
$currency = \Mage::app()->getStore($shopId)->getCurrentCurrencyCode();
|
100 |
+
|
101 |
+
foreach ($orderCollections as $orderCollection) {
|
102 |
+
$items = $orderCollection->getAllVisibleItems();
|
103 |
+
$products = array();
|
104 |
+
|
105 |
+
foreach ($items as $item) {
|
106 |
+
$product_collection = $item->getProduct();
|
107 |
+
$category_array = array();
|
108 |
+
$categoryIds = $product_collection->getCategoryIds();
|
109 |
+
|
110 |
+
if (!empty($categoryIds)) {
|
111 |
+
foreach ($categoryIds as $value) {
|
112 |
+
$category = \Mage::getModel('catalog/category')->load($value);
|
113 |
+
$category_array[] = $category->getData();
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/** @var Varien_Data_Collection $gallery */
|
118 |
+
$images = array();
|
119 |
+
$gallery = $product_collection->getMediaGalleryImages();
|
120 |
+
|
121 |
+
foreach ($gallery->getItems() as $img) {
|
122 |
+
$images[] = $img->getData();
|
123 |
+
}
|
124 |
+
|
125 |
+
$products[] = array(
|
126 |
+
'transaction_product' => $item->getData(),
|
127 |
+
'product_detail' => $product_collection->getData(),
|
128 |
+
'product_categories' => $category_array,
|
129 |
+
'images' => $images,
|
130 |
+
'product_url' => $product_collection->getProductUrl(),
|
131 |
+
'currency' => $currency,
|
132 |
+
);
|
133 |
+
}
|
134 |
+
|
135 |
+
$buyer_addresses = array();
|
136 |
+
$buyer = array();
|
137 |
+
|
138 |
+
if ($orderCollection->getCustomerId()) {
|
139 |
+
$buyer = \Mage::getModel('customer/customer')->load($orderCollection->getCustomerId());
|
140 |
+
|
141 |
+
foreach ($buyer->getAddressesCollection() as $address) {
|
142 |
+
$buyer_addresses[] = $address->getData();
|
143 |
+
}
|
144 |
+
|
145 |
+
$buyer = $buyer->getData();
|
146 |
+
}
|
147 |
+
|
148 |
+
$shiping = array();
|
149 |
+
|
150 |
+
if ($orderCollection->getShippingAddress()) {
|
151 |
+
$shiping = $orderCollection->getShippingAddress()->getData();
|
152 |
+
}
|
153 |
+
|
154 |
+
$billing = array();
|
155 |
+
|
156 |
+
if ($orderCollection->getBillingAddress()) {
|
157 |
+
$billing = $orderCollection->getBillingAddress()->getData();
|
158 |
+
}
|
159 |
+
|
160 |
+
$data[] = array(
|
161 |
+
'transaction' => $orderCollection->getData(),
|
162 |
+
'products' => $products,
|
163 |
+
'tracks' => $orderCollection->getTracksCollection()->getData(),
|
164 |
+
'shipping' => $shiping,
|
165 |
+
'billing' => $billing,
|
166 |
+
'buyer' => $buyer,
|
167 |
+
'buyer_addresses' => $buyer_addresses,
|
168 |
+
'currency' => $currency,
|
169 |
+
);
|
170 |
+
}
|
171 |
+
|
172 |
+
return $data;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* {@inheritdoc}
|
177 |
+
*/
|
178 |
+
public function getProductsData($shopId, $page, $limit, $minDateCreated, $minDateUpdated)
|
179 |
+
{
|
180 |
+
$minDateCreated = date('Y-m-d H:i:s', $minDateCreated);
|
181 |
+
$minDateUpdated = date('Y-m-d H:i:s', $minDateUpdated);
|
182 |
+
|
183 |
+
$productCollections = \Mage::getModel('catalog/product')
|
184 |
+
->getCollection()
|
185 |
+
->addStoreFilter($shopId)
|
186 |
+
->addAttributeToFilter('created_at', array('from' => $minDateCreated))
|
187 |
+
->addAttributeToFilter('updated_at', array('from' => $minDateUpdated))
|
188 |
+
->addAttributeToFilter('status', array('eq' => 1))
|
189 |
+
->setPageSize($limit)
|
190 |
+
->setCurPage($page);
|
191 |
+
|
192 |
+
$data = array();
|
193 |
+
|
194 |
+
foreach ($productCollections as $productCollection) {
|
195 |
+
$categoryArray = array();
|
196 |
+
$categoryIds = $productCollection->getCategoryIds();
|
197 |
+
|
198 |
+
if (!empty($categoryIds)) {
|
199 |
+
foreach ($categoryIds as $value) {
|
200 |
+
$category = \Mage::getModel('catalog/category')->load($value);
|
201 |
+
$categoryArray[] = $category->getData();
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
$productCollectionData = $productCollection->getData();
|
206 |
+
|
207 |
+
$item = \Mage::app()
|
208 |
+
->getLayout()
|
209 |
+
->helper('catalog/product')
|
210 |
+
->getProduct($productCollectionData['entity_id'], $shopId);
|
211 |
+
|
212 |
+
/** @var Varien_Data_Collection $gallery */
|
213 |
+
$images = array();
|
214 |
+
$gallery = $item->getMediaGalleryImages();
|
215 |
+
|
216 |
+
foreach ($gallery->getItems() as $img) {
|
217 |
+
$images[] = $img->getData();
|
218 |
+
}
|
219 |
+
|
220 |
+
$productData = $item->getData();
|
221 |
+
$_request = \Mage::getSingleton('tax/calculation')->getRateRequest();
|
222 |
+
|
223 |
+
$_request->setProductClassId($productData['tax_class_id']);
|
224 |
+
$currentTax = \Mage::getSingleton('tax/calculation')->getRate($_request);
|
225 |
+
|
226 |
+
$data[] = array(
|
227 |
+
'product_detail' => $productData,
|
228 |
+
'images' => $images,
|
229 |
+
'product_url' => $item->getProductUrl(),
|
230 |
+
'product_categories' => $categoryArray,
|
231 |
+
'currency' => \Mage::app()->getStore($shopId)->getCurrentCurrencyCode(),
|
232 |
+
'tax_rate' => $currentTax,
|
233 |
+
);
|
234 |
+
}
|
235 |
+
|
236 |
+
return $data;
|
237 |
+
}
|
238 |
+
}
|
lib/ac/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Extension.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PluginExtension\Multishop;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
5 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
6 |
+
use Itembase\Psdk\Core;
|
7 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Extension
|
11 |
+
*
|
12 |
+
* @package Itembase\PluginExtension\Multishop
|
13 |
+
* @author Serghei Ilin <si@itembase.biz>
|
14 |
+
* @copyright (c) 2015 itembase GmbH
|
15 |
+
*/
|
16 |
+
class Extension implements ExtensionInterface, ContainerAwareInterface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* {@inheritdoc}
|
20 |
+
*/
|
21 |
+
public function getExtensionName()
|
22 |
+
{
|
23 |
+
return 'multishop_magento';
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* {@inheritdoc}
|
28 |
+
*/
|
29 |
+
public function setContainer(ServiceContainer $container)
|
30 |
+
{
|
31 |
+
$container->bindService(
|
32 |
+
Core::SERVICE_MULTISHOP, new Multishop($container)
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
lib/ac/itembase/m1-ext-multishop/src/Itembase/PluginExtension/Multishop/Multishop.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PluginExtension\Multishop;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
5 |
+
use Itembase\Psdk\Core;
|
6 |
+
use Itembase\Psdk\Platform\MultiShop\MultishopAbstract;
|
7 |
+
use Itembase\Psdk\Platform\MultiShop\Shop;
|
8 |
+
use Itembase\Psdk\Platform\StorageInterface;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Multishop
|
12 |
+
*
|
13 |
+
* @package Itembase\PluginExtension\Multishop
|
14 |
+
* @author Serghei Ilin <si@itembase.biz>
|
15 |
+
* @copyright (c) 2015 itembase GmbH
|
16 |
+
*/
|
17 |
+
class Multishop extends MultishopAbstract
|
18 |
+
{
|
19 |
+
/** @var ServiceContainer */
|
20 |
+
private $container;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Multishop constructor.
|
24 |
+
*
|
25 |
+
* @param ServiceContainer $container
|
26 |
+
*/
|
27 |
+
public function __construct(ServiceContainer $container)
|
28 |
+
{
|
29 |
+
$this->container = $container;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* {@inheritdoc}
|
34 |
+
*/
|
35 |
+
protected function getShops()
|
36 |
+
{
|
37 |
+
$shopList = array();
|
38 |
+
|
39 |
+
/** @var StorageInterface $storage */
|
40 |
+
$storage = $this->container->getService(Core::SERVICE_STORAGE);
|
41 |
+
|
42 |
+
foreach (\Mage::app()->getStores() as $shop) {
|
43 |
+
$subShop = new Shop();
|
44 |
+
$storeId = $shop->getId();
|
45 |
+
|
46 |
+
$subShop->url = \Mage::getStoreConfig('web/unsecure/base_url', $storeId) !== null
|
47 |
+
? \Mage::getStoreConfig('web/unsecure/base_url', $storeId)
|
48 |
+
: \Mage::getStoreConfig('web/unsecure/base_url');
|
49 |
+
|
50 |
+
$subShop->url = rtrim($subShop->url, '/');
|
51 |
+
|
52 |
+
$subShop->name = \Mage::getStoreConfig('general/store_information/name', $storeId)
|
53 |
+
? \Mage::getStoreConfig('general/store_information/name', $storeId)
|
54 |
+
: $shop->getName();
|
55 |
+
|
56 |
+
$subShop->id = $storeId;
|
57 |
+
$subShop->currency = $shop->getCurrentCurrencyCode();
|
58 |
+
$subShop->defaultLanguage = substr(\Mage::getStoreConfig('general/locale/code', $storeId), 0, 2);
|
59 |
+
$subShop->timezone = \Mage::getStoreConfig('general/locale/timezone', $storeId);
|
60 |
+
|
61 |
+
$isRegistered = $storage->get(MultishopAbstract::REGISTERED_STORAGE_FLAG, $storeId);
|
62 |
+
|
63 |
+
if (!empty($isRegistered)) {
|
64 |
+
$subShop->registered = true;
|
65 |
+
}
|
66 |
+
|
67 |
+
$shopList[] = $subShop;
|
68 |
+
}
|
69 |
+
|
70 |
+
return $shopList;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* {@inheritdoc}
|
75 |
+
*/
|
76 |
+
public function isMultiShop()
|
77 |
+
{
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
}
|
lib/ac/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Extension.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PluginExtension\Platform;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
5 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
6 |
+
use Itembase\Psdk\Core;
|
7 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Extension
|
11 |
+
*
|
12 |
+
* @package Itembase\PluginExtension\Storage
|
13 |
+
* @author Serghei Ilin <si@itembase.biz>
|
14 |
+
* @copyright (c) 2015 itembase GmbH
|
15 |
+
*/
|
16 |
+
class Extension implements ExtensionInterface, ContainerAwareInterface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @param ServiceContainer $container
|
20 |
+
*/
|
21 |
+
public function setContainer(ServiceContainer $container)
|
22 |
+
{
|
23 |
+
$container->bindService(Core::SERVICE_PLATFORM, new Platform());
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getExtensionName()
|
30 |
+
{
|
31 |
+
return 'platform_extension';
|
32 |
+
}
|
33 |
+
}
|
lib/ac/itembase/m1-ext-platform/src/Itembase/PluginExtension/Platform/Platform.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PluginExtension\Platform;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Platform\PlatformInterface;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Platform
|
8 |
+
*
|
9 |
+
* @package Itembase\PluginExtension\Platform
|
10 |
+
* @author Serghei Ilin <si@itembase.biz>
|
11 |
+
* @copyright (c) 2015 itembase GmbH
|
12 |
+
*/
|
13 |
+
class Platform implements PlatformInterface
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* {@inheritdoc}
|
17 |
+
*/
|
18 |
+
public function getName()
|
19 |
+
{
|
20 |
+
return PlatformInterface::MAGENTO;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function getVersion()
|
27 |
+
{
|
28 |
+
$m = new \Mage();
|
29 |
+
return $m->getVersion();
|
30 |
+
}
|
31 |
+
}
|
lib/ac/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Extension.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PluginExtension\Storage;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
5 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
6 |
+
use Itembase\Psdk\Core;
|
7 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Extension
|
11 |
+
*
|
12 |
+
* @package Itembase\PluginExtension\Storage
|
13 |
+
* @author Serghei Ilin <si@itembase.biz>
|
14 |
+
* @copyright (c) 2015 itembase GmbH
|
15 |
+
*/
|
16 |
+
class Extension implements ExtensionInterface, ContainerAwareInterface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @param ServiceContainer $container
|
20 |
+
*/
|
21 |
+
public function setContainer(ServiceContainer $container)
|
22 |
+
{
|
23 |
+
$container->bindService(Core::SERVICE_STORAGE, new Storage());
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getExtensionName()
|
30 |
+
{
|
31 |
+
return 'storage_extension';
|
32 |
+
}
|
33 |
+
}
|
lib/ac/itembase/m1-ext-storage/src/Itembase/PluginExtension/Storage/Storage.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PluginExtension\Storage;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Platform\StorageInterface;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Storage
|
8 |
+
*
|
9 |
+
* Implementation of Itembase\Psdk\Platform\StorageInterface for Magento 1.7 - 1.9
|
10 |
+
*
|
11 |
+
* @package ItembaseExtension\Plugin\Storage
|
12 |
+
* @author Serghei Ilin <si@itembase.biz>
|
13 |
+
* @copyright (c) 2015 itembase GmbH
|
14 |
+
*/
|
15 |
+
class Storage implements StorageInterface
|
16 |
+
{
|
17 |
+
/** @var array $keyMap */
|
18 |
+
protected $keyMap;
|
19 |
+
|
20 |
+
/** @var string $keyspace */
|
21 |
+
protected $keyspace = "itembase/";
|
22 |
+
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function get($key, $shopId)
|
27 |
+
{
|
28 |
+
if (null == $shopId) {
|
29 |
+
$shopId = 0;
|
30 |
+
}
|
31 |
+
|
32 |
+
$key = $this->getConfigPath($key);
|
33 |
+
|
34 |
+
return \Mage::getStoreConfig($key, $shopId);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* {@inheritdoc}
|
39 |
+
*/
|
40 |
+
public function save($key, $value, $shopId)
|
41 |
+
{
|
42 |
+
if (null == $shopId) {
|
43 |
+
$shopId = 0;
|
44 |
+
}
|
45 |
+
|
46 |
+
$key = $this->getConfigPath($key);
|
47 |
+
|
48 |
+
\Mage::getConfig()->saveConfig($key, $value, 'stores', $shopId);
|
49 |
+
\Mage::getConfig()->reinit();
|
50 |
+
|
51 |
+
\Mage::app()->reinitStores();
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* {@inheritdoc}
|
56 |
+
*/
|
57 |
+
public function getShopIdBy($key, $value)
|
58 |
+
{
|
59 |
+
$key = $this->getConfigPath($key);
|
60 |
+
|
61 |
+
foreach (\Mage::app()->getStores() as $shop) {
|
62 |
+
$storeId = $shop->getId();
|
63 |
+
|
64 |
+
if (\Mage::getStoreConfig($key, $storeId) === $value) {
|
65 |
+
return $storeId;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
return null;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* {@inheritdoc}
|
74 |
+
*/
|
75 |
+
public function setKeyMapping($map)
|
76 |
+
{
|
77 |
+
$this->keyMap = $map;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* {@inheritdoc}
|
82 |
+
*/
|
83 |
+
public function getKeyMapping()
|
84 |
+
{
|
85 |
+
return $this->keyMap;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* {@inheritdoc}
|
90 |
+
*/
|
91 |
+
public function setKeyspace($keyspace)
|
92 |
+
{
|
93 |
+
$this->keyspace = $keyspace;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* {@inheritdoc}
|
98 |
+
*/
|
99 |
+
public function getKeyspace()
|
100 |
+
{
|
101 |
+
return $this->keyspace;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function delete($key, $shopId)
|
105 |
+
{
|
106 |
+
if (null == $shopId) {
|
107 |
+
$shopId = 0;
|
108 |
+
}
|
109 |
+
|
110 |
+
$key = $this->getConfigPath($key);
|
111 |
+
|
112 |
+
\Mage::getConfig()->deleteConfig($key, 'stores' , $shopId);
|
113 |
+
\Mage::getConfig()->reinit();
|
114 |
+
|
115 |
+
\Mage::app()->reinitStores();
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Returns key according to keymaps
|
120 |
+
*
|
121 |
+
* @param string $key
|
122 |
+
* @return string
|
123 |
+
*/
|
124 |
+
protected function getConfigPath($key)
|
125 |
+
{
|
126 |
+
if (!empty($this->keyMap[$key])) {
|
127 |
+
$key = $this->keyMap[$key];
|
128 |
+
} else {
|
129 |
+
$key = $this->keyspace . $key;
|
130 |
+
}
|
131 |
+
|
132 |
+
return $key;
|
133 |
+
}
|
134 |
+
}
|
lib/ac/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/Extension.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (C) 2016 itembase GmbH - All Rights Reserved
|
4 |
+
*/
|
5 |
+
|
6 |
+
namespace Itembase\PsdkExtension\Data;
|
7 |
+
|
8 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
9 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
10 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
11 |
+
use Itembase\Psdk\Http\Request;
|
12 |
+
use Itembase\Psdk\Http\RequestAwareInterface;
|
13 |
+
use Itembase\Psdk\Http\Response;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Class Extension
|
17 |
+
*
|
18 |
+
* @package Itembase\PsdkExtension\Data
|
19 |
+
*/
|
20 |
+
class Extension implements ExtensionInterface, ContainerAwareInterface, RequestAwareInterface
|
21 |
+
{
|
22 |
+
const DATA_FETCH_FETCHER = "data_fetch_fetcher";
|
23 |
+
|
24 |
+
/** @var ServiceContainer */
|
25 |
+
protected $container;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param ServiceContainer $container
|
29 |
+
*/
|
30 |
+
public function setContainer(ServiceContainer $container)
|
31 |
+
{
|
32 |
+
$this->container = $container;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function getExtensionName()
|
39 |
+
{
|
40 |
+
return 'data_fetch';
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getResponseType()
|
47 |
+
{
|
48 |
+
return $this->getExtensionName();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function getResponseVersion()
|
55 |
+
{
|
56 |
+
return '1.0';
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getRequestVersion()
|
63 |
+
{
|
64 |
+
return '1.0';
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param Request $request
|
69 |
+
* @param Response $response
|
70 |
+
*
|
71 |
+
* @throws \Exception
|
72 |
+
*/
|
73 |
+
public function handleRequest(Request $request, Response $response)
|
74 |
+
{
|
75 |
+
$supportedActions = array("getProfileData", "getBuyersData", "getTransactionsData", "getProductsData");
|
76 |
+
if (!$request->matchActions($supportedActions)) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
$this->container->verifyServices(array(
|
81 |
+
array(self::DATA_FETCH_FETCHER => 'Itembase\PsdkExtension\Data\FetcherInterface')
|
82 |
+
));
|
83 |
+
|
84 |
+
$fetcher = $this->container->getService(self::DATA_FETCH_FETCHER);
|
85 |
+
|
86 |
+
ini_set('max_execution_time', 0);
|
87 |
+
|
88 |
+
$params = $request->getIbParams();
|
89 |
+
$page = isset($params['ib_page']) ? (int)$params['ib_page'] : 1;
|
90 |
+
$limit = isset($params['ib_limit']) ? (int)$params['ib_limit'] : 50;
|
91 |
+
$minDateModified = isset($params['ib_min_date_modified']) ? (int)$params['ib_min_date_modified'] : null;
|
92 |
+
$minDateCreated = isset($params['ib_min_date_created']) ? (int)$params['ib_min_date_created'] : null;
|
93 |
+
$method = $request->getAction();
|
94 |
+
$rawData = call_user_func(
|
95 |
+
array($fetcher, $method),
|
96 |
+
$request->getShopId(),
|
97 |
+
$page,
|
98 |
+
$limit,
|
99 |
+
$minDateCreated,
|
100 |
+
$minDateModified
|
101 |
+
);
|
102 |
+
|
103 |
+
$response->setData($rawData);
|
104 |
+
}
|
105 |
+
}
|
lib/ac/itembase/psdk2-ext-data/src/Itembase/PsdkExtension/Data/FetcherInterface.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (C) 2016 itembase GmbH - All Rights Reserved
|
4 |
+
*/
|
5 |
+
|
6 |
+
namespace Itembase\PsdkExtension\Data;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Interface FetcherInterface
|
10 |
+
*
|
11 |
+
* @author Paweł Kubasiak <pk@itembase.biz>
|
12 |
+
*/
|
13 |
+
interface FetcherInterface
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Method to fetching all available raw shop profile data from the shop
|
17 |
+
*
|
18 |
+
* Function should return array with ALL available shop profile data which you can fetch from the shop.
|
19 |
+
* Fetched data must include (but not limited to) information about:
|
20 |
+
* - shop name
|
21 |
+
* - shop url
|
22 |
+
*
|
23 |
+
* @param string $shopId id of the shop if shop has multi-store options.
|
24 |
+
* @param int $page pagination parameter
|
25 |
+
* @param int $limit how many profiles fetch from database
|
26 |
+
* @param string $minDateCreated minimal date when the profile was created
|
27 |
+
* @param string $minDateUpdated minimal date when the profile was updated
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
public function getProfileData($shopId, $page, $limit, $minDateCreated, $minDateUpdated);
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Method to fetching all available raw buyer data from the shop
|
35 |
+
*
|
36 |
+
* Function should return array with ALL available shop buyer data which you can fetch from the shop.
|
37 |
+
* Fetched data must include (but not limited to) information about:
|
38 |
+
* - id (unique buyer id number)
|
39 |
+
* - email address
|
40 |
+
*
|
41 |
+
* @param string $shopId id of the shop if shop has multi-store options.
|
42 |
+
* @param int $page pagination parameter
|
43 |
+
* @param int $limit how many profiles fetch from database
|
44 |
+
* @param string $minDateCreated minimal date when the profile was created
|
45 |
+
* @param string $minDateUpdated minimal date when the profile was updated
|
46 |
+
*
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
public function getBuyersData($shopId, $page, $limit, $minDateCreated, $minDateUpdated);
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Method to fetching all available raw shop transaction data from the shop
|
53 |
+
*
|
54 |
+
* Function should return array with ALL available shop transaction data which you can fetch from the shop.
|
55 |
+
* Fetched data must include (but not limited to) information about:
|
56 |
+
* - id
|
57 |
+
* - created date
|
58 |
+
* - currency
|
59 |
+
* - total price
|
60 |
+
* - total price net
|
61 |
+
* - total tax price
|
62 |
+
* - transaction status
|
63 |
+
* - information about product: product url, created date, name, currency, price per unit,
|
64 |
+
* tax rate, product description, product categories, product images urls, stock information,
|
65 |
+
* - information about buyer: id, address email
|
66 |
+
*
|
67 |
+
* @param string $shopId id of the shop if shop has multi-store options.
|
68 |
+
* @param int $page pagination parameter
|
69 |
+
* @param int $limit how many profiles fetch from database
|
70 |
+
* @param string $minDateCreated minimal date when the profile was created
|
71 |
+
* @param string $minDateUpdated minimal date when the profile was updated
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function getTransactionsData($shopId, $page, $limit, $minDateCreated, $minDateUpdated);
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Method to fetching all available raw shop product data from the shop
|
79 |
+
*
|
80 |
+
* Function should return array with ALL available shop product data which you can fetch from the shop.
|
81 |
+
* Fetched data must include (but not limited to) information about:
|
82 |
+
* - product url
|
83 |
+
* - created date
|
84 |
+
* - currency
|
85 |
+
* - price per unit
|
86 |
+
* - tax rate
|
87 |
+
* - description
|
88 |
+
* - product categories
|
89 |
+
* - product images urls
|
90 |
+
* - stock information
|
91 |
+
*
|
92 |
+
* @param string $shopId id of the shop if shop has multi-store options.
|
93 |
+
* @param int $page pagination parameter
|
94 |
+
* @param int $limit how many profiles fetch from database
|
95 |
+
* @param string $minDateCreated minimal date when the profile was created
|
96 |
+
* @param string $minDateUpdated minimal date when the profile was updated
|
97 |
+
*
|
98 |
+
* @return array
|
99 |
+
*/
|
100 |
+
public function getProductsData($shopId, $page, $limit, $minDateCreated, $minDateUpdated);
|
101 |
+
}
|
lib/ac/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Extension.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PsdkExtension\RemoteFS;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
5 |
+
use Itembase\Psdk\Http\Request;
|
6 |
+
use Itembase\Psdk\Http\RequestAwareInterface;
|
7 |
+
use Itembase\Psdk\Http\Response;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Extension
|
11 |
+
*
|
12 |
+
* @package Itembase\PsdkExtension\RemoteFS
|
13 |
+
* @author Serghei Ilin <si@itembase.biz>
|
14 |
+
* @copyright (c) 2016 itembase GmbH
|
15 |
+
*/
|
16 |
+
class Extension implements ExtensionInterface, RequestAwareInterface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
public function getExtensionName()
|
22 |
+
{
|
23 |
+
return 'remotefs';
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param Request $request
|
28 |
+
* @param Response $response
|
29 |
+
*
|
30 |
+
* @throws \Exception
|
31 |
+
*/
|
32 |
+
public function handleRequest(Request $request, Response $response)
|
33 |
+
{
|
34 |
+
$supportedActions = array('rfs-limits', 'rfs-deploy', 'rfs-delete', 'rfs-rmdir');
|
35 |
+
|
36 |
+
if (!$request->matchActions($supportedActions)) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$fs = new Filesystem();
|
41 |
+
$fsResp = null;
|
42 |
+
|
43 |
+
switch ($request->getAction()) {
|
44 |
+
case 'rfs-limits':
|
45 |
+
$fsResp = array('limits' => $fs->getLimits());
|
46 |
+
break;
|
47 |
+
case 'rfs-deploy':
|
48 |
+
$fsResp = array('status_deploy' => $fs->upload());
|
49 |
+
break;
|
50 |
+
case 'rfs-delete':
|
51 |
+
$fsResp = array('status_delete' => $fs->delete());
|
52 |
+
break;
|
53 |
+
case 'rfs-rmdir':
|
54 |
+
$fsResp = array('status_delete_folder', $fs->deleteFolder());
|
55 |
+
break;
|
56 |
+
}
|
57 |
+
|
58 |
+
$response->setData($fsResp);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getResponseType()
|
65 |
+
{
|
66 |
+
return $this->getExtensionName();
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getResponseVersion()
|
73 |
+
{
|
74 |
+
return '1.0';
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function getRequestVersion()
|
81 |
+
{
|
82 |
+
return '1.0';
|
83 |
+
}
|
84 |
+
}
|
lib/ac/itembase/psdk2-ext-remotefs/src/Itembase/PsdkExtension/RemoteFS/Filesystem.php
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PsdkExtension\RemoteFS;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Filesystem
|
6 |
+
*
|
7 |
+
* @package Itembase\PsdkExtension\RemoteFS
|
8 |
+
* @author Serghei Ilin <si@itembase.biz>
|
9 |
+
* @copyright (c) 2016 itembase GmbH
|
10 |
+
*/
|
11 |
+
class Filesystem
|
12 |
+
{
|
13 |
+
/** @var string $lastError */
|
14 |
+
protected $lastError;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param $phpValue string
|
18 |
+
* @return int|string
|
19 |
+
*/
|
20 |
+
protected function calculateBytes($phpValue)
|
21 |
+
{
|
22 |
+
$val = trim($phpValue);
|
23 |
+
$last = strtolower($val[strlen($val) - 1]);
|
24 |
+
|
25 |
+
switch ($last) {
|
26 |
+
case 'k':
|
27 |
+
$val *= 1024;
|
28 |
+
break;
|
29 |
+
case 'm':
|
30 |
+
$val *= 1048576;
|
31 |
+
break;
|
32 |
+
case 'g':
|
33 |
+
$val *= 1073741824;
|
34 |
+
break;
|
35 |
+
}
|
36 |
+
|
37 |
+
return $val;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return array
|
42 |
+
* @throws \Exception
|
43 |
+
*/
|
44 |
+
public function getLimits()
|
45 |
+
{
|
46 |
+
if (strtolower($_SERVER['REQUEST_METHOD']) != "get") {
|
47 |
+
throw new \Exception("Unsupported request method!");
|
48 |
+
}
|
49 |
+
|
50 |
+
$fileSize = ini_get("upload_max_filesize");
|
51 |
+
$postSize = ini_get("post_max_size");
|
52 |
+
|
53 |
+
return array(
|
54 |
+
'file_size' => $this->calculateBytes($fileSize),
|
55 |
+
'post_size' => $this->calculateBytes($postSize),
|
56 |
+
'max_files' => intval(ini_get("max_file_uploads"))
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return array
|
62 |
+
* @throws \Exception
|
63 |
+
*/
|
64 |
+
public function upload()
|
65 |
+
{
|
66 |
+
if (strtolower($_SERVER['REQUEST_METHOD']) != "post") {
|
67 |
+
throw new \Exception("Unsupported request method!");
|
68 |
+
}
|
69 |
+
|
70 |
+
if (empty($_FILES)) {
|
71 |
+
throw new \Exception("No files sent!");
|
72 |
+
}
|
73 |
+
|
74 |
+
if (empty($_POST['locations'])) {
|
75 |
+
throw new \Exception("No locations sent!");
|
76 |
+
}
|
77 |
+
|
78 |
+
$locations = $_POST['locations'];
|
79 |
+
$statuses = array();
|
80 |
+
$currState = -1;
|
81 |
+
$defaultPermission = fileperms($_SERVER["DOCUMENT_ROOT"]);
|
82 |
+
|
83 |
+
foreach ($_FILES as $hash => $file) {
|
84 |
+
$currState++;
|
85 |
+
$statuses[$currState] = array(
|
86 |
+
'path' => '',
|
87 |
+
'hash' => $hash,
|
88 |
+
'success' => false,
|
89 |
+
'reason' => null
|
90 |
+
);
|
91 |
+
|
92 |
+
if (empty($locations[$hash])) {
|
93 |
+
$statuses[$currState]['reason'] = 'Target location was not passed';
|
94 |
+
continue;
|
95 |
+
}
|
96 |
+
|
97 |
+
$statuses[$currState]['path'] = rtrim($_SERVER["DOCUMENT_ROOT"], "/") . "/" . ltrim($locations[$hash], "/");
|
98 |
+
|
99 |
+
if (!is_uploaded_file($file['tmp_name'])) {
|
100 |
+
$statuses[$currState]['reason'] = 'Issues with uploading file! is_uploaded_file() returned false value';
|
101 |
+
continue;
|
102 |
+
}
|
103 |
+
|
104 |
+
$targetDir = dirname($locations[$hash]);
|
105 |
+
|
106 |
+
if (!file_exists($targetDir)) {
|
107 |
+
set_error_handler(array($this, 'onWarning'));
|
108 |
+
$status = mkdir($targetDir, $defaultPermission, true);
|
109 |
+
restore_error_handler();
|
110 |
+
|
111 |
+
if (!$status) {
|
112 |
+
$statuses[$currState]['reason'] = $this->lastError;
|
113 |
+
continue;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
$this->lastError = null;
|
118 |
+
|
119 |
+
set_error_handler(array($this, 'onWarning'));
|
120 |
+
$moveResult = move_uploaded_file($file['tmp_name'], $statuses[$currState]['path']);
|
121 |
+
restore_error_handler();
|
122 |
+
|
123 |
+
if (!$moveResult) {
|
124 |
+
if (null == $this->lastError) {
|
125 |
+
$statuses[$currState]['reason'] = "Unable to store uploaded file to " . $locations[$hash];
|
126 |
+
} else {
|
127 |
+
$statuses[$currState]['reason'] = $this->lastError;
|
128 |
+
}
|
129 |
+
|
130 |
+
continue;
|
131 |
+
}
|
132 |
+
|
133 |
+
$statuses[$currState]['success'] = true;
|
134 |
+
}
|
135 |
+
|
136 |
+
return $statuses;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @return array
|
141 |
+
* @throws \Exception
|
142 |
+
*/
|
143 |
+
public function delete()
|
144 |
+
{
|
145 |
+
if (strtolower($_SERVER['REQUEST_METHOD']) != "post") {
|
146 |
+
throw new \Exception("Unsupported request method!");
|
147 |
+
}
|
148 |
+
|
149 |
+
if (empty($_POST['fileList'])) {
|
150 |
+
throw new \Exception("File list is not provided!");
|
151 |
+
}
|
152 |
+
|
153 |
+
$statuses = array();
|
154 |
+
$currentStatus = -1;
|
155 |
+
|
156 |
+
foreach ($_POST['fileList'] as $hash => $filePath) {
|
157 |
+
$currentStatus++;
|
158 |
+
$statuses[$currentStatus] = array(
|
159 |
+
'path' => $filePath,
|
160 |
+
'hash' => $hash,
|
161 |
+
'success' => false,
|
162 |
+
'reason' => null
|
163 |
+
);
|
164 |
+
|
165 |
+
if (!file_exists($filePath)) {
|
166 |
+
$statuses[$currentStatus] = "File doesn't exists";
|
167 |
+
continue;
|
168 |
+
}
|
169 |
+
|
170 |
+
set_error_handler(array($this, 'onWarning'));
|
171 |
+
$isDeleted = unlink($filePath);
|
172 |
+
restore_error_handler();
|
173 |
+
|
174 |
+
if (!$isDeleted) {
|
175 |
+
$statuses[$currentStatus] = $this->lastError;
|
176 |
+
continue;
|
177 |
+
}
|
178 |
+
|
179 |
+
$statuses[$currentStatus]['success'] = true;
|
180 |
+
}
|
181 |
+
|
182 |
+
return $statuses;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @throws \Exception
|
187 |
+
*/
|
188 |
+
public function deleteFolder()
|
189 |
+
{
|
190 |
+
if (strtolower($_SERVER['REQUEST_METHOD']) != "post") {
|
191 |
+
throw new \Exception("Unsupported request method!");
|
192 |
+
}
|
193 |
+
|
194 |
+
$statuses = array();
|
195 |
+
$currentStatus = -1;
|
196 |
+
|
197 |
+
foreach ($_POST['dirList'] as $hash => $dirPath) {
|
198 |
+
$currentStatus++;
|
199 |
+
$statuses[$currentStatus] = array(
|
200 |
+
'path' => $dirPath,
|
201 |
+
'hash' => $hash,
|
202 |
+
'success' => false,
|
203 |
+
'reason' => null
|
204 |
+
);
|
205 |
+
|
206 |
+
if (!is_dir($dirPath)) {
|
207 |
+
$statuses[$currentStatus]['reason'] = "Provided path is not a directory";
|
208 |
+
continue;
|
209 |
+
}
|
210 |
+
|
211 |
+
$this->removeDirectory($dirPath);
|
212 |
+
|
213 |
+
$statuses[$currentStatus]['success'] = true;
|
214 |
+
}
|
215 |
+
|
216 |
+
return $statuses;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* @param $path
|
221 |
+
*/
|
222 |
+
protected function removeDirectory($path)
|
223 |
+
{
|
224 |
+
if (!is_dir($path)) {
|
225 |
+
return;
|
226 |
+
}
|
227 |
+
|
228 |
+
$objects = scandir($path);
|
229 |
+
|
230 |
+
foreach ($objects as $object) {
|
231 |
+
if ($object != "." && $object != "..") {
|
232 |
+
if (filetype($path . "/" . $object) == "dir") {
|
233 |
+
$this->removeDirectory($path . "/" . $object);
|
234 |
+
} else {
|
235 |
+
unlink($path . "/" . $object);
|
236 |
+
}
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
reset($objects);
|
241 |
+
rmdir($path);
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Custom PHP error handling
|
246 |
+
*
|
247 |
+
* @param $errno int
|
248 |
+
* @param $errstr string
|
249 |
+
*/
|
250 |
+
public function onWarning($errno, $errstr)
|
251 |
+
{
|
252 |
+
$this->lastError = sprintf("%s (%d)", $errstr, $errno);
|
253 |
+
}
|
254 |
+
}
|
lib/ac/itembase/psdk2-ext-signup/src/Itembase/PsdkExtension/Signup/Extension.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PsdkExtension\Signup;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
5 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
6 |
+
use Itembase\Psdk\Core;
|
7 |
+
use Itembase\Psdk\Core\OAuthClient;
|
8 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
9 |
+
use Itembase\Psdk\Http\HttpClient;
|
10 |
+
use Itembase\Psdk\Http\Request;
|
11 |
+
use Itembase\Psdk\Http\RequestAwareInterface;
|
12 |
+
use Itembase\Psdk\Http\Response;
|
13 |
+
use Itembase\Psdk\Platform\MultiShop\Shop;
|
14 |
+
use Itembase\Psdk\Platform\StorageInterface;
|
15 |
+
use Itembase\Psdk\Platform\MultiShop\MultishopAbstract;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class Extension
|
19 |
+
*
|
20 |
+
* @package Itembase\PsdkExtension\Signup
|
21 |
+
* @author Serghei Ilin <si@itembase.biz>
|
22 |
+
* @copyright (c) 2016 itembase GmbH
|
23 |
+
*/
|
24 |
+
class Extension implements ExtensionInterface, RequestAwareInterface, ContainerAwareInterface
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* @var array
|
28 |
+
*
|
29 |
+
* Shop information; in case of multi-shop - several elements will be in array
|
30 |
+
*/
|
31 |
+
protected $shops = array();
|
32 |
+
|
33 |
+
/** @var ServiceContainer */
|
34 |
+
protected $container;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param ServiceContainer $container
|
38 |
+
*/
|
39 |
+
public function setContainer(ServiceContainer $container)
|
40 |
+
{
|
41 |
+
$this->container = $container;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function getExtensionName()
|
48 |
+
{
|
49 |
+
return 'signup';
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getResponseType()
|
56 |
+
{
|
57 |
+
return $this->getExtensionName();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getResponseVersion()
|
64 |
+
{
|
65 |
+
return '1.0';
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function getRequestVersion()
|
72 |
+
{
|
73 |
+
return '1.0';
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @param Request $request
|
78 |
+
* @param Response $response
|
79 |
+
*
|
80 |
+
* @throws \Exception
|
81 |
+
*/
|
82 |
+
public function handleRequest(Request $request, Response $response)
|
83 |
+
{
|
84 |
+
if (!$request->matchActions(array('signup'), false)) {
|
85 |
+
return;
|
86 |
+
}
|
87 |
+
$client = new HttpClient();
|
88 |
+
$details = $client->sendData(ITEMBASE_PLUGIN_SERVICE . '/signup/client-details/' . $request->getToken());
|
89 |
+
$credentials = json_decode($details, true);
|
90 |
+
$keys = array(
|
91 |
+
'api_key' => $credentials['api_key'],
|
92 |
+
'secret_key' => $credentials['secret'],
|
93 |
+
'shop_id' => $credentials['shop_id'],
|
94 |
+
);
|
95 |
+
if (empty($keys['api_key']) || empty($keys['secret_key']) || empty($keys['shop_id'])) {
|
96 |
+
$response->add('status', 'failed');
|
97 |
+
$response->add('reason', 'Keys are empty: ' . print_r($keys, true));
|
98 |
+
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
/** @var StorageInterface $storage */
|
102 |
+
$storage = $this->container->getService(Core::SERVICE_STORAGE);
|
103 |
+
$storage->save(MultishopAbstract::REGISTERED_STORAGE_FLAG, true, $keys['shop_id']);
|
104 |
+
$storage->save(OAuthClient::STORAGE_API_KEY, $keys['api_key'], $keys['shop_id']);
|
105 |
+
$storage->save(OAuthClient::STORAGE_API_SECRET, $keys['secret_key'], $keys['shop_id']);
|
106 |
+
$response->add('status', 'success');
|
107 |
+
$response->add('reason', sprintf("Shop was successfully registered"));
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Return html code of the registration page.
|
112 |
+
*
|
113 |
+
* @param string $redirectUri Full URL where itembase backend can redirect user after signup on server
|
114 |
+
* @param string $language ISO 639-1 language code (2-letter for example 'en')
|
115 |
+
* @return string html code of the signup page to the itembase.com
|
116 |
+
*/
|
117 |
+
public function htmlSignupPage($redirectUri, $language = 'en')
|
118 |
+
{
|
119 |
+
if (!defined('ITEMBASE_SELFSERVICE_URL')) {
|
120 |
+
define('ITEMBASE_SELFSERVICE_URL', 'https://selfservice.itembase.com');
|
121 |
+
}
|
122 |
+
|
123 |
+
if (!defined('ITEMBASE_EMBEDDED_TEMPLATE')) {
|
124 |
+
define('ITEMBASE_EMBEDDED_TEMPLATE', 'https://deliver-static-d1.itembase.com/embed/signup');
|
125 |
+
}
|
126 |
+
|
127 |
+
if (defined('ITEMBASE_RETURN_URL') && !empty(ITEMBASE_RETURN_URL)) {
|
128 |
+
$redirectUri = ITEMBASE_RETURN_URL;
|
129 |
+
}
|
130 |
+
|
131 |
+
if (empty($language)) {
|
132 |
+
$language = 'en';
|
133 |
+
}
|
134 |
+
|
135 |
+
$atLeastOne = false;
|
136 |
+
$tplComponents = array();
|
137 |
+
$shops = $this->container->getService(Core::SERVICE_MULTISHOP)->getList();
|
138 |
+
$content = "";
|
139 |
+
$templateUrl = sprintf(
|
140 |
+
"%s?lang=%s&platform=%s",
|
141 |
+
ITEMBASE_EMBEDDED_TEMPLATE,
|
142 |
+
$language,
|
143 |
+
$this->container->getService(Core::SERVICE_PLATFORM)->getName()
|
144 |
+
);
|
145 |
+
|
146 |
+
try {
|
147 |
+
$client = new HttpClient();
|
148 |
+
$response = $client->sendData($templateUrl);
|
149 |
+
$tplComponents = json_decode($response, true);
|
150 |
+
} catch (\Exception $ex) {
|
151 |
+
$this->container->getService('logger')->log(\Itembase\Psdk\Core\Logger::IB_LOG_ERR, $ex);
|
152 |
+
}
|
153 |
+
|
154 |
+
if (!empty($shops)) {
|
155 |
+
/** @var Shop $shop */
|
156 |
+
foreach ($shops as $shop) {
|
157 |
+
$backToShop = $redirectUri;
|
158 |
+
|
159 |
+
if ($shop->registered) {
|
160 |
+
$atLeastOne = true;
|
161 |
+
$content .= str_replace('%name%', $shop->name, $tplComponents['shop_connected_tpl']);
|
162 |
+
continue;
|
163 |
+
}
|
164 |
+
|
165 |
+
$njordUrl = sprintf("%s/v1/tokens", ITEMBASE_SELFSERVICE_URL);
|
166 |
+
$njordReq = array(
|
167 |
+
'component_ids' => array(ITEMBASE_VARIANT_ID),
|
168 |
+
'action' => 'create',
|
169 |
+
'additional_parameters' => array(
|
170 |
+
'build' => ITEMBASE_PLUGIN_BUILD,
|
171 |
+
'shop_url' => $shop->url,
|
172 |
+
'shop_id' => $shop->id,
|
173 |
+
'shop_name' => $shop->name,
|
174 |
+
'shop_lang' => $shop->defaultLanguage,
|
175 |
+
'return_uri' => $backToShop,
|
176 |
+
),
|
177 |
+
);
|
178 |
+
|
179 |
+
if (defined('ITEMBASE_BRANDED_ID')) {
|
180 |
+
$njordReq['client_id'] = ITEMBASE_BRANDED_ID;
|
181 |
+
$njordReq['enable_whisper_signup'] = true;
|
182 |
+
}
|
183 |
+
|
184 |
+
try {
|
185 |
+
$njordClient = new HttpClient();
|
186 |
+
|
187 |
+
$njordToken = $njordClient->sendJsonData(
|
188 |
+
$njordUrl,
|
189 |
+
$njordReq,
|
190 |
+
array("Content-type: application/json")
|
191 |
+
);
|
192 |
+
|
193 |
+
$njordToken = json_decode($njordToken, true);
|
194 |
+
|
195 |
+
$backToShop .= (false === strpos($backToShop, '?')) ? '?' : '&';
|
196 |
+
|
197 |
+
if (!empty($njordToken['uri'])) {
|
198 |
+
$backToShop .= 'success=Connection+successful';
|
199 |
+
$backToShop = sprintf("%s?redirect_uri=%s", $njordToken['uri'], urlencode($backToShop));
|
200 |
+
} else {
|
201 |
+
$backToShop .= 'error=We+have+some+problem.+Please+try+again+later';
|
202 |
+
}
|
203 |
+
} catch (\Exception $ex) {
|
204 |
+
$backToShop .= 'error=We+have+some+problem.+Please+try+again+later';
|
205 |
+
}
|
206 |
+
|
207 |
+
$content .= str_replace(
|
208 |
+
array(
|
209 |
+
'%signup_url%',
|
210 |
+
'%name%'
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
$backToShop,
|
214 |
+
$shop->name
|
215 |
+
),
|
216 |
+
$tplComponents['shop_tpl']
|
217 |
+
);
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
return str_replace(
|
222 |
+
array(
|
223 |
+
'<shops_placeholder/>',
|
224 |
+
'<button_placeholder/>'
|
225 |
+
),
|
226 |
+
array(
|
227 |
+
$content,
|
228 |
+
($atLeastOne) ? $tplComponents['button_tpl'] : $tplComponents['no_button_tpl']
|
229 |
+
),
|
230 |
+
$tplComponents['base_tpl']
|
231 |
+
);
|
232 |
+
}
|
233 |
+
}
|
lib/ac/itembase/psdk2-ext-sysinfo/src/Itembase/PsdkExtension/SysInfo/Extension.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (C) 2015 itembase GmbH - All Rights Reserved
|
4 |
+
*/
|
5 |
+
|
6 |
+
namespace Itembase\PsdkExtension\SysInfo;
|
7 |
+
|
8 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
9 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
10 |
+
use Itembase\Psdk\Core;
|
11 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
12 |
+
use Itembase\Psdk\Http\Request;
|
13 |
+
use Itembase\Psdk\Http\RequestAwareInterface;
|
14 |
+
use Itembase\Psdk\Http\Response;
|
15 |
+
use Itembase\Psdk\Platform\MultiShop\MultishopAbstract;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class Extension
|
19 |
+
*
|
20 |
+
* @package Itembase\PsdkExtension\SysInfo
|
21 |
+
* @author Serghei Ilin <si@itembase.biz>
|
22 |
+
* @copyright (c) 2016 itembase GmbH
|
23 |
+
*/
|
24 |
+
class Extension implements ExtensionInterface, ContainerAwareInterface, RequestAwareInterface
|
25 |
+
{
|
26 |
+
/** @var ServiceContainer $serviceContainer */
|
27 |
+
protected $serviceContainer;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getExtensionName()
|
33 |
+
{
|
34 |
+
return 'sysinfo';
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param ServiceContainer $container
|
39 |
+
*/
|
40 |
+
public function setContainer(ServiceContainer $container)
|
41 |
+
{
|
42 |
+
$this->serviceContainer = $container;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getResponseType()
|
49 |
+
{
|
50 |
+
return $this->getExtensionName();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getResponseVersion()
|
57 |
+
{
|
58 |
+
return '1.0';
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* {@inheritdoc}
|
63 |
+
*/
|
64 |
+
public function getRequestVersion()
|
65 |
+
{
|
66 |
+
return '1.0';
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param Request $request
|
71 |
+
* @param Response $response
|
72 |
+
*
|
73 |
+
* @throws \Exception
|
74 |
+
*/
|
75 |
+
public function handleRequest(Request $request, Response $response)
|
76 |
+
{
|
77 |
+
if (!$request->matchActions(array("getPluginData", "sysinfo"))) {
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
+
$platform = $this->serviceContainer->getService(Core::SERVICE_PLATFORM);
|
82 |
+
|
83 |
+
$response->add("platform", $platform->getName());
|
84 |
+
$response->add("platform_version", $platform->getVersion());
|
85 |
+
$response->add("plugin_build", ITEMBASE_PLUGIN_BUILD);
|
86 |
+
$response->add("plugin_version", "5.0");
|
87 |
+
$response->add("vendor_path", ITEMBASE_VENDOR_DIR);
|
88 |
+
$response->add('php_info', $this->phpinfoToArray());
|
89 |
+
|
90 |
+
$index = 0;
|
91 |
+
$serviceList = array();
|
92 |
+
$extensionList = array();
|
93 |
+
|
94 |
+
foreach ($this->serviceContainer->listServices() as $tag) {
|
95 |
+
$service = $this->serviceContainer->getService($tag);
|
96 |
+
|
97 |
+
if ($service instanceof ExtensionInterface && $service instanceof RequestAwareInterface) {
|
98 |
+
$extensionList[$index++] = array(
|
99 |
+
'name' => $service->getExtensionName(),
|
100 |
+
'tag' => $tag,
|
101 |
+
'request_version' => $service->getRequestVersion(),
|
102 |
+
'response_version' => $service->getResponseVersion(),
|
103 |
+
);
|
104 |
+
} else {
|
105 |
+
$serviceList[] = $tag;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
$response->add("services", $serviceList);
|
110 |
+
$response->add("extensions", $extensionList);
|
111 |
+
|
112 |
+
if ($this->serviceContainer->hasService('multishop')) {
|
113 |
+
/** @var MultishopAbstract $multiShop */
|
114 |
+
$multiShop = $this->serviceContainer->getService('multishop');
|
115 |
+
|
116 |
+
$response->add('support_multi_shop', $multiShop->isMultiShop());
|
117 |
+
$response->add('shops', $multiShop->getList());
|
118 |
+
} else {
|
119 |
+
$response->add('support_multi_shop', false);
|
120 |
+
$response->add('shops', null);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Handle phpinfo output and translate it to array
|
126 |
+
*
|
127 |
+
* @return array|mixed
|
128 |
+
*/
|
129 |
+
private function phpinfoToArray()
|
130 |
+
{
|
131 |
+
ob_start();
|
132 |
+
phpinfo(INFO_MODULES);
|
133 |
+
|
134 |
+
$pi = preg_replace(
|
135 |
+
array(
|
136 |
+
'#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
|
137 |
+
'#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
|
138 |
+
"#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%',
|
139 |
+
'#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
|
140 |
+
.'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
|
141 |
+
'#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
|
142 |
+
'#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
|
143 |
+
"# +#", '#<tr>#', '#</tr>#'
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
'$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
|
147 |
+
'<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'.
|
148 |
+
"\n".'<tr><td>PHP Egg</td><td>$1</td></tr>',
|
149 |
+
'<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
|
150 |
+
'<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
|
151 |
+
'<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'
|
152 |
+
),
|
153 |
+
ob_get_clean()
|
154 |
+
);
|
155 |
+
|
156 |
+
$sections = explode('<h2>', strip_tags($pi, '<h2><th><td>'));
|
157 |
+
unset($sections[0]);
|
158 |
+
|
159 |
+
$pi = array();
|
160 |
+
foreach($sections as $section) {
|
161 |
+
$sectionName = substr($section, 0, strpos($section, '</h2>'));
|
162 |
+
|
163 |
+
preg_match_all(
|
164 |
+
'#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
|
165 |
+
$section,
|
166 |
+
$matches,
|
167 |
+
PREG_SET_ORDER
|
168 |
+
);
|
169 |
+
|
170 |
+
$sectionName = strtolower(str_replace(' ', '_', $sectionName));
|
171 |
+
|
172 |
+
foreach($matches as $match) {
|
173 |
+
$sectionKey = strtolower(str_replace(' ', '_', $match[1]));
|
174 |
+
|
175 |
+
if (!isset($match[3]) || $match[2] == $match[3]) {
|
176 |
+
$pi[$sectionName][$sectionKey] = $match[2];
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
return $pi;
|
182 |
+
}
|
183 |
+
}
|
lib/ac/itembase/psdk2/LICENSE.txt
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright 2015 itembase GmbH
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Container/ContainerAwareInterface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Container;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface ContainerAwareInterface
|
6 |
+
*
|
7 |
+
* If some service requires service container object - he need to implement ContainerAwareInterface interface.
|
8 |
+
* Using 'setContainer()' setter ServiceContainer will be injected to class.
|
9 |
+
*
|
10 |
+
* @package Itembase\Psdk\Container
|
11 |
+
* @author Serghei Ilin <si@itembase.biz>
|
12 |
+
* @copyright (c) 2016 itembase GmbH
|
13 |
+
*/
|
14 |
+
interface ContainerAwareInterface
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Setter-based injection of the ServiceContainer object.
|
18 |
+
*
|
19 |
+
* @param ServiceContainer $container
|
20 |
+
*
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
public function setContainer(ServiceContainer $container);
|
24 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Container/ServiceContainer.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Container;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class ServiceContainer
|
6 |
+
*
|
7 |
+
* ServiceContainer class can be named as repository named (tagged) services. It allows to share class instances based
|
8 |
+
* on tags which implements passive dependency injection - developer should take care of getting necessary service from
|
9 |
+
* the container.
|
10 |
+
*
|
11 |
+
* @package Itembase\Psdk\Container
|
12 |
+
* @author Serghei Ilin <si@itembase.biz>
|
13 |
+
* @copyright (c) 2016 itembase GmbH
|
14 |
+
*/
|
15 |
+
class ServiceContainer
|
16 |
+
{
|
17 |
+
/** @var array $container */
|
18 |
+
private $container;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* ItembaseServiceContainer constructor.
|
22 |
+
*/
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
$this->container["service_container"] = $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Adding/replacing some instance object with specific tag/alias
|
30 |
+
*
|
31 |
+
* @param string $tag
|
32 |
+
* @param mixed $object
|
33 |
+
*
|
34 |
+
* @throws \Exception
|
35 |
+
*/
|
36 |
+
public function bindService($tag, $object)
|
37 |
+
{
|
38 |
+
// checking if someone is adding container aware object
|
39 |
+
if (is_object($object) && $object instanceof ContainerAwareInterface) {
|
40 |
+
$object->setContainer($this);
|
41 |
+
}
|
42 |
+
|
43 |
+
$this->container[$tag] = $object;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Check if tag/alias exists in container
|
48 |
+
*
|
49 |
+
* @param string $tag
|
50 |
+
*
|
51 |
+
* @return bool
|
52 |
+
*/
|
53 |
+
public function hasService($tag)
|
54 |
+
{
|
55 |
+
if (empty($this->container[$tag])) {
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
|
59 |
+
return true;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Extended and stricter version of hasService() method. Verifies if in container exists specific services (by tags)
|
64 |
+
* and (if needed) they are instances of some specific class/interface.
|
65 |
+
*
|
66 |
+
* $tags should always be array, otherwise method will throw \Exception. Array can consist of strings (tags names)
|
67 |
+
* or contains assoc arrays what will mean for verifyServices() to check specific service if it's instance of
|
68 |
+
* specified class or interface. So $tags can be:
|
69 |
+
*
|
70 |
+
* array(
|
71 |
+
* 'logger',
|
72 |
+
* array('storage' => 'Itembase\Psdk\StorageInterface')
|
73 |
+
* )
|
74 |
+
*
|
75 |
+
* If one of the service wasn't found or doesn't implement necessary interface or is not instance of some class -
|
76 |
+
* \Exception will thrown. Otherwise nothing will happened.
|
77 |
+
*
|
78 |
+
* @param string|array $tags
|
79 |
+
*
|
80 |
+
* @throws \Exception
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function verifyServices($tags)
|
85 |
+
{
|
86 |
+
if (empty($tags)) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
if (!is_array($tags)) {
|
91 |
+
throw new \Exception("Dependecy tags should be provided as an array!");
|
92 |
+
}
|
93 |
+
|
94 |
+
foreach ($tags as $tag) {
|
95 |
+
if (is_string($tag)) {
|
96 |
+
if (!$this->hasService($tag)) {
|
97 |
+
throw new \Exception("Dependency service " . $tag . " was not found!");
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
if (is_array($tag)) {
|
102 |
+
list($tagName, $interface) = each($tag);
|
103 |
+
|
104 |
+
if (!interface_exists($interface) && !class_exists($interface)) {
|
105 |
+
throw new \Exception(
|
106 |
+
"Interface/class " . $interface . " cannot be found to validate service " . $tagName . "!"
|
107 |
+
);
|
108 |
+
}
|
109 |
+
|
110 |
+
if (!$this->hasService($tagName)) {
|
111 |
+
throw new \Exception("Dependency service " . $tagName . " was not found!");
|
112 |
+
}
|
113 |
+
|
114 |
+
$service = $this->getService($tagName);
|
115 |
+
|
116 |
+
if (!$service instanceof $interface) {
|
117 |
+
throw new \Exception("Dependency service " . $tagName . " (class: " . get_class($service)
|
118 |
+
. ") is not implementing " . $interface);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Returns instance by tag
|
126 |
+
*
|
127 |
+
* @param string $tag
|
128 |
+
*
|
129 |
+
* @return null|mixed
|
130 |
+
*/
|
131 |
+
public function getService($tag)
|
132 |
+
{
|
133 |
+
if ($this->hasService($tag)) {
|
134 |
+
return $this->container[$tag];
|
135 |
+
}
|
136 |
+
|
137 |
+
return null;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Get list of tags in container
|
142 |
+
*
|
143 |
+
* @return array
|
144 |
+
*/
|
145 |
+
public function listServices()
|
146 |
+
{
|
147 |
+
return array_keys($this->container);
|
148 |
+
}
|
149 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Core.php
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Itembase\Psdk is a core namespace of plugin PluginSdk. It's developed and maintained by itembase GmbH developers ONLY!
|
4 |
+
* During plugin development based on that PluginSdk developer MUST NOT modify PluginSdk!
|
5 |
+
*/
|
6 |
+
namespace Itembase\Psdk;
|
7 |
+
|
8 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
9 |
+
use Itembase\Psdk\Core\ExceptionHandler;
|
10 |
+
use Itembase\Psdk\Core\Logger;
|
11 |
+
use Itembase\Psdk\Core\OAuthClient;
|
12 |
+
use Itembase\Psdk\Event\EventDispatcher;
|
13 |
+
use Itembase\Psdk\Extension\ExtensionsLoader;
|
14 |
+
use Itembase\Psdk\Http\HttpClient;
|
15 |
+
use Itembase\Psdk\Http\HttpHandler;
|
16 |
+
use Itembase\PsdkExtension\Registration\PingHandler;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Class Core
|
20 |
+
*
|
21 |
+
* Core class is an entry point for the PluginSdk. It instantiate necessary classes like EventDispatcher, ServiceContainer,
|
22 |
+
* ExceptionHandler, HttpHandler etc, checks required services to be presented in ServiceContainer, triggering events
|
23 |
+
* and finalize PluginSdk lifecycle.
|
24 |
+
*
|
25 |
+
* The sequence of Core class methods calls to fulfill PluginSdk lifecycle:
|
26 |
+
*
|
27 |
+
* 1. Itembase\Psdk\Core object creation
|
28 |
+
* 2. init() - initialization of PluginSdk and extensions
|
29 |
+
* 3. run() - run business logic of the extensions
|
30 |
+
* 4. done() - finishing work of the plugin
|
31 |
+
*
|
32 |
+
* All 3 methods must be executed, they need to be called in listed order or it's possible to use the following:
|
33 |
+
*
|
34 |
+
* 1. Itembase\Psdk\Core object creation
|
35 |
+
* 2. runAll() - executes init() run() and done() methods in right order at once
|
36 |
+
*
|
37 |
+
* Methods are splitted to give plugin developer possibility to do necessary actions between these calls if necessary.
|
38 |
+
* There might be need to postpone, for example, init() call because of some platform architectural processes.
|
39 |
+
*
|
40 |
+
* Core requires some configuration. Necessary constants which needs to be defined are listed and described in
|
41 |
+
* config.php.dist file. Plugin developer should decide what is the best place for defining these constants in platform.
|
42 |
+
* PluginSdk doesn't force to specify where that file is stored. It's developer duty to load/define these constants in
|
43 |
+
* appropriate place/way in platform specific implementation.
|
44 |
+
*
|
45 |
+
* Class also define (if previously was not defined) the following constants:
|
46 |
+
*
|
47 |
+
* - ITEMBASE_PLUGIN_BUILD: in order to request plugin service for configuration of the specific plugin (version,
|
48 |
+
* platform etc); (!) IMPORTANT. MUST be defined in platform plugin!
|
49 |
+
*
|
50 |
+
* - ITEMBASE_VENDOR_DIR: set the vendor where all extensions and actual SDK is located after composer install/update;
|
51 |
+
* developer can change it in case of custom place of the vendor dir (class assume standart composer behaviour of
|
52 |
+
* placing current file 6 level deep from the actual vendor root folder)
|
53 |
+
*
|
54 |
+
* (!) IMPORTANT. If you want to change values of these constants you must define them BEFORE instantiating
|
55 |
+
* Itembase\Psdk\Core object!
|
56 |
+
*
|
57 |
+
* @package Itembase\Psdk
|
58 |
+
* @author Serghei Ilin <si@itembase.biz>
|
59 |
+
* @copyright (c) 2016 itembase GmbH
|
60 |
+
*/
|
61 |
+
class Core
|
62 |
+
{
|
63 |
+
const OAUTH_SERVER_URL = 'https://accounts.itembase.com';
|
64 |
+
const PLUGIN_SERVER_URL = 'https://services.itembase.com/connectors/plugin';
|
65 |
+
|
66 |
+
const EVENT_INITIALIZED = 'initialized';
|
67 |
+
const EVENT_EXCEPTION = 'exception';
|
68 |
+
const EVENT_RUN = 'run';
|
69 |
+
const EVENT_DONE = 'done';
|
70 |
+
|
71 |
+
// constant list of the core/mandatory services in service container
|
72 |
+
const SERVICE_STORAGE = "storage";
|
73 |
+
const SERVICE_MULTISHOP = "multishop";
|
74 |
+
const SERVICE_LOGGER = "logger";
|
75 |
+
const SERVICE_OAUTH_CLIENT = "oauth_client";
|
76 |
+
const SERVICE_PLATFORM = "platform";
|
77 |
+
|
78 |
+
/** @var EventDispatcher $eventDispatcher */
|
79 |
+
protected $eventDispatcher;
|
80 |
+
|
81 |
+
/** @var ServiceContainer $serviceContainer */
|
82 |
+
protected $serviceContainer;
|
83 |
+
|
84 |
+
/** @var HttpHandler $httpHandler */
|
85 |
+
protected $httpHandler;
|
86 |
+
|
87 |
+
/** @var ExceptionHandler $exceptionHandler */
|
88 |
+
protected $exceptionHandler;
|
89 |
+
|
90 |
+
/** @var Logger $logger */
|
91 |
+
protected $logger;
|
92 |
+
|
93 |
+
/** @var callable $prevExceptionHandler */
|
94 |
+
protected $prevExceptionHandler;
|
95 |
+
|
96 |
+
/** @var callable $prevErrorHandler */
|
97 |
+
protected $prevErrorHandler;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Itembase constructor.
|
101 |
+
*/
|
102 |
+
public function __construct()
|
103 |
+
{
|
104 |
+
$this->serviceContainer = new ServiceContainer();
|
105 |
+
$this->logger = new Logger();
|
106 |
+
$this->eventDispatcher = new EventDispatcher($this->serviceContainer);
|
107 |
+
$this->httpHandler = new HttpHandler($this->serviceContainer);
|
108 |
+
$exceptionHandler = new ExceptionHandler($this->logger);
|
109 |
+
|
110 |
+
$this->serviceContainer->bindService(self::SERVICE_LOGGER, $this->logger);
|
111 |
+
$this->serviceContainer->bindService(self::SERVICE_OAUTH_CLIENT, new OAuthClient());
|
112 |
+
|
113 |
+
// initialize exception handler with response
|
114 |
+
$this->httpHandler->initResponseAwareService($exceptionHandler);
|
115 |
+
|
116 |
+
// add exception handler to listen exception event
|
117 |
+
$this->eventDispatcher->addListener(self::EVENT_EXCEPTION, $exceptionHandler);
|
118 |
+
|
119 |
+
// set exception/error handlers
|
120 |
+
$this->prevErrorHandler = set_error_handler(array($this, 'errorHandler'));
|
121 |
+
$this->prevExceptionHandler = set_exception_handler(array($this, 'exceptionHandler'));
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Destructor method for Core.
|
126 |
+
* Resetting exception and error handler
|
127 |
+
*/
|
128 |
+
public function __destruct()
|
129 |
+
{
|
130 |
+
set_error_handler($this->prevErrorHandler);
|
131 |
+
set_exception_handler($this->prevExceptionHandler);
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Initialization of PluginSdk and extensions
|
136 |
+
*
|
137 |
+
* @throws \Exception
|
138 |
+
* @return Core
|
139 |
+
*/
|
140 |
+
public function init()
|
141 |
+
{
|
142 |
+
try {
|
143 |
+
if (!defined('ITEMBASE_PLUGIN_BUILD')) {
|
144 |
+
throw new \Exception("No build key is set!");
|
145 |
+
}
|
146 |
+
|
147 |
+
if (!defined('ITEMBASE_PLUGIN_SERVICE')) {
|
148 |
+
define('ITEMBASE_PLUGIN_SERVICE', self::PLUGIN_SERVER_URL);
|
149 |
+
}
|
150 |
+
|
151 |
+
try {
|
152 |
+
$httpClient = new HttpClient();
|
153 |
+
$response = $httpClient->sendData(ITEMBASE_PLUGIN_SERVICE . '/builds/' . ITEMBASE_PLUGIN_BUILD);
|
154 |
+
$response = json_decode($response, true);
|
155 |
+
|
156 |
+
if (empty($response)) {
|
157 |
+
throw new \Exception("No configuration data is available for the plugin!");
|
158 |
+
}
|
159 |
+
|
160 |
+
if (!empty($response['constants'])) {
|
161 |
+
foreach ($response['constants'] as $constant => $value) {
|
162 |
+
if (!defined($constant)) {
|
163 |
+
define('ITEMBASE_' . strtoupper($constant), $value);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
if (!empty($response['client_id']) && !defined('ITEMBASE_BRANDED_ID')) {
|
169 |
+
define('ITEMBASE_BRANDED_ID', $response['client_id']);
|
170 |
+
}
|
171 |
+
} catch (\Exception $ex) {
|
172 |
+
define('ITEMBASE_OAUTH_SERVER_URL', self::OAUTH_SERVER_URL);
|
173 |
+
}
|
174 |
+
|
175 |
+
if (!defined('ITEMBASE_VENDOR_DIR')) {
|
176 |
+
// according to composer (and PSR-4) folder structure vendor dir is the 6th level from current file
|
177 |
+
define('ITEMBASE_VENDOR_DIR', dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))));
|
178 |
+
}
|
179 |
+
|
180 |
+
$extensionLoader = new ExtensionsLoader($this->serviceContainer);
|
181 |
+
$extensionLoader->loadExtensions();
|
182 |
+
|
183 |
+
$this->eventDispatcher->initAwareServices();
|
184 |
+
|
185 |
+
$this->serviceContainer->verifyServices(array(
|
186 |
+
array(self::SERVICE_STORAGE => 'Itembase\Psdk\Platform\StorageInterface'),
|
187 |
+
array(self::SERVICE_MULTISHOP => 'Itembase\Psdk\Platform\MultiShop\MultishopAbstract'),
|
188 |
+
array(self::SERVICE_PLATFORM => 'Itembase\Psdk\Platform\PlatformInterface')
|
189 |
+
));
|
190 |
+
|
191 |
+
// adding ping service to handle ping request
|
192 |
+
$pingService = new PingHandler();
|
193 |
+
$this->serviceContainer->bindService($pingService->getExtensionName(), $pingService);
|
194 |
+
|
195 |
+
// we are ready to go
|
196 |
+
$this->eventDispatcher->dispatch(self::EVENT_INITIALIZED);
|
197 |
+
} catch (\Exception $ex) {
|
198 |
+
$this->logger->log(Logger::IB_LOG_ERR, $ex);
|
199 |
+
|
200 |
+
$this->eventDispatcher->dispatch(self::EVENT_EXCEPTION, $ex);
|
201 |
+
$this->httpHandler->sendResponses();
|
202 |
+
exit;
|
203 |
+
}
|
204 |
+
|
205 |
+
return $this;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Execute all handlers
|
210 |
+
*
|
211 |
+
* @return Core
|
212 |
+
*/
|
213 |
+
public function run()
|
214 |
+
{
|
215 |
+
try {
|
216 |
+
$this->httpHandler->initRequest();
|
217 |
+
$this->httpHandler->initResponseAwareServices();
|
218 |
+
|
219 |
+
$this->eventDispatcher->dispatch(self::EVENT_RUN);
|
220 |
+
$this->httpHandler->initRequestAwareServices();
|
221 |
+
} catch (\Exception $ex) {
|
222 |
+
$this->eventDispatcher->dispatch(self::EVENT_EXCEPTION, $ex);
|
223 |
+
$this->httpHandler->sendResponses();
|
224 |
+
exit;
|
225 |
+
}
|
226 |
+
|
227 |
+
return $this;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Finalizing work
|
232 |
+
*/
|
233 |
+
public function done()
|
234 |
+
{
|
235 |
+
try {
|
236 |
+
$this->eventDispatcher->dispatch(self::EVENT_DONE);
|
237 |
+
$this->httpHandler->sendResponses();
|
238 |
+
|
239 |
+
// restore previous error/exception handler
|
240 |
+
set_error_handler($this->prevErrorHandler);
|
241 |
+
set_exception_handler($this->prevExceptionHandler);
|
242 |
+
} catch (\Exception $ex) {
|
243 |
+
$this->eventDispatcher->dispatch(self::EVENT_EXCEPTION, $ex);
|
244 |
+
$this->httpHandler->sendResponses();
|
245 |
+
exit;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Executes all method chain at once
|
251 |
+
*/
|
252 |
+
public function runAll()
|
253 |
+
{
|
254 |
+
$this->init()->run()->done();
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* @return ServiceContainer
|
259 |
+
*/
|
260 |
+
public function getServiceContainer()
|
261 |
+
{
|
262 |
+
return $this->serviceContainer;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Custom error handler. In case of $errno == E_NOTICE || $errno == E_WARNING || $errno == E_USER_NOTICE ||
|
267 |
+
* $errno == E_USER_WARNING - IB_LOG_DEBUG message will be wrote into the log. Otherwise exception event will be
|
268 |
+
* dispatched and execution will be stopped.
|
269 |
+
*
|
270 |
+
* @param int $errno
|
271 |
+
* @param string $errstr
|
272 |
+
* @param string $errfile
|
273 |
+
* @param int $errline
|
274 |
+
*
|
275 |
+
* @return bool
|
276 |
+
*/
|
277 |
+
public function errorHandler($errno, $errstr, $errfile, $errline)
|
278 |
+
{
|
279 |
+
$message = sprintf(
|
280 |
+
"Error handler got message (%s) in file (%s) on line (%d)",
|
281 |
+
$errstr,
|
282 |
+
$errfile,
|
283 |
+
$errline
|
284 |
+
);
|
285 |
+
|
286 |
+
if ($errno == E_NOTICE || $errno == E_WARNING || $errno == E_USER_NOTICE || $errno == E_USER_WARNING) {
|
287 |
+
$this->logger->log(Logger::IB_LOG_DEBUG, $message);
|
288 |
+
|
289 |
+
return true;
|
290 |
+
}
|
291 |
+
|
292 |
+
$this->eventDispatcher->dispatch(self::EVENT_EXCEPTION, new \Exception($message, $errno));
|
293 |
+
$this->httpHandler->sendResponses();
|
294 |
+
exit;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Custom exception handler function in case somewhere try/catch block was missed.
|
299 |
+
*
|
300 |
+
* @param string|\Exception $exception
|
301 |
+
*/
|
302 |
+
public function exceptionHandler($exception)
|
303 |
+
{
|
304 |
+
$this->eventDispatcher->dispatch(self::EVENT_EXCEPTION, $exception);
|
305 |
+
$this->httpHandler->sendResponses();
|
306 |
+
|
307 |
+
exit;
|
308 |
+
}
|
309 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/ExceptionHandler.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Core;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Event\EventListenerInterface;
|
5 |
+
use Itembase\Psdk\Http\Response;
|
6 |
+
use Itembase\Psdk\Http\ResponseAwareInterface;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class ExceptionHandler
|
10 |
+
*
|
11 |
+
* ExceptionHandler class is responsible to react when exception happened during SDK based plugin work cycle.
|
12 |
+
* It's used internally by SDK and can not be re-defined.
|
13 |
+
* Doesn't accessible via ServiceContainer.
|
14 |
+
*
|
15 |
+
* @package Itembase\Psdk\Core
|
16 |
+
* @author Serghei Ilin <si@itembase.biz>
|
17 |
+
* @copyright (c) 2016 itembase GmbH
|
18 |
+
*/
|
19 |
+
class ExceptionHandler implements EventListenerInterface, ResponseAwareInterface
|
20 |
+
{
|
21 |
+
/** @var Response $response */
|
22 |
+
protected $response;
|
23 |
+
|
24 |
+
/** @var Logger $logger */
|
25 |
+
protected $logger;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* ExceptionHandler constructor.
|
29 |
+
*
|
30 |
+
* @param Logger $logger
|
31 |
+
*/
|
32 |
+
public function __construct(Logger $logger)
|
33 |
+
{
|
34 |
+
$this->logger = $logger;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* {@inheritdoc}
|
39 |
+
*/
|
40 |
+
public function getResponseType()
|
41 |
+
{
|
42 |
+
return 'exception';
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* {@inheritdoc}
|
47 |
+
*/
|
48 |
+
public function getResponseVersion()
|
49 |
+
{
|
50 |
+
return '1.0';
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* {@inheritdoc}
|
55 |
+
*/
|
56 |
+
public function getRequestVersion()
|
57 |
+
{
|
58 |
+
return '1.0';
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* {@inheritdoc}
|
63 |
+
*/
|
64 |
+
public function setResponse(Response $response)
|
65 |
+
{
|
66 |
+
$this->response = $response;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* {@inheritdoc}
|
71 |
+
*/
|
72 |
+
public function onEvent($eventName, $exception)
|
73 |
+
{
|
74 |
+
$this->response->setData(array(
|
75 |
+
'file' => $exception->getFile(),
|
76 |
+
'line' => $exception->getLine(),
|
77 |
+
'message' => $exception->getMessage(),
|
78 |
+
'logs' => $this->logger->getMessages(Logger::IB_LOG_DEBUG)
|
79 |
+
));
|
80 |
+
}
|
81 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/Logger.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Core;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Logger
|
6 |
+
*
|
7 |
+
* Logger class is a simple implementation for logging.
|
8 |
+
* It doesn't log anything to filesystem. Everything is stored inside the Logger instance in an array and will be
|
9 |
+
* returned with response in case of exception or when development mode is enabled.
|
10 |
+
*
|
11 |
+
* Class contains the following log levels:
|
12 |
+
* IB_LOG_ERR - represents error.
|
13 |
+
* IB_LOG_INFO - represents information log entry.
|
14 |
+
* IB_LOG_DEBUG - some message which might help during debugging.
|
15 |
+
*
|
16 |
+
* @package Itembase\Psdk\Core
|
17 |
+
* @author Serghei Ilin <si@itembase.biz>
|
18 |
+
* @copyright (c) 2016 itembase GmbH
|
19 |
+
*/
|
20 |
+
class Logger
|
21 |
+
{
|
22 |
+
// Logger log levels
|
23 |
+
const IB_LOG_ERR = 0;
|
24 |
+
const IB_LOG_INFO = 1;
|
25 |
+
const IB_LOG_DEBUG = 2;
|
26 |
+
|
27 |
+
/** @var array $messages */
|
28 |
+
protected $messages;
|
29 |
+
|
30 |
+
/** @var array $errorLevels */
|
31 |
+
protected $errorLevels = array(
|
32 |
+
self::IB_LOG_ERR => 'error',
|
33 |
+
self::IB_LOG_INFO => 'info',
|
34 |
+
self::IB_LOG_DEBUG => 'debug'
|
35 |
+
);
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Stores log entry in internal messages array. Log level and actual message must be provided.
|
39 |
+
* $message can be instance of \Exception class.
|
40 |
+
*
|
41 |
+
* @param int $level
|
42 |
+
* @param string|\Exception $message
|
43 |
+
*/
|
44 |
+
public function log($level, $message)
|
45 |
+
{
|
46 |
+
$msg = array(
|
47 |
+
'level' => $this->errorLevels[$level],
|
48 |
+
'date' => date('c'),
|
49 |
+
'message' => $message
|
50 |
+
);
|
51 |
+
|
52 |
+
if ($message instanceof \Exception) {
|
53 |
+
$msg['file'] = $message->getFile();
|
54 |
+
$msg['line'] = $message->getLine();
|
55 |
+
$msg['message'] = $message->getMessage();
|
56 |
+
}
|
57 |
+
|
58 |
+
$this->messages[$level][] = $msg;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Method returns all messages from "minLevel" (including minLevel messages as well).
|
63 |
+
*
|
64 |
+
* Log levels (from lowest to highest):
|
65 |
+
* - IB_LOG_DEBUG
|
66 |
+
* - IB_LOG_INFO
|
67 |
+
* - IB_LOG_ERR
|
68 |
+
*
|
69 |
+
* @param int $minLevel
|
70 |
+
*
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function getMessages($minLevel = self::IB_LOG_ERR)
|
74 |
+
{
|
75 |
+
$messages = array();
|
76 |
+
|
77 |
+
for ($level = $minLevel; $level >= self::IB_LOG_ERR; $level--) {
|
78 |
+
if (empty($this->messages[$level])) {
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
|
82 |
+
$messages = array_merge($messages, $this->messages[$level]);
|
83 |
+
}
|
84 |
+
|
85 |
+
return $messages;
|
86 |
+
}
|
87 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/OAuthClient.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Core;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ContainerAwareInterface;
|
5 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
6 |
+
use Itembase\Psdk\Core;
|
7 |
+
use Itembase\Psdk\Http\HttpClient;
|
8 |
+
use Itembase\Psdk\Platform\StorageInterface;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class OAuthClient
|
12 |
+
*
|
13 |
+
* Simple OAuth client designed to communicate with itembase server to get/verify access and one-time tokens.
|
14 |
+
*
|
15 |
+
* @package Itembase\Psdk\Core
|
16 |
+
* @author Serghei Ilin <si@itembase.biz>
|
17 |
+
* @copyright (c) 2016 itembase GmbH
|
18 |
+
*/
|
19 |
+
class OAuthClient implements ContainerAwareInterface
|
20 |
+
{
|
21 |
+
const STORAGE_API_KEY = "api_key";
|
22 |
+
const STORAGE_API_SECRET = "api_secret";
|
23 |
+
const STORAGE_API_TOKEN = "api_token";
|
24 |
+
const STORAGE_API_TBCS_TOKEN = "api_tbcs_token";
|
25 |
+
|
26 |
+
/** @var ServiceContainer $serviceContainer */
|
27 |
+
protected $serviceContainer;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* {@inheritdoc}
|
31 |
+
*/
|
32 |
+
public function setContainer(ServiceContainer $container)
|
33 |
+
{
|
34 |
+
$this->serviceContainer = $container;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Method is trying to authenticate towards OAuth itembase server using API key and secret which must be stored
|
39 |
+
* already in storage. As a result - token is received from itembase server, stored in shop storage and returned by
|
40 |
+
* method.
|
41 |
+
*
|
42 |
+
* If token already exists in the storage - method will check if it's still valid (check if it's not expired) and
|
43 |
+
* will return it instead of requesting new one.
|
44 |
+
*
|
45 |
+
* Operation is happening per shop so "shopId" parameter is passed. Same as a StorageInterface OAuthClient is
|
46 |
+
* supporting "shopId" to be NULL.
|
47 |
+
* Method throws exception:
|
48 |
+
* - if api key is not set
|
49 |
+
* - if secret is not set
|
50 |
+
* - if some issue happened during request to itembase server
|
51 |
+
* - if some issue happened during storing received from itembase server access token
|
52 |
+
*
|
53 |
+
* It's used by validateToken method to make an authorized request to itembase server.
|
54 |
+
*
|
55 |
+
* @param string $shopId
|
56 |
+
*
|
57 |
+
* @return array
|
58 |
+
*
|
59 |
+
* @throws \Exception
|
60 |
+
*/
|
61 |
+
public function authenticateClient($shopId)
|
62 |
+
{
|
63 |
+
/** @var StorageInterface $storage */
|
64 |
+
$storage = $this->serviceContainer->getService(Core::SERVICE_STORAGE);
|
65 |
+
$token = $storage->get(self::STORAGE_API_TOKEN, $shopId);
|
66 |
+
|
67 |
+
if (!empty($token)) {
|
68 |
+
$token = json_decode($token, true);
|
69 |
+
if ($token['expires_at'] > time()) {
|
70 |
+
return $token;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
$clientId = $storage->get(self::STORAGE_API_KEY, $shopId);
|
75 |
+
if (empty($clientId)) {
|
76 |
+
throw new \Exception('Api key is not set');
|
77 |
+
}
|
78 |
+
|
79 |
+
$clientSecret = $storage->get(self::STORAGE_API_SECRET, $shopId);
|
80 |
+
if (empty($clientSecret)) {
|
81 |
+
throw new \Exception('Secret key is not set');
|
82 |
+
}
|
83 |
+
|
84 |
+
$data = array(
|
85 |
+
'client_id' => $clientId,
|
86 |
+
'client_secret' => $clientSecret,
|
87 |
+
'response_type' => 'token',
|
88 |
+
'grant_type' => 'http://oauth.itembase.com/grants/plugin'
|
89 |
+
);
|
90 |
+
|
91 |
+
$header = array("Content-type: application/x-www-form-urlencoded");
|
92 |
+
$client = new HttpClient();
|
93 |
+
$jsonResponse = $client->sendData(ITEMBASE_OAUTH_SERVER_URL . '/oauth/v2/token', $data, $header);
|
94 |
+
$token = json_decode($jsonResponse, true);
|
95 |
+
|
96 |
+
if (isset($token['error'])) {
|
97 |
+
throw new \Exception(
|
98 |
+
sprintf(
|
99 |
+
'Error during OAuth authorization: %s',
|
100 |
+
isset($token['error_description']) ? $token['error_description'] : $token['error']
|
101 |
+
)
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
$token['expires_at'] = time() + intval($token['expires_in']);
|
106 |
+
unset($token['expires_in'], $token['scope']);
|
107 |
+
|
108 |
+
$storage->save(self::STORAGE_API_TOKEN, json_encode($token), $shopId);
|
109 |
+
|
110 |
+
return $token;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Validate access token
|
115 |
+
* Method is used to validate token received in the request to plugin. As a result method will store token in the
|
116 |
+
* storage (with expire date) and returns an array with the actual token and expire date.
|
117 |
+
*
|
118 |
+
* Later when request will be done with the same token method will check if the storage has already such token and
|
119 |
+
* instead of sending request to itembase server will just return that token.
|
120 |
+
*
|
121 |
+
* Method may throw exception:
|
122 |
+
* - if api key is not set
|
123 |
+
* - if secret is not set
|
124 |
+
* - if some issue happened during request to itembase server
|
125 |
+
* - if some issue happened during storing received from itembase server access token
|
126 |
+
*
|
127 |
+
* @param string $tokenToCheck
|
128 |
+
* @param string $shopId
|
129 |
+
*
|
130 |
+
* @return array
|
131 |
+
*
|
132 |
+
* @throws \Exception
|
133 |
+
*/
|
134 |
+
public function validateToken($tokenToCheck, $shopId)
|
135 |
+
{
|
136 |
+
/** @var StorageInterface $storage */
|
137 |
+
$storage = $this->serviceContainer->getService(Core::SERVICE_STORAGE);
|
138 |
+
$tbcs = json_decode(
|
139 |
+
$storage->get(self::STORAGE_API_TBCS_TOKEN, $shopId), true
|
140 |
+
);
|
141 |
+
|
142 |
+
if (isset($tbcs['tbcs_token']) && $tokenToCheck == $tbcs['tbcs_token']
|
143 |
+
&& isset($tbcs['expires_at']) && $tbcs['expires_at'] > time()
|
144 |
+
) {
|
145 |
+
return $tbcs;
|
146 |
+
}
|
147 |
+
|
148 |
+
$accessToken = $this->authenticateClient($shopId);
|
149 |
+
|
150 |
+
$header[] = 'Authorization: Bearer ' . $accessToken['access_token'];
|
151 |
+
$client = new HttpClient();
|
152 |
+
$jsonResponse = $client->sendData(ITEMBASE_OAUTH_SERVER_URL . '/tbcs/v1/tokens/' . $tokenToCheck, null, $header);
|
153 |
+
$response = json_decode($jsonResponse, true);
|
154 |
+
|
155 |
+
$tbcs = array(
|
156 |
+
'tbcs_token' => $tokenToCheck,
|
157 |
+
'expires_at' => $response['expires_at']
|
158 |
+
);
|
159 |
+
|
160 |
+
$storage->save(self::STORAGE_API_TBCS_TOKEN, json_encode($tbcs), $shopId);
|
161 |
+
|
162 |
+
return $tbcs;
|
163 |
+
}
|
164 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Core/PingHandler.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\PsdkExtension\Registration;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Extension\ExtensionInterface;
|
5 |
+
use Itembase\Psdk\Http\Request;
|
6 |
+
use Itembase\Psdk\Http\RequestAwareInterface;
|
7 |
+
use Itembase\Psdk\Http\Response;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class PingHandler
|
11 |
+
*
|
12 |
+
* Build-in ping/pong handler for check if plugin is still presented on the connected to itembase shop
|
13 |
+
*
|
14 |
+
* @package ItembaseExtension\Psdk\Registration
|
15 |
+
* @author Serghei Ilin <si@itembase.biz>
|
16 |
+
* @copyright (c) 2016 itembase GmbH
|
17 |
+
*/
|
18 |
+
class PingHandler implements ExtensionInterface, RequestAwareInterface
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getExtensionName()
|
24 |
+
{
|
25 |
+
return 'ping';
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getResponseType()
|
32 |
+
{
|
33 |
+
return $this->getExtensionName();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getResponseVersion()
|
40 |
+
{
|
41 |
+
return '1.0';
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* {@inheritdoc}
|
46 |
+
*/
|
47 |
+
public function getRequestVersion()
|
48 |
+
{
|
49 |
+
return '1.0';
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param Request $request
|
54 |
+
* @param Response $response
|
55 |
+
*
|
56 |
+
* @throws \Exception
|
57 |
+
*/
|
58 |
+
public function handleRequest(Request $request, Response $response)
|
59 |
+
{
|
60 |
+
if (!$request->matchActions(array('ping'), false)) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
$response->setData('pong');
|
65 |
+
}
|
66 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Event/EventAwareInterface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Event;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface EventAwareInterface
|
6 |
+
*
|
7 |
+
* If some instance requires EventDispatcher object - it needs to implement EventAwareInterface interface.
|
8 |
+
* Using 'setEventDispatcher()' setter EventDispatcher will be injected into instance.
|
9 |
+
*
|
10 |
+
* @package Itembase\Psdk\Event
|
11 |
+
* @author Serghei Ilin <si@itembase.biz>
|
12 |
+
* @copyright (c) 2016 itembase GmbH
|
13 |
+
*/
|
14 |
+
interface EventAwareInterface
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Setter for injecting EventDispatcher object.
|
18 |
+
*
|
19 |
+
* @param EventDispatcher $dispatcher
|
20 |
+
*
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
public function setEventDispatcher(EventDispatcher $dispatcher);
|
24 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Event/EventDispatcher.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Event;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class EventDispatcher
|
8 |
+
*
|
9 |
+
* Class represents implementation of the event dispatcher functionality. An instance of the dispatcher is created by
|
10 |
+
* Itembase\Psdk\Core class.
|
11 |
+
*
|
12 |
+
* Note: EventDispatcher instance is not available in ServiceContainer.
|
13 |
+
*
|
14 |
+
* @package Itembase\Psdk\Event
|
15 |
+
* @author Serghei Ilin <si@itembase.biz>
|
16 |
+
* @copyright (c) 2016 itembase GmbH
|
17 |
+
*/
|
18 |
+
class EventDispatcher
|
19 |
+
{
|
20 |
+
/** @var ServiceContainer $serviceContainer */
|
21 |
+
protected $serviceContainer;
|
22 |
+
|
23 |
+
/** @var array $events */
|
24 |
+
protected $events;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param ServiceContainer $container
|
28 |
+
*/
|
29 |
+
public function __construct(ServiceContainer $container)
|
30 |
+
{
|
31 |
+
$this->serviceContainer = $container;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Method allows to add event listener instance for event. Listener must implement EventListenerInterface interface.
|
36 |
+
*
|
37 |
+
* @param string $event
|
38 |
+
* @param EventListenerInterface $listener
|
39 |
+
*/
|
40 |
+
public function addListener($event, EventListenerInterface $listener)
|
41 |
+
{
|
42 |
+
$this->events[$event][] = $listener;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* dispatch() method triggers event execution which means EventDispatcher will call all event listeners for the
|
47 |
+
* specific "event". It's possible to pass additional data during event trigger using "extra" parameter.
|
48 |
+
*
|
49 |
+
* Event listeners will be called in the order they were added.
|
50 |
+
*
|
51 |
+
* @param string $event
|
52 |
+
* @param mixed $extra
|
53 |
+
*/
|
54 |
+
public function dispatch($event, $extra = null)
|
55 |
+
{
|
56 |
+
if (empty($this->events[$event])) {
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
+
/** @var EventListenerInterface $listener */
|
61 |
+
foreach ($this->events[$event] as $listener) {
|
62 |
+
$listener->onEvent($event, $extra);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* It's a helper method which is going through all instances inside ServerContainer instance and for those which
|
68 |
+
* implements EventAwareInterface interface injecting instance of EventDispatcher.
|
69 |
+
*
|
70 |
+
* Is used by Itembase\Psdk\Core class during initialization. Ideally should not be used by developers directly.
|
71 |
+
*
|
72 |
+
* @return void
|
73 |
+
*/
|
74 |
+
public function initAwareServices()
|
75 |
+
{
|
76 |
+
$tags = $this->serviceContainer->listServices();
|
77 |
+
|
78 |
+
foreach ($tags as $tag) {
|
79 |
+
$ext = $this->serviceContainer->getService($tag);
|
80 |
+
|
81 |
+
if ($ext instanceof EventAwareInterface) {
|
82 |
+
$ext->setEventDispatcher($this);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Event/EventListenerInterface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Event;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface EventListenerInterface
|
6 |
+
*
|
7 |
+
* In case if class want to handle events it must implement EventListenerInterface interface
|
8 |
+
*
|
9 |
+
* @package Itembase\Psdk\Event
|
10 |
+
* @author Serghei Ilin <si@itembase.biz>
|
11 |
+
* @copyright (c) 2016 itembase GmbH
|
12 |
+
*/
|
13 |
+
interface EventListenerInterface
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Method-handler for event
|
17 |
+
*
|
18 |
+
* @param string $eventName Name of the event
|
19 |
+
* @param mixed $extraData Associated data which was sent by event trigger
|
20 |
+
*
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
public function onEvent($eventName, $extraData);
|
24 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionInterface.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Extension;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface ExtensionInterface
|
6 |
+
*
|
7 |
+
* In order to be loaded extension must have Extension class in it's namespace and it should implement
|
8 |
+
* ExtensionInterface interface.
|
9 |
+
*
|
10 |
+
* getExtensionName() is used by ExtensionLoader to set the name of the extension in ServiceContainer during loading.
|
11 |
+
* Keep in mind that ExtensionLoading is checking if provided name is already registered in ServiceContainer.
|
12 |
+
*
|
13 |
+
* @package Itembase\Psdk\Extension
|
14 |
+
* @author Serghei Ilin <si@itembase.biz>
|
15 |
+
* @copyright (c) 2016 itembase GmbH
|
16 |
+
*/
|
17 |
+
interface ExtensionInterface
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Getter which returns extension name.
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getExtensionName();
|
25 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Extension/ExtensionsLoader.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Extension;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class ExtensionsLoader
|
8 |
+
*
|
9 |
+
* Class is responsible for loading SDK and plugin extensions. Used by Itembase\Psdk\Core class and not exposed in
|
10 |
+
* ServiceContainer instance.
|
11 |
+
*
|
12 |
+
* Plugin developer should not use it directly.
|
13 |
+
*
|
14 |
+
* Requires defined constant - ITEMBASE_VENDOR_DIR. By default Core class set it to 6 levels previous from it's position.
|
15 |
+
* In case it must be changed - please define correct path for ITEMBASE_VENDOR_DIR before calling init() of the Core
|
16 |
+
* class.
|
17 |
+
*
|
18 |
+
* Class requires Composer autoloader class map to be available in <vendor-dir>/composer/autoload_classmap.php
|
19 |
+
*
|
20 |
+
* In order to be loaded extension must have Extension class and it must be in Itembase\PsdkExtension or
|
21 |
+
* Itembase\PluginExtension namespace and it should implement ExtensionInterface interface.
|
22 |
+
*
|
23 |
+
* Keep in mind that ExtensionLoading is checking if provided name is already registered in ServiceContainer. If that is
|
24 |
+
* the case - exception will be thrown.
|
25 |
+
*
|
26 |
+
* Please check out the loadExtension diagram to see how ExtensionLoader is loading extensions.
|
27 |
+
*
|
28 |
+
* @package Itembase\Psdk\Extension
|
29 |
+
* @author Serghei Ilin <si@itembase.biz>
|
30 |
+
* @copyright (c) 2016 itembase GmbH
|
31 |
+
*/
|
32 |
+
class ExtensionsLoader
|
33 |
+
{
|
34 |
+
/** @var ServiceContainer $serviceContainer */
|
35 |
+
protected $serviceContainer;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* ExtensionsLoader constructor.
|
39 |
+
*
|
40 |
+
* @param ServiceContainer $container
|
41 |
+
*/
|
42 |
+
public function __construct(ServiceContainer $container)
|
43 |
+
{
|
44 |
+
$this->serviceContainer = $container;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Main logic of the loading extensions is implemented in that method and used internally by loadExtensions method.
|
49 |
+
* loadExtensions method call once that method with SDK extensions folder path and then second time with plugin
|
50 |
+
* extensions folder path.
|
51 |
+
*
|
52 |
+
* Method throws exception:
|
53 |
+
* - if ITEMBASE_VENDOR_DIR is not defined
|
54 |
+
* - if composer autoload classmap was not found or it's array is empty
|
55 |
+
* - if extension name already exists in ServiceContainer
|
56 |
+
*
|
57 |
+
* @throws \Exception
|
58 |
+
*/
|
59 |
+
public function loadExtensions()
|
60 |
+
{
|
61 |
+
if (!defined('ITEMBASE_VENDOR_DIR')) {
|
62 |
+
throw new \Exception("Extensions dir path was not defined");
|
63 |
+
}
|
64 |
+
|
65 |
+
$classMapFilePath = ITEMBASE_VENDOR_DIR . '/composer/autoload_classmap.php';
|
66 |
+
if (!file_exists($classMapFilePath)) {
|
67 |
+
throw new \Exception("No classmap file found! Maybe composer is not used?");
|
68 |
+
}
|
69 |
+
|
70 |
+
$classMap = include $classMapFilePath;
|
71 |
+
if (empty($classMap)) {
|
72 |
+
throw new \Exception("Classmap is empty!");
|
73 |
+
}
|
74 |
+
|
75 |
+
foreach ($classMap as $className => $path) {
|
76 |
+
if (false === strpos($className, "Itembase\\PsdkExtension")
|
77 |
+
&&
|
78 |
+
false === strpos($className, "Itembase\\PluginExtension")) {
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
|
82 |
+
$implements = class_implements($className);
|
83 |
+
if (false === $implements) {
|
84 |
+
continue;
|
85 |
+
}
|
86 |
+
|
87 |
+
if (!in_array("Itembase\\Psdk\\Extension\\ExtensionInterface", array_keys($implements))) {
|
88 |
+
continue;
|
89 |
+
}
|
90 |
+
|
91 |
+
$ext = new $className();
|
92 |
+
if (!$ext instanceof ExtensionInterface) {
|
93 |
+
continue;
|
94 |
+
}
|
95 |
+
|
96 |
+
if ($this->serviceContainer->hasService($ext->getExtensionName())) {
|
97 |
+
throw new \Exception('Extension with the tag ' . $ext->getExtensionName() . ' already exists in container!');
|
98 |
+
}
|
99 |
+
|
100 |
+
$this->serviceContainer->bindService($ext->getExtensionName(), $ext);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/HttpClient.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Http;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class HttpClient
|
6 |
+
*
|
7 |
+
* Simple HTTP client for communicating with itembase server.
|
8 |
+
*
|
9 |
+
* @package Itembase\Psdk\Http
|
10 |
+
* @author Serghei Ilin <si@itembase.biz>
|
11 |
+
* @copyright (c) 2016 itembase GmbH
|
12 |
+
*/
|
13 |
+
class HttpClient
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Method to send request to itembase server. If "data" is passed POST request will be sent, otherwise GET request
|
17 |
+
* is send.
|
18 |
+
*
|
19 |
+
* @param string $url URL where request should be sent
|
20 |
+
* @param mixed|null $data data which needs to be send
|
21 |
+
* @param array $header HTTP headers
|
22 |
+
*
|
23 |
+
* @return mixed|string
|
24 |
+
*
|
25 |
+
* @throws \Exception
|
26 |
+
*/
|
27 |
+
public function sendData($url, $data = null, $header = array())
|
28 |
+
{
|
29 |
+
if (extension_loaded('curl')) {
|
30 |
+
$ibCurl = curl_init();
|
31 |
+
|
32 |
+
curl_setopt($ibCurl, CURLOPT_HEADER, true);
|
33 |
+
curl_setopt($ibCurl, CURLOPT_HTTPHEADER, $header);
|
34 |
+
curl_setopt($ibCurl, CURLOPT_SSL_VERIFYPEER, false);
|
35 |
+
curl_setopt($ibCurl, CURLOPT_SSL_VERIFYHOST, 2);
|
36 |
+
curl_setopt($ibCurl, CURLOPT_VERBOSE, 1);
|
37 |
+
curl_setopt($ibCurl, CURLOPT_URL, $url);
|
38 |
+
curl_setopt($ibCurl, CURLOPT_RETURNTRANSFER, true);
|
39 |
+
curl_setopt($ibCurl, CURLOPT_CONNECTTIMEOUT, 30);
|
40 |
+
|
41 |
+
if ($data) {
|
42 |
+
$prepareData = http_build_query($data);
|
43 |
+
|
44 |
+
curl_setopt($ibCurl, CURLOPT_POST, true);
|
45 |
+
curl_setopt($ibCurl, CURLOPT_POSTFIELDS, $prepareData);
|
46 |
+
}
|
47 |
+
|
48 |
+
$response = curl_exec($ibCurl);
|
49 |
+
$header_size = curl_getinfo($ibCurl, CURLINFO_HEADER_SIZE);
|
50 |
+
$response = substr($response, $header_size);
|
51 |
+
$httpInfo = curl_getinfo($ibCurl);
|
52 |
+
|
53 |
+
if ($response === false || $response == '' || $httpInfo['http_code'] == 500 || $httpInfo['http_code'] == 404) {
|
54 |
+
$errorMsg = curl_error($ibCurl);
|
55 |
+
curl_close($ibCurl);
|
56 |
+
|
57 |
+
throw new \Exception(sprintf(
|
58 |
+
'curl error: %s, http status code: %s, requested URI: %s',
|
59 |
+
$errorMsg,
|
60 |
+
$httpInfo['http_code'],
|
61 |
+
$url
|
62 |
+
));
|
63 |
+
}
|
64 |
+
|
65 |
+
curl_close($ibCurl);
|
66 |
+
} else {
|
67 |
+
$dataQuery = '';
|
68 |
+
$opts = array('http' => array('ignore_errors' => true, 'timeout' => 5));
|
69 |
+
$context = stream_context_create($opts);
|
70 |
+
|
71 |
+
if ($data) {
|
72 |
+
$dataQuery = '?' . http_build_query($data);;
|
73 |
+
}
|
74 |
+
|
75 |
+
$response = file_get_contents($url . $dataQuery, false, $context);
|
76 |
+
|
77 |
+
if ($response === false) {
|
78 |
+
throw new \Exception('file_get_contents error.');
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
return $response;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Method to send request to itembase server. If "data" is passed POST request will be sent, otherwise GET request
|
87 |
+
* is send.
|
88 |
+
*
|
89 |
+
* @param string $url URL where request should be sent
|
90 |
+
* @param mixed|null $data data which needs to be send
|
91 |
+
*
|
92 |
+
* @return mixed|string
|
93 |
+
*
|
94 |
+
* @throws \Exception
|
95 |
+
*/
|
96 |
+
public function sendJsonData($url, $data = null)
|
97 |
+
{
|
98 |
+
if (extension_loaded('curl')) {
|
99 |
+
$ibCurl = curl_init();
|
100 |
+
|
101 |
+
curl_setopt($ibCurl, CURLOPT_HEADER, true);
|
102 |
+
curl_setopt($ibCurl, CURLOPT_SSL_VERIFYPEER, false);
|
103 |
+
curl_setopt($ibCurl, CURLOPT_SSL_VERIFYHOST, 2);
|
104 |
+
curl_setopt($ibCurl, CURLOPT_VERBOSE, 1);
|
105 |
+
curl_setopt($ibCurl, CURLOPT_URL, $url);
|
106 |
+
curl_setopt($ibCurl, CURLOPT_RETURNTRANSFER, true);
|
107 |
+
curl_setopt($ibCurl, CURLOPT_CONNECTTIMEOUT, 30);
|
108 |
+
|
109 |
+
if ($data) {
|
110 |
+
$json = json_encode($data);
|
111 |
+
|
112 |
+
curl_setopt($ibCurl, CURLOPT_POST, true);
|
113 |
+
curl_setopt($ibCurl, CURLOPT_CUSTOMREQUEST, "POST");
|
114 |
+
curl_setopt($ibCurl, CURLOPT_POSTFIELDS, $json);
|
115 |
+
curl_setopt($ibCurl, CURLOPT_HTTPHEADER, array(
|
116 |
+
"Content-Type: application/json",
|
117 |
+
"Content-Length: " . strlen($json),
|
118 |
+
));
|
119 |
+
}
|
120 |
+
|
121 |
+
$response = curl_exec($ibCurl);
|
122 |
+
$header_size = curl_getinfo($ibCurl, CURLINFO_HEADER_SIZE);
|
123 |
+
$response = substr($response, $header_size);
|
124 |
+
$httpInfo = curl_getinfo($ibCurl);
|
125 |
+
|
126 |
+
if ($response === false || $response == '' || $httpInfo['http_code'] == 500 || $httpInfo['http_code'] == 404) {
|
127 |
+
$errorMsg = curl_error($ibCurl);
|
128 |
+
curl_close($ibCurl);
|
129 |
+
|
130 |
+
throw new \Exception(sprintf(
|
131 |
+
'curl error: %s, http status code: %s, requested URI: %s',
|
132 |
+
$errorMsg,
|
133 |
+
$httpInfo['http_code'],
|
134 |
+
$url
|
135 |
+
));
|
136 |
+
}
|
137 |
+
|
138 |
+
curl_close($ibCurl);
|
139 |
+
} else {
|
140 |
+
throw new \Exception("No curl extensions");
|
141 |
+
}
|
142 |
+
|
143 |
+
return $response;
|
144 |
+
}
|
145 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/HttpHandler.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Http;
|
3 |
+
|
4 |
+
use Itembase\Psdk\Container\ServiceContainer;
|
5 |
+
use Itembase\Psdk\Core;
|
6 |
+
use Itembase\Psdk\Core\OAuthClient;
|
7 |
+
use Itembase\Psdk\Platform\Frontend\ControllerInterface;
|
8 |
+
use Itembase\Psdk\Platform\StorageInterface;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class HttpHandler
|
12 |
+
*
|
13 |
+
* HttpHandler class take care for detecting if request is aimed directly to itembase plugin, parsing that request and
|
14 |
+
* make out of it Request object and prepare Response objects for each extension which needs to return some information
|
15 |
+
* back to the request initiator.
|
16 |
+
*
|
17 |
+
* Class supports custom renderer via \Itembase\Psdk\Platform\Frontend implementation.
|
18 |
+
*
|
19 |
+
* It should not be considered as framework-quality class. It's specifically used for handling itembase server requests.
|
20 |
+
*
|
21 |
+
* @package Itembase\Psdk\Http
|
22 |
+
* @author Serghei Ilin <si@itembase.biz>
|
23 |
+
* @copyright (c) 2016 itembase GmbH
|
24 |
+
*/
|
25 |
+
class HttpHandler
|
26 |
+
{
|
27 |
+
const FRONTEND_RESPONSE_HANDLER = "frontend_response_handler";
|
28 |
+
|
29 |
+
/** @var ServiceContainer $serviceContainer */
|
30 |
+
protected $serviceContainer;
|
31 |
+
|
32 |
+
/** @var Request $request */
|
33 |
+
protected $request;
|
34 |
+
|
35 |
+
/** @var array $responses */
|
36 |
+
protected $responses;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param ServiceContainer $container
|
40 |
+
*/
|
41 |
+
public function __construct(ServiceContainer $container)
|
42 |
+
{
|
43 |
+
$this->request = null;
|
44 |
+
$this->serviceContainer = $container;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Method is going through all instances in ServiceContainer and for the objects which are implementing
|
49 |
+
* RequestAwareInterface interface will call handleRequest() method with Request object and Response.
|
50 |
+
*
|
51 |
+
* Response object is created per service/instance found in ServiceContainer which implements RequestAwareInterface.
|
52 |
+
*
|
53 |
+
* @return void
|
54 |
+
*/
|
55 |
+
public function initRequestAwareServices()
|
56 |
+
{
|
57 |
+
if (null === $this->request) {
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
$tags = $this->serviceContainer->listServices();
|
62 |
+
|
63 |
+
foreach ($tags as $tag) {
|
64 |
+
$service = $this->serviceContainer->getService($tag);
|
65 |
+
|
66 |
+
if (!$service instanceof RequestAwareInterface) {
|
67 |
+
continue;
|
68 |
+
}
|
69 |
+
|
70 |
+
$this->initRequestAwareService($service);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Method is going through all instances in ServiceContainer and for the objects which are implementing
|
76 |
+
* ResponseAwareInterface interface will call setResponse() method with Response object.
|
77 |
+
*
|
78 |
+
* Response object is created per service/instance found in ServiceContainer which implements RequestAwareInterface.
|
79 |
+
* Because services/extensions can evolve and change it's output format each response has version and type. That way
|
80 |
+
* itembase backend knows how to handle response correctly.
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function initResponseAwareServices()
|
85 |
+
{
|
86 |
+
$tags = $this->serviceContainer->listServices();
|
87 |
+
|
88 |
+
foreach ($tags as $tag) {
|
89 |
+
$service = $this->serviceContainer->getService($tag);
|
90 |
+
|
91 |
+
if (!$service instanceof ResponseAwareInterface) {
|
92 |
+
continue;
|
93 |
+
}
|
94 |
+
|
95 |
+
$this->initResponseAwareService($service);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* During method call HttpHandler check if request is actually is done directly for the plugin. It's checking it by
|
101 |
+
* GET parameters: "ib_method" and "ib_token". If they are not presented - request considered as not for plugin and
|
102 |
+
* method stop it's execution so no Request object is created.
|
103 |
+
*
|
104 |
+
* If these parameters are presented method will check if "ib_api_key" and "ib_token" parameters are set. If they
|
105 |
+
* are not passed - request considered as unauthorized.
|
106 |
+
*
|
107 |
+
* If parameters are presented - method will validate "ib_token" using OAuthClient class, so in the end token is
|
108 |
+
* verified using itembase server. If token passed validation - request marked as authorized,
|
109 |
+
* otherwise - unauthorized.
|
110 |
+
*
|
111 |
+
* Method may throw exception:
|
112 |
+
* - if api key is not set
|
113 |
+
* - if secret is not set
|
114 |
+
* - if some issue happened during request to itembase server
|
115 |
+
* - if some issue happened during storing received from itembase server access token
|
116 |
+
*
|
117 |
+
* @throws \Exception
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function initRequest()
|
121 |
+
{
|
122 |
+
if (empty($_GET['ib_method']) || empty($_GET['ib_token'])) {
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
$shopId = null;
|
127 |
+
$isAuthorized = false;
|
128 |
+
|
129 |
+
if (!empty($_GET['ib_api_key']) && !empty($_GET['ib_token'])) {
|
130 |
+
/** @var StorageInterface $storage */
|
131 |
+
$storage = $this->serviceContainer->getService(Core::SERVICE_STORAGE);
|
132 |
+
|
133 |
+
/** @var OAuthClient $oauthClient */
|
134 |
+
$oauthClient = $this->serviceContainer->getService(Core::SERVICE_OAUTH_CLIENT);
|
135 |
+
$shopId = $storage->getShopIdBy(OAuthClient::STORAGE_API_KEY, $_GET['ib_api_key']);
|
136 |
+
|
137 |
+
if (!empty($shopId)) {
|
138 |
+
$token = $oauthClient->validateToken($_GET['ib_token'], $shopId);
|
139 |
+
|
140 |
+
if (!empty($token)) {
|
141 |
+
$isAuthorized = true;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
$this->request = new Request($isAuthorized, $shopId);
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Method used to output all the responses.
|
151 |
+
*
|
152 |
+
* Because method is sending header - before doing anything it checks if some content was already sent. If that is
|
153 |
+
* the case - nothing will be sent and method will stop it's execution.
|
154 |
+
*
|
155 |
+
* Otherwise It's going by each response in responses array and format responses array as:
|
156 |
+
* - response - type of the response returned by getType() method of the Response object
|
157 |
+
* - version- version of the response returned by getVersion() method of the Response object
|
158 |
+
* - payload - actual response data from the Response object
|
159 |
+
*
|
160 |
+
* When all Response objects are processed method send application/json header and output JSON serialized responses
|
161 |
+
* array.
|
162 |
+
*
|
163 |
+
* @throw \Exception
|
164 |
+
* @return void
|
165 |
+
*/
|
166 |
+
public function sendResponses()
|
167 |
+
{
|
168 |
+
// we don't want to cause warnings if something was echo/print etc. already
|
169 |
+
if (headers_sent()) {
|
170 |
+
return;
|
171 |
+
}
|
172 |
+
|
173 |
+
if ($this->serviceContainer->hasService(self::FRONTEND_RESPONSE_HANDLER)) {
|
174 |
+
$frontend = $this->serviceContainer->getService(self::FRONTEND_RESPONSE_HANDLER);
|
175 |
+
if ($frontend instanceof ControllerInterface) {
|
176 |
+
$frontend->renderResponse($this->request, $this->responses);
|
177 |
+
|
178 |
+
return;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
$data = array();
|
183 |
+
|
184 |
+
/** @var Response $response */
|
185 |
+
foreach ($this->responses as $response) {
|
186 |
+
if (!$response->isEmpty()) {
|
187 |
+
$data[] = array(
|
188 |
+
'response' => $response->getType(),
|
189 |
+
'version' => $response->getVersion(),
|
190 |
+
'payload' => $response->getData()
|
191 |
+
);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
if (!empty($data)) {
|
196 |
+
header("Content-type: application/json");
|
197 |
+
echo json_encode($data);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Inject to object implemented ResponseAwareInterface interface Response object via setResponse() method.
|
203 |
+
* A new response object is created each time for RequestAwareInterface object.
|
204 |
+
*
|
205 |
+
* @param ResponseAwareInterface $service
|
206 |
+
*/
|
207 |
+
public function initResponseAwareService(ResponseAwareInterface $service)
|
208 |
+
{
|
209 |
+
$response = new Response($service->getResponseType(), $service->getResponseVersion());
|
210 |
+
$this->responses[] = $response;
|
211 |
+
$service->setResponse($response);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Inject to object implemented RequestAwareInterface interface Request and Response objects via handleRequest()
|
216 |
+
* method. A new response object is created each time for RequestAwareInterface object.
|
217 |
+
*
|
218 |
+
* @param RequestAwareInterface $service
|
219 |
+
*/
|
220 |
+
public function initRequestAwareService(RequestAwareInterface $service)
|
221 |
+
{
|
222 |
+
$response = new Response($service->getResponseType(), $service->getResponseVersion());
|
223 |
+
$this->responses[] = $response;
|
224 |
+
$service->handleRequest($this->request, $response);
|
225 |
+
}
|
226 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/Request.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Http;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Request
|
6 |
+
*
|
7 |
+
* Represents request form itembase server.
|
8 |
+
*
|
9 |
+
* Request class should not be treated like framework-quality class for any requests. It's only to represent request
|
10 |
+
* data from itembase server.
|
11 |
+
*
|
12 |
+
* @package Itembase\Psdk\Http
|
13 |
+
* @author Serghei Ilin <si@itembase.biz>
|
14 |
+
* @copyright (c) 2016 itembase GmbH
|
15 |
+
*/
|
16 |
+
class Request
|
17 |
+
{
|
18 |
+
const GET_REQUEST_TOKEN = 'ib_token';
|
19 |
+
const GET_REQUEST_METHOD = 'ib_method';
|
20 |
+
|
21 |
+
/** @var string $action */
|
22 |
+
protected $action;
|
23 |
+
|
24 |
+
/** @var string $token */
|
25 |
+
protected $token;
|
26 |
+
|
27 |
+
/** @var string $apiKey */
|
28 |
+
protected $apiKey;
|
29 |
+
|
30 |
+
/** @var string $shopId */
|
31 |
+
protected $shopId;
|
32 |
+
|
33 |
+
/** @var array $ibParams */
|
34 |
+
protected $ibParams;
|
35 |
+
|
36 |
+
/** @var boolean $authorized */
|
37 |
+
protected $authorized;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* ItembaseRequest constructor.
|
41 |
+
*
|
42 |
+
* @param boolean $authorized
|
43 |
+
* @param string|int $shopId
|
44 |
+
*/
|
45 |
+
public function __construct($authorized, $shopId)
|
46 |
+
{
|
47 |
+
$this->authorized = $authorized;
|
48 |
+
|
49 |
+
$this->token = $_GET[self::GET_REQUEST_TOKEN];
|
50 |
+
$this->action = $_GET[self::GET_REQUEST_METHOD];
|
51 |
+
|
52 |
+
if (!empty($shopId)) {
|
53 |
+
$this->shopId = $shopId;
|
54 |
+
}
|
55 |
+
|
56 |
+
foreach ($_GET as $key => $value) {
|
57 |
+
if ($key == "ib_method" || $key == "ib_token") {
|
58 |
+
continue;
|
59 |
+
}
|
60 |
+
|
61 |
+
if (strpos($key, "ib_") === 0) {
|
62 |
+
$this->ibParams[$key] = $value;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
if (!empty($this->ibParams['ib_api_key'])) {
|
67 |
+
$this->apiKey = $this->ibParams['ib_api_key'];
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Getter for action value passed via GET parameter ib_method
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function getAction()
|
77 |
+
{
|
78 |
+
return $this->action;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Getter for token value passed via GET parameter ib_token
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function getToken()
|
87 |
+
{
|
88 |
+
return $this->token;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Getter for action value passed via GET parameter ib_api_key
|
93 |
+
*
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function getApiKey()
|
97 |
+
{
|
98 |
+
return $this->apiKey;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Getter for shop ID value passed via GET parameter ib_shop_id
|
103 |
+
*
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function getShopId()
|
107 |
+
{
|
108 |
+
return $this->shopId;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Getter for all GET parameters which has ib_ prefix
|
113 |
+
*
|
114 |
+
* @return array
|
115 |
+
*/
|
116 |
+
public function getIbParams()
|
117 |
+
{
|
118 |
+
return $this->ibParams;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Getter for returning the authorization status of the request.
|
123 |
+
*
|
124 |
+
* @return boolean
|
125 |
+
*/
|
126 |
+
public function isAuthorized()
|
127 |
+
{
|
128 |
+
return $this->authorized;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Helper method allowing to match passed actions with the current requested and specify if request needs to be
|
133 |
+
* authorized.
|
134 |
+
*
|
135 |
+
* @param array $actions
|
136 |
+
* @param bool|true $authRequired
|
137 |
+
*
|
138 |
+
* @return bool
|
139 |
+
* @throws \Exception
|
140 |
+
*/
|
141 |
+
public function matchActions($actions, $authRequired = true)
|
142 |
+
{
|
143 |
+
if (in_array($this->getAction(), $actions)) {
|
144 |
+
if ($authRequired and !$this->isAuthorized()) {
|
145 |
+
throw new \Exception("Unauthorized access");
|
146 |
+
}
|
147 |
+
|
148 |
+
return true;
|
149 |
+
}
|
150 |
+
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/RequestAwareInterface.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Http;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface RequestAwareInterface
|
6 |
+
*
|
7 |
+
* When some service/extension need to handle request from itembase server and send back some data/response back to
|
8 |
+
* itembase server it should implement RequestAwareInterface interface.
|
9 |
+
*
|
10 |
+
* HttpHandler use these implementations to prepare Response object for each service/extension which implements
|
11 |
+
* RequestAwareInterface interface and also pass the actual Request object.
|
12 |
+
*
|
13 |
+
* @package Itembase\Psdk\Http
|
14 |
+
* @author Serghei Ilin <si@itembase.biz>
|
15 |
+
* @copyright (c) 2016 itembase GmbH
|
16 |
+
*/
|
17 |
+
interface RequestAwareInterface
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Method will be called when the request will be done from itembase server to the plugin.
|
21 |
+
*
|
22 |
+
* @param Request $request
|
23 |
+
* @param Response $response
|
24 |
+
*
|
25 |
+
* @return void
|
26 |
+
*/
|
27 |
+
public function handleRequest(Request $request, Response $response);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Method is called to get response type name. It's necessary for backend to know what extension/service is replying
|
31 |
+
* to request. It's possible that several extensions/services reply to one request.
|
32 |
+
*
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getResponseType();
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Method is called to get response version. It's necessary for backend to know what output version extension/service
|
39 |
+
* is replying to request. It's possible that several extensions/services reply to one request with different
|
40 |
+
* versions.
|
41 |
+
*
|
42 |
+
* (!) IMPORTANT. Please change version for ANY changes (even not BC ones). So if you added a new field (which is
|
43 |
+
* not BC) in output - version must be changed.
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function getResponseVersion();
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Method is called to get request version. It's necessary for backend to know what input version extension/service
|
51 |
+
* is replying to request. It's possible that several extensions/services reply to one request with different
|
52 |
+
* versions.
|
53 |
+
*
|
54 |
+
* (!) IMPORTANT. Please change version for ANY changes (even not BC ones). So if you added a new field (which is
|
55 |
+
* not BC) in output - version must be changed.
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getRequestVersion();
|
60 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/Response.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Http;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Response
|
6 |
+
*
|
7 |
+
* Class represent response for itembase server request. Response class should not be treated like framework-quality.
|
8 |
+
* It's only to represent response data for itembase server.
|
9 |
+
*
|
10 |
+
* @package Itembase\Psdk\Http
|
11 |
+
* @author Serghei Ilin <si@itembase.biz>
|
12 |
+
* @copyright (c) 2016 itembase GmbH
|
13 |
+
*/
|
14 |
+
class Response
|
15 |
+
{
|
16 |
+
/** @var array $body */
|
17 |
+
protected $body;
|
18 |
+
|
19 |
+
/** @var string $type */
|
20 |
+
protected $type;
|
21 |
+
|
22 |
+
/** @var string $version */
|
23 |
+
protected $version;
|
24 |
+
|
25 |
+
/** @var string $isRedirect */
|
26 |
+
protected $isRedirect;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Constructor accept response type and version value which HttpHandler is getting from extension implementing
|
30 |
+
* RequestAwareInterface.
|
31 |
+
*
|
32 |
+
* @param string $responseType
|
33 |
+
* @param string $version
|
34 |
+
*/
|
35 |
+
public function __construct($responseType, $version)
|
36 |
+
{
|
37 |
+
$this->type = $responseType;
|
38 |
+
$this->version = $version;
|
39 |
+
$this->body = null;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add some data to response and set a key for it. If some data was set for that key previously - it will be replaced
|
44 |
+
* with the new value.
|
45 |
+
*
|
46 |
+
* @param string $key
|
47 |
+
* @param mixed $data
|
48 |
+
*/
|
49 |
+
public function add($key, $data)
|
50 |
+
{
|
51 |
+
$this->body[$key] = $data;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Getter to get value stored in response associated for key.
|
56 |
+
*
|
57 |
+
* @param string $key
|
58 |
+
*
|
59 |
+
* @return null|mixed
|
60 |
+
*/
|
61 |
+
public function get($key)
|
62 |
+
{
|
63 |
+
if (!empty($this->body[$key])) {
|
64 |
+
return $this->body[$key];
|
65 |
+
}
|
66 |
+
|
67 |
+
return null;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Setter allows to set complete response at once. It will overwrite all previous data in response. Data parameter
|
72 |
+
* can be array or an object.
|
73 |
+
*
|
74 |
+
* @param array|mixed $data
|
75 |
+
*/
|
76 |
+
public function setData($data)
|
77 |
+
{
|
78 |
+
$this->body = $data;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Getter for response type
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function getType()
|
87 |
+
{
|
88 |
+
return $this->type;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Getter for response version
|
93 |
+
*
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function getVersion()
|
97 |
+
{
|
98 |
+
return $this->version;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Getter for the available data in response. Data can be array (if only add() method was used) or mixed if
|
103 |
+
* setData() was used (because setData() allows to set objects as well). Also it's possible to get NULL if nothing
|
104 |
+
* was set. You can check that by calling isEmpty() method.
|
105 |
+
*
|
106 |
+
* @return array|mixed|null
|
107 |
+
*/
|
108 |
+
public function getData()
|
109 |
+
{
|
110 |
+
return $this->body;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Checks if response contains any data or not.
|
115 |
+
*
|
116 |
+
* @return bool
|
117 |
+
*/
|
118 |
+
public function isEmpty()
|
119 |
+
{
|
120 |
+
if (is_array($this->body) || is_string($this->body)) {
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
return empty($this->body);
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* @return string
|
129 |
+
*/
|
130 |
+
public function isRedirect()
|
131 |
+
{
|
132 |
+
return $this->isRedirect;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @param string $isRedirect
|
137 |
+
*/
|
138 |
+
public function setRedirect($isRedirect)
|
139 |
+
{
|
140 |
+
$this->isRedirect = $isRedirect;
|
141 |
+
}
|
142 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Http/ResponseAwareInterface.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Http;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface ResponseAwareInterface
|
6 |
+
*
|
7 |
+
* When some service/extension need to just return some data to itembase server (without handling request) it should
|
8 |
+
* implement ResponseAwareInterface interface.
|
9 |
+
*
|
10 |
+
* HttpHandler use these implementations to prepare Response object for each service/extension.
|
11 |
+
*
|
12 |
+
* @package Itembase\Psdk\Http
|
13 |
+
* @author Serghei Ilin <si@itembase.biz>
|
14 |
+
* @copyright (c) 2016 itembase GmbH
|
15 |
+
*/
|
16 |
+
interface ResponseAwareInterface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Returns name of the response type. Most of the time it will be service name.
|
20 |
+
* Used by backend to correctly parse response of the service.
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getResponseType();
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Returns response version of the service. It's vital to have it so backend can use correct mappings for the
|
28 |
+
* response.
|
29 |
+
*
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getResponseVersion();
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Method is called to get request version. It's necessary for backend to know what input version extension/service
|
36 |
+
* is replying to request. It's possible that several extensions/services reply to one request with different
|
37 |
+
* versions.
|
38 |
+
*
|
39 |
+
* (!) IMPORTANT. Please change version for ANY changes (even not BC ones). So if you added a new field (which is
|
40 |
+
* not BC) in output - version must be changed.
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getRequestVersion();
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Setter to receive Response object for the specific service
|
48 |
+
*
|
49 |
+
* @param Response $response
|
50 |
+
*
|
51 |
+
* @return void
|
52 |
+
*/
|
53 |
+
public function setResponse(Response $response);
|
54 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/Frontend/ControllerInterface.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Itembase\Psdk\Platform\Frontend;
|
4 |
+
|
5 |
+
use Itembase\Psdk\Http\Request;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Interface ControllerInterface
|
9 |
+
*
|
10 |
+
* ControllerInterface is an interface to provide developer possibility to make a platform specific renderer of the SDK
|
11 |
+
* response or to handle response manually.
|
12 |
+
*
|
13 |
+
* It should be available in ServiceContainer by tag Itembase\Psdk\Http\HttpHandler::FRONTEND_RESPONSE_HANDLER.
|
14 |
+
*
|
15 |
+
* It's important to use predefined list of platform names, because backend service is depending on correct platform
|
16 |
+
* name
|
17 |
+
*
|
18 |
+
* @package Itembase\Psdk\Platform\Frontend
|
19 |
+
* @author Serghei Ilin <si@itembase.biz>
|
20 |
+
* @copyright (c) 2016 itembase GmbH
|
21 |
+
*/
|
22 |
+
interface ControllerInterface
|
23 |
+
{
|
24 |
+
public function renderResponse(Request $request, $responses);
|
25 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/MultishopAbstract.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Itembase\Psdk\Platform\MultiShop;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Interface MultiShopInterface
|
7 |
+
*
|
8 |
+
* That abstract class is used to have a collection to store available shops.
|
9 |
+
*
|
10 |
+
* Itembase\Psdk\Core class requires implementation of that abstract class to be presented in ServiceContainer as
|
11 |
+
* "multishop".
|
12 |
+
*
|
13 |
+
* @package Itembase\Psdk\MultiShop
|
14 |
+
* @author Serghei Ilin <si@itembase.biz>
|
15 |
+
* @copyright (c) 2016 itembase GmbH
|
16 |
+
*/
|
17 |
+
abstract class MultishopAbstract
|
18 |
+
{
|
19 |
+
const REGISTERED_STORAGE_FLAG = "registered";
|
20 |
+
|
21 |
+
/** @var array $list */
|
22 |
+
private $list = null;
|
23 |
+
|
24 |
+
/** @var Shop $currentShop */
|
25 |
+
private $currentShop = null;
|
26 |
+
|
27 |
+
/** @var boolean $initialized */
|
28 |
+
private $initialized = false;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Abstract method which developer need to implement. It should return indexed array of Shop objects.
|
32 |
+
* If platform doesn't support multi-shop system - at least one Shop object should be returned.
|
33 |
+
*
|
34 |
+
* @return array|null
|
35 |
+
*/
|
36 |
+
abstract protected function getShops();
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Return true if multi-shop is supported by platform and false otherwise.
|
40 |
+
*
|
41 |
+
* @return boolean
|
42 |
+
*/
|
43 |
+
abstract public function isMultiShop();
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Getting currently active shop. If multi-shop is not supported main shop information is returned. If getList()
|
47 |
+
* will not return currently active shop for some reason - first one will be picked as current shop.
|
48 |
+
*
|
49 |
+
* @return Shop|null
|
50 |
+
*
|
51 |
+
* @throws \Exception
|
52 |
+
*/
|
53 |
+
public function getCurrentShop()
|
54 |
+
{
|
55 |
+
$this->init();
|
56 |
+
|
57 |
+
return $this->currentShop;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Returns whole list of all available Shop objects.
|
62 |
+
*
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
public function getList()
|
66 |
+
{
|
67 |
+
$this->init();
|
68 |
+
|
69 |
+
return $this->list;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Internal method of the class. Used to fill list array with the shops returned by implemented getShops() method,
|
74 |
+
* initialize class properties.
|
75 |
+
*
|
76 |
+
* In case when multi-shop is available and if there is no Shop object from the getShops() method has
|
77 |
+
* currentlyActive = true - first shop from the list is considered as active.
|
78 |
+
*
|
79 |
+
* Method throw exception is case if getShops() returns empty array, or returns non-null or non-array value and
|
80 |
+
* item from the list is not Shop object.
|
81 |
+
*
|
82 |
+
* @throws \Exception
|
83 |
+
*/
|
84 |
+
private function init()
|
85 |
+
{
|
86 |
+
if (true === $this->initialized) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->initialized = true;
|
91 |
+
$this->list = $this->getShops();
|
92 |
+
|
93 |
+
if (null == $this->list) {
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
|
97 |
+
if (!is_array($this->list)) {
|
98 |
+
throw new \Exception("getShops() should return array or null");
|
99 |
+
}
|
100 |
+
|
101 |
+
if (count($this->list) == 0) {
|
102 |
+
throw new \Exception("At least one shop must be returned or null in case if multi-shop is not supported");
|
103 |
+
}
|
104 |
+
|
105 |
+
/** @var Shop $item */
|
106 |
+
foreach ($this->list as $item) {
|
107 |
+
if (!$item instanceof Shop) {
|
108 |
+
throw new \Exception("Shop object is expected to be returned");
|
109 |
+
}
|
110 |
+
|
111 |
+
if ($item->currentlyActive) {
|
112 |
+
$this->currentShop = $item;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
if (empty($this->currentShop)) {
|
117 |
+
$this->currentShop = $this->list[0];
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/MultiShop/Shop.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Itembase\Psdk\Platform\MultiShop;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Shop
|
6 |
+
*
|
7 |
+
* Shop class represents instance of this shop in multi-shop.
|
8 |
+
*
|
9 |
+
* @package Itembase\Psdk\MultiShop
|
10 |
+
* @author Serghei Ilin <si@itembase.biz>
|
11 |
+
* @copyright (c) 2016 itembase GmbH
|
12 |
+
*/
|
13 |
+
class Shop
|
14 |
+
{
|
15 |
+
/** @var int Platform specific ID of the shop */
|
16 |
+
public $id;
|
17 |
+
|
18 |
+
/** @var string URL of the shop */
|
19 |
+
public $url;
|
20 |
+
|
21 |
+
/** @var string Name of the shop */
|
22 |
+
public $name;
|
23 |
+
|
24 |
+
/** @var string Main currency of the shop */
|
25 |
+
public $currency;
|
26 |
+
|
27 |
+
/** @var string Default language of the shop. Should be provided as ISO 639-1 code */
|
28 |
+
public $defaultLanguage;
|
29 |
+
|
30 |
+
/** @var string Timezone of the shop. Should PHP timezone value, like: Europe/Berlin */
|
31 |
+
public $timezone;
|
32 |
+
|
33 |
+
/** @var boolean Value is "true" if current request is "targeted" to that shop. */
|
34 |
+
public $currentlyActive;
|
35 |
+
|
36 |
+
/** @var boolean Value is "true" if shop is main/default in shopping system */
|
37 |
+
public $default;
|
38 |
+
|
39 |
+
/** @var boolean Value is "true" if shop is already registered (has REGISTERED_STORAGE_FLAG set in storage)*/
|
40 |
+
public $registered;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Developer can use constructor to set data about shop. All parameters are optional
|
44 |
+
*
|
45 |
+
* @param int $id
|
46 |
+
* @param string $url
|
47 |
+
* @param string $name
|
48 |
+
* @param string $currency
|
49 |
+
* @param string $defaultLanguage
|
50 |
+
* @param string $timezone
|
51 |
+
* @param bool $currentlyActive
|
52 |
+
* @param bool $default
|
53 |
+
* @param bool $registered
|
54 |
+
*/
|
55 |
+
public function __construct($id = null, $url = null, $name = null, $currency = null, $defaultLanguage = null,
|
56 |
+
$timezone = null, $currentlyActive = false, $default = false, $registered = false)
|
57 |
+
{
|
58 |
+
$this->id = $id;
|
59 |
+
$this->url = $url;
|
60 |
+
$this->name = $name;
|
61 |
+
$this->currency = $currency;
|
62 |
+
$this->defaultLanguage = $defaultLanguage;
|
63 |
+
$this->timezone = $timezone;
|
64 |
+
$this->currentlyActive = $currentlyActive;
|
65 |
+
$this->default = $default;
|
66 |
+
$this->registered = $registered;
|
67 |
+
}
|
68 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/PlatformInterface.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Itembase\Psdk\Platform;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Interface PlatformInterface
|
7 |
+
*
|
8 |
+
* PlatformInterface is an interface to abstract platform information
|
9 |
+
* It's a necessary to implement that interface, because SDK core is rely on it to get detailed information about
|
10 |
+
* platform
|
11 |
+
*
|
12 |
+
* It should be available in ServiceContainer by tag "platform".
|
13 |
+
*
|
14 |
+
* It's important to use predefined list of platform names, because backend service is depending on correct platform
|
15 |
+
* name
|
16 |
+
*
|
17 |
+
* @package Itembase\Psdk\Platform
|
18 |
+
* @author Serghei Ilin <si@itembase.biz>
|
19 |
+
* @copyright (c) 2016 itembase GmbH
|
20 |
+
*/
|
21 |
+
interface PlatformInterface
|
22 |
+
{
|
23 |
+
const MAGENTO = "magento";
|
24 |
+
const PRESTASHOP = "prestashop";
|
25 |
+
const WOOCOMMERCE = "woocommerce";
|
26 |
+
const VIRTUEMART = "virtuemart";
|
27 |
+
const OPENCART = "opencart";
|
28 |
+
const GAMBIO = "gambio";
|
29 |
+
const SHOPWARE = "shopware";
|
30 |
+
const SPREECOMMERCE = "spreecommerce";
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Method should return the name of the platform where plugin is running.
|
34 |
+
* It should be one of the provided platform names constants.
|
35 |
+
*
|
36 |
+
* If necessary one is missing - please contact itembase developers.
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getName();
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Method should return current version of the platform where plugin is running.
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function getVersion();
|
48 |
+
}
|
lib/ac/itembase/psdk2/src/Itembase/Psdk/Platform/StorageInterface.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Itembase\Psdk\Platform;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Interface StorageInterface
|
7 |
+
*
|
8 |
+
* StorageInterface is an interface to abstract storage manipulation for different platforms.
|
9 |
+
* It's a necessary to implement that interface, because SDK core is rely on having it implemented and all storing
|
10 |
+
* operation will use it.
|
11 |
+
*
|
12 |
+
* It should be available in ServiceContainer by tag "storage".
|
13 |
+
*
|
14 |
+
* @package Itembase\Psdk\Platform
|
15 |
+
* @author Serghei Ilin <si@itembase.biz>
|
16 |
+
* @copyright (c) 2016 itembase GmbH
|
17 |
+
*/
|
18 |
+
interface StorageInterface
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Method allows developer to store new or update existing value in the platform storage. Implementation should take
|
22 |
+
* in consideration "shopId" parameter which distinguish values for different shops.
|
23 |
+
*
|
24 |
+
* So it's possible to have same "key" for the "value" for different "shopId".
|
25 |
+
*
|
26 |
+
* Also it's possible that some values are global for all shops or shop system doesn't support multi-shop. So
|
27 |
+
* "shopId" in these cases can be NULL, so implementation should be done keeping that in mind.
|
28 |
+
*
|
29 |
+
* @param string $key
|
30 |
+
* @param null|string $shopId
|
31 |
+
*
|
32 |
+
* @return null|string
|
33 |
+
*/
|
34 |
+
public function get($key, $shopId);
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Method returns existing value in the platform storage. Implementation should take in consideration "shopId"
|
38 |
+
* parameter which distinguish values for different shops.
|
39 |
+
*
|
40 |
+
* So it's possible to have same "key" for the "value" for different "shopId".
|
41 |
+
*
|
42 |
+
* Also it's possible that some values are global for all shops or shop system doesn't support multi-shop. So
|
43 |
+
* "shopId" in these cases can be NULL, so implementation should be done keeping that in mind.
|
44 |
+
*
|
45 |
+
* @param string $key
|
46 |
+
* @param string $value
|
47 |
+
* @param string $shopId
|
48 |
+
*
|
49 |
+
* @throws \Exception
|
50 |
+
*/
|
51 |
+
public function save($key, $value, $shopId);
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Method returns shop id in platform by some key and it's value which will make sure it's assign only for the
|
55 |
+
* specific shop, e.g. client_id of the credentials
|
56 |
+
*
|
57 |
+
* Also it's possible that some values are global for all shops or shop system doesn't support multi-shop. So
|
58 |
+
* "shopId" in these cases can be NULL, so implementation should be done keeping that in mind.
|
59 |
+
*
|
60 |
+
* @param string $key
|
61 |
+
* @param string $value
|
62 |
+
*
|
63 |
+
* @return int|string $shopId
|
64 |
+
*
|
65 |
+
* @throws \Exception
|
66 |
+
*/
|
67 |
+
public function getShopIdBy($key, $value);
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Method sets assoc array with simple key as a key of array and platform specific key as a value. Handy to use
|
71 |
+
* when platform system has key-spaces or more complex storage.
|
72 |
+
*
|
73 |
+
* @param array $map Key to platform key mapping array
|
74 |
+
*/
|
75 |
+
public function setKeyMapping($map);
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Method returns assoc array with simple key as a key of array and platform specific key as a value.
|
79 |
+
*
|
80 |
+
* @return array Key to platform key mapping array
|
81 |
+
*/
|
82 |
+
public function getKeyMapping();
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Method sets keyspace for values inside platform storage. Please keep in mind - if set used for both: get and set
|
86 |
+
*
|
87 |
+
* @param string $keyspace Keyspace for storage values
|
88 |
+
*/
|
89 |
+
public function setKeyspace($keyspace);
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Method returns keyspace value which was set previously
|
93 |
+
*
|
94 |
+
* @return string Keyspace for storage values
|
95 |
+
*/
|
96 |
+
public function getKeyspace();
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Method allows developer to delete existing value in the platform storage. Implementation should take
|
100 |
+
* in consideration "shopId" parameter which distinguish values for different shops.
|
101 |
+
*
|
102 |
+
* So it's possible to have same "key" for the "value" for different "shopId".
|
103 |
+
*
|
104 |
+
* Also it's possible that some values are global for all shops or shop system doesn't support multi-shop. So
|
105 |
+
* "shopId" in these cases can be NULL, so implementation should be done keeping that in mind.
|
106 |
+
*
|
107 |
+
* @param string $key
|
108 |
+
* @param null|string $shopId
|
109 |
+
*
|
110 |
+
* @return void
|
111 |
+
*/
|
112 |
+
public function delete($key, $shopId);
|
113 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>actonlytics_magento</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Actonlytics plugin for Magento 1.7.x - 1.9.x plugin</summary>
|
10 |
+
<description>Actonlytics plugin for Magento 1.7.x - 1.9.x plugin</description>
|
11 |
+
<notes>Actonlytics Magento plugin</notes>
|
12 |
+
<authors><author><name>actonlytics</name><user>actonlytics</user><email>si@itembase.biz</email></author></authors>
|
13 |
+
<date>2016-05-31</date>
|
14 |
+
<time>10:42:12</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Actonlytics_Plugin.xml" hash="d846caba7d2567b4abbbac566198b2b6"/><file name="Actonlytics_Signup.xml" hash="ca2d0ec53913ac43ab72b1636c799d19"/></dir></target><target name="magecommunity"><dir name="Actonlytics"><dir name="Plugin"><dir name="controllers"><file name="IndexController.php" hash="7d8def62076850de4caaf47a00308569"/></dir><dir name="etc"><file name="build.php" hash="885eab4cf4f1e6e1fe712cd6e6aaeda6"/><file name="config.xml" hash="2240ec596ee7ccf4b62bba037adfac66"/><file name="system.xml" hash="2ec5303b5cf768a3c80a1a77bb2f4d70"/></dir></dir><dir name="Signup"><dir name="Block"><file name="Button.php" hash="fbe6eae7d8199be5d7fd445ad42c395b"/><file name="Content.php" hash="739a84ee31f12631d3c45db2d4c70a6e"/></dir><dir name="Helper"><file name="Data.php" hash="a03b7521d2d8e56257bdd3e3c3cbeb84"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ActonlyticssignupController.php" hash="04ce7f883d7245acfb7c6c13cfc4054b"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="afd9333d7fe606b90a7c0d9cdecfcce5"/><file name="config.xml" hash="a036b28c9cca92183ef89f2cf4cbd0c7"/><file name="system.xml" hash="b51533c468029c194f7b075233d57643"/></dir></dir></dir></target><target name="magelib"><dir name="ac"><file name="autoload.php" hash="b7719e046172591495ad665d80d9db27"/><dir name="composer"><file name="ClassLoader.php" hash="c67ebce5ff31e99311ceb750202adf2e"/><file name="LICENSE" hash="9b01fc9e0129adc080344653fbcbbc0f"/><file name="autoload_classmap.php" hash="d33f279ef1a90422a3a8d8635a716de2"/><file name="autoload_namespaces.php" hash="b6d394d7a469fe5ed568b82c62d49965"/><file name="autoload_psr4.php" hash="e3ee54f9f6a820b674c2cf20666ced5f"/><file name="autoload_real.php" hash="86e06384657abb144ff1b2cbd5e063a4"/></dir><dir name="itembase"><dir name="m1-ext-data"><dir name="src"><dir name="Itembase"><dir name="PluginExtension"><dir name="Data"><file name="Extension.php" hash="852e77d80f6c12efd454c4f404d58f28"/></dir></dir></dir></dir></dir><dir name="m1-ext-multishop"><dir name="src"><dir name="Itembase"><dir name="PluginExtension"><dir name="Multishop"><file name="Extension.php" hash="d6cf15c02d8b39e84ad695230506d31e"/><file name="Multishop.php" hash="35d6f74fb6070565e1b02c868b98dca2"/></dir></dir></dir></dir></dir><dir name="m1-ext-platform"><dir name="src"><dir name="Itembase"><dir name="PluginExtension"><dir name="Platform"><file name="Extension.php" hash="a6591275e47ba917d2f8f0df6c78a800"/><file name="Platform.php" hash="8379724ffc9b81cdca2db8f924e7abe1"/></dir></dir></dir></dir></dir><dir name="m1-ext-storage"><dir name="src"><dir name="Itembase"><dir name="PluginExtension"><dir name="Storage"><file name="Extension.php" hash="8464cecfe6facff2fb99e4b24c72cecc"/><file name="Storage.php" hash="fe865517207ce8f904db07cc3328b7fb"/></dir></dir></dir></dir></dir><dir name="psdk2"><file name="LICENSE.txt" hash="0eefd483afaa801044b150edb7fc2b6c"/><dir name="src"><dir name="Itembase"><dir name="Psdk"><dir name="Container"><file name="ContainerAwareInterface.php" hash="e8d56caf79e421215413182df8e37035"/><file name="ServiceContainer.php" hash="4162bace332366f635c61f4f027120e7"/></dir><dir name="Core"><file name="ExceptionHandler.php" hash="06fe75768702fe30dd641b13249767a2"/><file name="Logger.php" hash="62e98aa071ade6c23c84bc0f9652f6fb"/><file name="OAuthClient.php" hash="717ec672f180749926c3dd5f6c6d88cf"/><file name="PingHandler.php" hash="3d23963795d6fc7fbb181d6ffe2f4155"/></dir><file name="Core.php" hash="05425c0a1289cb52dc6f53b69d056623"/><dir name="Event"><file name="EventAwareInterface.php" hash="a75ee820c5ec05821d0220460d65bf83"/><file name="EventDispatcher.php" hash="830ea282c3b0946f6a17f3ec4e3c2dc1"/><file name="EventListenerInterface.php" hash="db474bbd17e6ed36119dc81f38dcaf5b"/></dir><dir name="Extension"><file name="ExtensionInterface.php" hash="d6ccf2283c891964801b6892f9385ab3"/><file name="ExtensionsLoader.php" hash="c05cbffbbb1f0d7955a09d9d55fac9af"/></dir><dir name="Http"><file name="HttpClient.php" hash="4fb43ac7473895df8bfdb81ae52afbc5"/><file name="HttpHandler.php" hash="ebce0c67b41de2d5e8970b509ae9a1e8"/><file name="Request.php" hash="33adb382766bd2fe82b8d82bf6164210"/><file name="RequestAwareInterface.php" hash="485b8e80a1a4b11831f9c5b3d8c7fe8c"/><file name="Response.php" hash="fa83442d94a5fe68ddb7bd3136671b53"/><file name="ResponseAwareInterface.php" hash="6cbe74b515f26dc974930da4f683348f"/></dir><dir name="Platform"><dir name="Frontend"><file name="ControllerInterface.php" hash="90b09c69f6d58eec61adbfa40a16a1d5"/></dir><dir name="MultiShop"><file name="MultishopAbstract.php" hash="5fdd99d9a881c0577a3ff37ffbbca9c3"/><file name="Shop.php" hash="beb2260b42ad7148a59bb93f48e54a37"/></dir><file name="PlatformInterface.php" hash="e545be957dc2612b3926c8b89e2e2483"/><file name="StorageInterface.php" hash="9165670a562789b34ac105e38e188eaa"/></dir></dir></dir></dir></dir><dir name="psdk2-ext-data"><dir name="src"><dir name="Itembase"><dir name="PsdkExtension"><dir name="Data"><file name="Extension.php" hash="f1f758b82d3bd4c1153e2fbcedae013d"/><file name="FetcherInterface.php" hash="182855a0f7ba96e42cc8b23191533772"/></dir></dir></dir></dir></dir><dir name="psdk2-ext-remotefs"><dir name="src"><dir name="Itembase"><dir name="PsdkExtension"><dir name="RemoteFS"><file name="Extension.php" hash="ec9fbefff7f14d8eec98a103b2defef7"/><file name="Filesystem.php" hash="eb36f6166af9526c1e3bd221ee4f61f6"/></dir></dir></dir></dir></dir><dir name="psdk2-ext-signup"><dir name="src"><dir name="Itembase"><dir name="PsdkExtension"><dir name="Signup"><file name="Extension.php" hash="abbb669600f14406b88c861ff0348060"/></dir></dir></dir></dir></dir><dir name="psdk2-ext-sysinfo"><dir name="src"><dir name="Itembase"><dir name="PsdkExtension"><dir name="SysInfo"><file name="Extension.php" hash="9bd72d7fe13e6f088681a647724a7f3a"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.10</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|