function ExtensionDiscoveryTest::addFileToFilesystemStructure

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php \Drupal\Tests\Core\Extension\ExtensionDiscoveryTest::addFileToFilesystemStructure()
  2. 8.9.x core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php \Drupal\Tests\Core\Extension\ExtensionDiscoveryTest::addFileToFilesystemStructure()
  3. 10 core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php \Drupal\Tests\Core\Extension\ExtensionDiscoveryTest::addFileToFilesystemStructure()

Parameters

array $filesystem_structure: An associative array where each key represents a directory.

string[] $pieces: Fragments of the file path.

string $content: The contents of the file.

1 call to ExtensionDiscoveryTest::addFileToFilesystemStructure()
ExtensionDiscoveryTest::populateFilesystemStructure in core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php
Adds example files to the filesystem structure.

File

core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php, line 197

Class

ExtensionDiscoveryTest
Tests discovery of extensions.

Namespace

Drupal\Tests\Core\Extension

Code

protected function addFileToFilesystemStructure(array &$filesystem_structure, array $pieces, $content) : void {
    $piece = array_shift($pieces);
    if ($pieces !== []) {
        $filesystem_structure += [
            $piece => [],
        ];
        $this->addFileToFilesystemStructure($filesystem_structure[$piece], $pieces, $content);
    }
    else {
        $filesystem_structure[$piece] = $content;
    }
}

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