-
Notifications
You must be signed in to change notification settings - Fork 31
/
bootstrap.php
52 lines (44 loc) · 2.35 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
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
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 (!file_exists(__DIR__ . '/config.php')) {
if (!symlink(__DIR__ . '/config.php-DEVELOPMENT', __DIR__ . '/config.php')) {
throw new \RuntimeException('Could not symlink config.php-DEVELOPMENT to config.php, please copy config.php-DEVELOPMENT to config.php & customize to your needs!');
}
}
if (!($settings = include(__DIR__ . '/config.php'))) {
throw new \RuntimeException('Could not read 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['legacy_dir'])) {
if (!defined('EZCBASE_ENABLED')) {
define('EZCBASE_ENABLED', false);
require_once $settings['legacy_dir'] . '/autoload.php';
}
if (empty($_ENV['legacyKernel'])) {
// 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['legacy_dir'], getcwd());
// Exposing in env variables in order be able to use them in test cases.
$_ENV['legacyKernel'] = $legacyKernel;
$_ENV['legacyPath'] = $settings['legacy_dir'];
}
$_ENV['imagemagickConvertPath'] = $settings['imagemagick_convert_path'];
}