mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #11296 from creative-commoners/pulls/6/manifest-composer
ENH Do not require _config dir or _config.php for modules
This commit is contained in:
commit
d96d85248a
@ -18,6 +18,11 @@ class ManifestFileFinder extends FileFinder
|
||||
|
||||
const CONFIG_FILE = '_config.php';
|
||||
const CONFIG_DIR = '_config';
|
||||
const COMPOSER_FILE = 'composer.json';
|
||||
const COMPOSER_TYPES = [
|
||||
'silverstripe-vendormodule',
|
||||
'silverstripe-theme',
|
||||
];
|
||||
const EXCLUDE_FILE = '_manifest_exclude';
|
||||
const LANG_DIR = 'lang';
|
||||
const TESTS_DIR = 'tests';
|
||||
@ -179,6 +184,16 @@ class ManifestFileFinder extends FileFinder
|
||||
return true;
|
||||
}
|
||||
|
||||
// True if composer type
|
||||
$path = $pathname . '/' . ManifestFileFinder::COMPOSER_FILE;
|
||||
if (file_exists($path)) {
|
||||
$composer = json_decode(file_get_contents($path), true);
|
||||
$type = $composer['type'] ?? '';
|
||||
if (in_array($type, ManifestFileFinder::COMPOSER_TYPES)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -120,4 +120,36 @@ class ManifestFileFinderTest extends SapphireTest
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that this phpunit file is unable to use a dataProvider for some unknown reason
|
||||
*/
|
||||
public function testIsDirectoryModule()
|
||||
{
|
||||
$provider = [
|
||||
'vendormodule' => [
|
||||
'silverstripe-vendormodule',
|
||||
true,
|
||||
],
|
||||
'theme' => [
|
||||
'silverstripe-theme',
|
||||
true,
|
||||
],
|
||||
'somethingelse' => [
|
||||
'silverstripe-somethingelse',
|
||||
false,
|
||||
],
|
||||
'notype' => [
|
||||
'silverstripe-notype',
|
||||
false,
|
||||
],
|
||||
];
|
||||
foreach ($provider as $data) {
|
||||
list($subdir, $expected) = $data;
|
||||
$finder = new ManifestFileFinder();
|
||||
$pathname = __DIR__ . '/fixtures/manifestfilefinder_rootconfigcomposer/' . $subdir;
|
||||
$actual = $finder->isDirectoryModule('', $pathname, 0);
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "silverstripe/manifestfilefindertest"
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "silverstripe/manifestfilefindertest",
|
||||
"type": "silverstripe-somethingelse"
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "silverstripe/manifestfilefindertest",
|
||||
"type": "silverstripe-theme"
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "silverstripe/manifestfilefindertest",
|
||||
"type": "silverstripe-vendormodule"
|
||||
}
|
Loading…
Reference in New Issue
Block a user