protected function FieldDefinitionIntegrityTest::modulesWithSubdirectory in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php \Drupal\Tests\field\Kernel\FieldDefinitionIntegrityTest::modulesWithSubdirectory()
Find modules with a specified subdirectory.
Parameters
string $subdirectory: The required path, relative to the module directory.
Return value
string[] A list of module names satisfying these criteria:
- provided by core
- not hidden
- not already enabled
- not in the Testing package
- containing the required $subdirectory
and all modules required by any of these modules.
2 calls to FieldDefinitionIntegrityTest::modulesWithSubdirectory()
- FieldDefinitionIntegrityTest::testFieldPluginDefinitionAvailability in core/
modules/ field/ tests/ src/ Kernel/ FieldDefinitionIntegrityTest.php - Tests to load field plugin definitions used in core's existing entities.
- FieldDefinitionIntegrityTest::testFieldPluginDefinitionIntegrity in core/
modules/ field/ tests/ src/ Kernel/ FieldDefinitionIntegrityTest.php - Tests the integrity of field plugin definitions.
File
- core/
modules/ field/ tests/ src/ Kernel/ FieldDefinitionIntegrityTest.php, line 172
Class
- FieldDefinitionIntegrityTest
- Tests the integrity of field API plugin definitions.
Namespace
Drupal\Tests\field\KernelCode
protected function modulesWithSubdirectory($subdirectory) {
$modules = \Drupal::service('extension.list.module')
->getList();
$modules = array_filter($modules, function (Extension $module) use ($subdirectory) {
// Filter contrib, hidden, already enabled modules and modules in the
// Testing package.
return $module->origin === 'core' && empty($module->info['hidden']) && $module->status == FALSE && $module->info['package'] !== 'Testing' && is_readable($module
->getPath() . DIRECTORY_SEPARATOR . $subdirectory);
});
// Gather the dependencies of the modules.
$dependencies = NestedArray::mergeDeepArray(array_map(function (Extension $module) {
return array_keys($module->requires);
}, $modules));
return array_unique(NestedArray::mergeDeep(array_keys($modules), $dependencies));
}