<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/
use Pimcore\Tool;
use Symfony\Component\HttpFoundation\Request;
include __DIR__ . "/../vendor/autoload.php";
const PIMCORE_KERNEL_CLASS = '\WebAppBundle\Kernel';
\Pimcore\Bootstrap::setProjectRoot();
\Pimcore\Bootstrap::bootstrap();
// CORS headers
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, PATCH');
header('Access-Control-Allow-Headers: DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization');
header('Access-Control-Expose-Headers: Content-Length, Content-Range');
// Handle OPTIONS preflight request
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
header('Access-Control-Max-Age: 1728000');
header('Content-Type: text/plain; charset=utf-8');
header('Content-Length: 0');
http_response_code(204);
exit;
}
$request = Request::createFromGlobals();
// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);
/** @var \Pimcore\Kernel $kernel */
$kernel = \Pimcore\Bootstrap::kernel();
// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);