Skip to content

Commit

Permalink
API Make the public directory mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Dec 14, 2022
1 parent bf440e4 commit 8c5087d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
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

0 comments on commit 8c5087d

Please sign in to comment.