org\bovigo\vfs\vfsStream::create PHP 메소드

create() 공개 정적인 메소드

Assumed $structure contains an array like this: 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', ) ) the resulting directory tree will look like this:
baseDir
\- Core
 |- badlocation.php
 |- AbstractFactory
 | |- test.php
 | |- other.php
 | \- Invalid.csv
 \- AnEmptyFolder
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.
또한 보기: https://github.com/mikey179/vfsStream/issues/14
또한 보기: https://github.com/mikey179/vfsStream/issues/20
부터: 0.10.0
public static create ( array $structure, vfsStreamDirectory $baseDir = null ) : vfsStreamDirectory
$structure array directory structure to add under root directory
$baseDir vfsStreamDirectory base directory to add structure to
리턴 vfsStreamDirectory
    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);
    }

Usage Example

 /**
  * @param $csvContent
  * @return string
  */
 protected function setUpVirtualFileAndGetPath($csvContent)
 {
     $structure = array('directory' => array('my_file.csv' => $csvContent));
     vfsStream::setup();
     vfsStream::create($structure);
     return vfsStream::url('root/directory/my_file.csv');
 }
All Usage Examples Of org\bovigo\vfs\vfsStream::create