FIX: Allow CMS_DIR at the root.

CMS_DIR is now inferred from the file location and may be at the
project root.
This commit is contained in:
Sam Minnee 2016-10-25 11:57:05 +13:00
parent added2129f
commit d946a3b240

View File

@ -9,8 +9,12 @@ use SilverStripe\Assets\File;
* - CMS_DIR: Path relative to webroot, e.g. "cms" * - CMS_DIR: Path relative to webroot, e.g. "cms"
* - CMS_PATH: Absolute filepath, e.g. "/var/www/my-webroot/cms" * - CMS_PATH: Absolute filepath, e.g. "/var/www/my-webroot/cms"
*/ */
define('CMS_DIR', 'cms'); define('CMS_PATH', realpath(__DIR__));
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR); if(strpos(CMS_PATH, BASE_PATH) === 0) {
define('CMS_DIR', trim(substr(CMS_PATH, strlen(BASE_PATH)), '/'));
} else {
throw new Exception("Path error: CMS_PATH " . CMS_PATH . " not within BASE_PATH " . BASE_PATH);
}
/** /**
* Register the default internal shortcodes. * Register the default internal shortcodes.