You are here

public static function vfsStream::create in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php \org\bovigo\vfs\vfsStream::create()

creates vfsStream directory structure from an array and adds it to given base dir

Assumed $structure contains an array like this: <code> array('Core' = array('AbstractFactory' => array('test.php' => 'some text content', 'other.php' => 'Some more text content', 'Invalid.csv' => 'Something else', ), 'AnEmptyFolder' => array(), 'badlocation.php' => 'some bad content', ) ) </code> the resulting directory tree will look like this: <pre> baseDir \- Core |- badlocation.php |- AbstractFactory | |- test.php | |- other.php | \- Invalid.csv \- AnEmptyFolder </pre> Arrays will become directories with their key as directory name, and strings becomes files with their key as file name and their value as file content.

If no baseDir is given it will try to add the structure to the existing root directory without replacing existing childs except those with equal names.

@since 0.10.0

Parameters

array $structure directory structure to add under root directory:

vfsStreamDirectory $baseDir base directory to add structure to:

Return value

vfsStreamDirectory

Throws

\InvalidArgumentException

See also

https://github.com/mikey179/vfsStream/issues/14

https://github.com/mikey179/vfsStream/issues/20

26 calls to vfsStream::create()
DirectoryIterationTestCase::recursiveDirectoryIterationWithDotsDisabled in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php
@test @group issue_50
DirectoryIterationTestCase::recursiveDirectoryIterationWithDotsEnabled in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php
@test @group issue_50
DrupalKernelTest::testFindSitePath in core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
Tests site path finding.
FileItemValidationTest::testFileValidationConstraint in core/modules/file/tests/src/Kernel/FileItemValidationTest.php
@covers \Drupal\file\Plugin\Validation\Constraint\FileValidationConstraint @covers \Drupal\file\Plugin\Validation\Constraint\FileValidationConstraintValidator @dataProvider getFileTypes
FileSystemTest::testChmodDir in core/tests/Drupal/Tests/Core/File/FileSystemTest.php
@covers ::chmod

... See full list

File

vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php, line 201

Class

vfsStream
Some utility methods for vfsStream.

Namespace

org\bovigo\vfs

Code

public static function create(array $structure, vfsStreamDirectory $baseDir = null) {
  if (null === $baseDir) {
    $baseDir = vfsStreamWrapper::getRoot();
  }
  if (null === $baseDir) {
    throw new \InvalidArgumentException('No baseDir given and no root directory set.');
  }
  return self::addStructure($structure, $baseDir);
}