forked from ezsystems/ezpublish-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
64 lines (56 loc) · 2.48 KB
/
bootstrap.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* File containing the bootstrapping of eZ Publish API for unit test use
*
* Setups class loading.
*
* @copyright Copyright (C) 1999-2014 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version //autogentag//
*/
use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel;
use eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler as LegacyKernelCLI;
// Get global config.php settings
if ( !( $settings = include ( __DIR__ . '/config.php' ) ) )
{
throw new \RuntimeException( 'Could not find config.php, please copy config.php-DEVELOPMENT to config.php & customize to your needs!' );
}
// Setup class loader, detect ezpublish-community repo context and use vendor files from there if that is the case
$rootDir = __DIR__;
if ( ( $vendorPathPos = strrpos( $rootDir, '/vendor/ezsystems/ezpublish' ) ) !== false )
$rootDir = substr( $rootDir, 0, $vendorPathPos );
require_once $rootDir . "/vendor/autoload.php";
// Bootstrap eZ Publish legacy kernel if configured
if ( !empty( $settings['service']['parameters']['legacy_dir'] ) )
{
if ( !defined( 'EZCBASE_ENABLED' ) )
{
define( 'EZCBASE_ENABLED', false );
require_once $settings['service']['parameters']['legacy_dir'] . '/autoload.php';
}
// Define $legacyKernelHandler to whatever you need before loading this bootstrap file.
// CLI handler is used by defaut, but you must use \ezpKernelWeb if not in CLI context (i.e. REST server)
// $legacyKernelHandler can be a closure returning the appropriate kernel handler (to avoid autoloading issues)
if ( isset( $legacyKernelHandler ) )
{
$legacyKernelHandler = $legacyKernelHandler instanceof \Closure ? $legacyKernelHandler() : $legacyKernelHandler;
}
else
{
$legacyKernelHandler = new LegacyKernelCLI;
}
$legacyKernel = new LegacyKernel( $legacyKernelHandler, $settings['service']['parameters']['legacy_dir'], getcwd() );
set_exception_handler( null );
// Avoid "Fatal error" text from legacy kernel if not called
$legacyKernel->runCallback(
function ()
{
eZExecution::setCleanExit();
}
);
// Exposing in env variables in order be able to use them in test cases.
$_ENV['legacyKernel'] = $legacyKernel;
$_ENV['legacyPath'] = $settings['service']['parameters']['legacy_dir'];
$_ENV['imagemagickConvertPath'] = $settings['service']['parameters']['imagemagick_convert_path'];
}
return include 'container.php';