function FieldDefinitionIntegrityTest::modulesWithSubdirectory

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php \Drupal\Tests\field\Kernel\FieldDefinitionIntegrityTest::modulesWithSubdirectory()
  2. 8.9.x core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php \Drupal\Tests\field\Kernel\FieldDefinitionIntegrityTest::modulesWithSubdirectory()
  3. 11.x 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 174

Class

FieldDefinitionIntegrityTest
Tests the integrity of field API plugin definitions.

Namespace

Drupal\Tests\field\Kernel

Code

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));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.