-
Notifications
You must be signed in to change notification settings - Fork 5
/
Connector.php
42 lines (37 loc) · 1.15 KB
/
Connector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use Shopware\Components\CSRFWhitelistAware;
class Shopware_Controllers_Frontend_Jtlconnector extends Enlight_Controller_Action implements CSRFWhitelistAware
{
public function getWhitelistedCSRFActions()
{
return [
'index'
];
}
public function preDispatch()
{
if (in_array($this->Request()->getActionName(), array('index'))) {
Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender();
}
}
public function indexAction()
{
session_destroy();
if(!defined('CONNECTOR_DIR')) {
define('CONNECTOR_DIR', __DIR__);
}
$bootstrapFile = sprintf('%s/src/bootstrap.php', CONNECTOR_DIR);
if(!file_exists($bootstrapFile)) {
throw new \Exception('Could not find src/bootstrap.php. Something is very wrong!');
}
$application = null;
try {
require_once $bootstrapFile;
} catch (\Exception $e) {
if (is_object($application)) {
$handler = $application->getErrorHandler()->getExceptionHandler();
$handler($e);
}
}
}
}