Neos\Flow\Core\Bootstrap::defineConstants PHP Méthode

defineConstants() protected méthode

Defines various path constants used by Flow and if no root path or web root was specified by an environment variable, exits with a respective error message.
protected defineConstants ( ) : void
Résultat void
    protected function defineConstants()
    {
        if (defined('FLOW_SAPITYPE')) {
            return;
        }
        define('FLOW_SAPITYPE', PHP_SAPI === 'cli' ? 'CLI' : 'Web');
        if (!defined('FLOW_PATH_FLOW')) {
            define('FLOW_PATH_FLOW', str_replace('//', '/', str_replace('\\', '/', __DIR__ . '/../../')));
        }
        if (!defined('FLOW_PATH_ROOT')) {
            $rootPath = isset($_SERVER['FLOW_ROOTPATH']) ? $_SERVER['FLOW_ROOTPATH'] : false;
            if ($rootPath === false && isset($_SERVER['REDIRECT_FLOW_ROOTPATH'])) {
                $rootPath = $_SERVER['REDIRECT_FLOW_ROOTPATH'];
            }
            if (FLOW_SAPITYPE === 'CLI' && $rootPath === false) {
                $rootPath = getcwd();
                if (realpath(__DIR__) !== realpath($rootPath . '/Packages/Framework/Neos.Flow/Classes/Core')) {
                    echo 'Neos Flow: Invalid root path. (Error #1301225173)' . PHP_EOL . 'You must start Neos Flow from the root directory or set the environment variable FLOW_ROOTPATH correctly.' . PHP_EOL;
                    exit(1);
                }
            }
            if ($rootPath !== false) {
                $rootPath = Files::getUnixStylePath(realpath($rootPath)) . '/';
                $testPath = Files::getUnixStylePath(realpath(Files::concatenatePaths([$rootPath, 'Packages/Framework/Neos.Flow']))) . '/';
                $expectedPath = Files::getUnixStylePath(realpath(FLOW_PATH_FLOW)) . '/';
                if ($testPath !== $expectedPath) {
                    echo 'Flow: Invalid root path. (Error #1248964375)' . PHP_EOL . '"' . $testPath . '" does not lead to' . PHP_EOL . '"' . $expectedPath . '"' . PHP_EOL;
                    exit(1);
                }
                define('FLOW_PATH_ROOT', $rootPath);
                unset($rootPath);
                unset($testPath);
            }
        }
        if (FLOW_SAPITYPE === 'CLI') {
            if (!defined('FLOW_PATH_ROOT')) {
                echo 'Flow: No root path defined in environment variable FLOW_ROOTPATH (Error #1248964376)' . PHP_EOL;
                exit(1);
            }
            if (!defined('FLOW_PATH_WEB')) {
                if (isset($_SERVER['FLOW_WEBPATH']) && is_dir($_SERVER['FLOW_WEBPATH'])) {
                    define('FLOW_PATH_WEB', Files::getUnixStylePath(realpath($_SERVER['FLOW_WEBPATH'])) . '/');
                } else {
                    define('FLOW_PATH_WEB', FLOW_PATH_ROOT . 'Web/');
                }
            }
        } else {
            if (!defined('FLOW_PATH_ROOT')) {
                define('FLOW_PATH_ROOT', Files::getUnixStylePath(realpath(dirname($_SERVER['SCRIPT_FILENAME']) . '/../')) . '/');
            }
            define('FLOW_PATH_WEB', Files::getUnixStylePath(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/');
        }
        define('FLOW_PATH_CONFIGURATION', FLOW_PATH_ROOT . 'Configuration/');
        define('FLOW_PATH_DATA', FLOW_PATH_ROOT . 'Data/');
        define('FLOW_PATH_PACKAGES', FLOW_PATH_ROOT . 'Packages/');
        if (!defined('FLOW_PATH_TEMPORARY_BASE')) {
            define('FLOW_PATH_TEMPORARY_BASE', self::getEnvironmentConfigurationSetting('FLOW_PATH_TEMPORARY_BASE') ?: FLOW_PATH_DATA . '/Temporary');
            $temporaryDirectoryPath = Files::concatenatePaths([FLOW_PATH_TEMPORARY_BASE, str_replace('/', '/SubContext', (string) $this->context)]) . '/';
            define('FLOW_PATH_TEMPORARY', $temporaryDirectoryPath);
        }
        define('FLOW_VERSION_BRANCH', '4.0');
    }