NEW: Allow project root to be treated as a module.

If the _config folder exists as a top-level directory, treat the project
root as a module too. This is useful, e.g. when initialisation a
SilverStripe environment within a module.

This is only a first cut. Modules in the vendor directory are excluded.
Most likely, we will need to search the vendor folder for modules with
type = silverstripe-module in their composer.json.
This commit is contained in:
Sam Minnee 2016-09-12 15:16:21 +12:00
parent ab7e5944d1
commit 6b847d3614
3 changed files with 9 additions and 1 deletions

View File

@ -226,6 +226,7 @@ class ConfigManifest {
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'min_depth' => 0,
'name_regex' => '/(^|[\/\\\\])_config.php$/',
'ignore_tests' => !$includeTests,
'file_callback' => array($this, 'addSourceConfigFile')

View File

@ -39,6 +39,11 @@ class ManifestFileFinder extends FileFinder {
return false;
}
// Skip over the vendor directories
if (($depth == 1 || $depth == 2) && $basename == 'vendor') {
return false;
}
// If we're not in testing mode, then skip over any tests directories.
if ($this->getOption('ignore_tests') && $basename == self::TESTS_DIR) {
return false;
@ -57,6 +62,8 @@ class ManifestFileFinder extends FileFinder {
&& !($this->getOption('include_themes') && $basename == THEMES_DIR)
&& !file_exists($pathname . '/' . self::CONFIG_FILE)
&& !file_exists($pathname . '/' . self::CONFIG_DIR)
&& $basename !== self::CONFIG_DIR // include a root config dir
&& !file_exists("$pathname/../" . self::CONFIG_DIR) // include all paths if a root config dir exists
);
if ($lackingConfig) {

View File

@ -154,7 +154,7 @@ class ThemeManifest implements ThemeList {
$path = '/'.implode('/', $themeParts);
// If this is in the project, add to beginning of list. Else add to end.
if ($themeParts[0] == $this->project) {
if ($themeParts && $themeParts[0] == $this->project) {
array_unshift($this->themes, $path);
}
else {