Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Make the public directory mandatory #10617

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ class Director implements TemplateGlobalProvider
*/
private static $alternate_base_folder;

/**
* Override PUBLIC_DIR. Set to a non-null value to override.
* Setting to an empty string will disable public dir.
*
* @config
* @var bool|null
*/
private static $alternate_public_dir = null;

/**
* Base url to populate if cannot be determined otherwise.
* Supports back-ticked vars; E.g. '`SS_BASE_URL`'
Expand Down Expand Up @@ -654,19 +645,12 @@ public static function baseFolder()
}

/**
* Check if using a separate public dir, and if so return this directory
* name.
*
* This will be removed in 5.0 and fixed to 'public'
* The name of the public directory
*
* @return string
*/
public static function publicDir()
{
$alternate = self::config()->uninherited('alternate_public_dir');
if (isset($alternate)) {
return $alternate;
}
return PUBLIC_DIR;
}

Expand Down
2 changes: 1 addition & 1 deletion src/View/PublicThemes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class PublicThemes implements ThemeList
{
public function getThemes()
{
return PUBLIC_DIR ? ['/' . PUBLIC_DIR] : [];
return ['/' . PUBLIC_DIR];
}
}
8 changes: 4 additions & 4 deletions src/includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* - THEMES_PATH: Absolute filepath, e.g. "/var/www/my-webroot/themes"
* - FRAMEWORK_DIR: Path relative to webroot, e.g. "framework"
* - FRAMEWORK_PATH:Absolute filepath, e.g. "/var/www/my-webroot/framework"
* - PUBLIC_DIR: Webroot path relative to project root, e.g. "public" or ""
* - PUBLIC_DIR: Webroot path relative to project root - always evaluates to "public"
* - PUBLIC_PATH: Absolute path to webroot, e.g. "/var/www/project/public"
* - THIRDPARTY_DIR: Path relative to webroot, e.g. "framework/thirdparty"
* - THIRDPARTY_PATH: Absolute filepath, e.g. "/var/www/my-webroot/framework/thirdparty"
Expand Down Expand Up @@ -70,10 +70,10 @@

// Set public webroot dir / path
if (!defined('PUBLIC_DIR')) {
define('PUBLIC_DIR', is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'public') ? 'public' : '');
define('PUBLIC_DIR', 'public');
}
if (!defined('PUBLIC_PATH')) {
define('PUBLIC_PATH', PUBLIC_DIR ? BASE_PATH . DIRECTORY_SEPARATOR . PUBLIC_DIR : BASE_PATH);
define('PUBLIC_PATH', BASE_PATH . DIRECTORY_SEPARATOR . PUBLIC_DIR);
}

// Allow a first class env var to be set that disables .env file loading
Expand Down Expand Up @@ -183,7 +183,7 @@
call_user_func(function () {
$paths = [
BASE_PATH,
(PUBLIC_DIR ? PUBLIC_DIR : null),
PUBLIC_DIR,
ASSETS_DIR
];
define('ASSETS_PATH', implode(DIRECTORY_SEPARATOR, array_filter($paths ?? [])));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testConfig()
// Check plugin links included
$this->assertStringContainsString(
<<<EOS
tinymce.each('tinymce/langs/en.js,mycode/plugin1.js,tinymce/plugins/plugin4/plugin.min.js,tinymce/plugins/plugin4/langs/en.js,tinymce/plugins/plugin5/plugin.js,mycode/plugin6.js,mycode/plugin8.js?m=
tinymce.each('tinymce/langs/en.js,mycode/plugin1.js,tinymce/plugins/plugin4/plugin.min.js,tinymce/plugins/plugin4/langs/en.js,tinymce/plugins/plugin5/plugin.js,mycode/plugin6.js,_resources/mycode/plugin8.js?m=
EOS
,
$content
Expand Down