Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. vfsStreamFile.php

function vfsStreamFile::withContent

sets the contents of the file

Setting content with this method does not change the time when the file was last modified.

Parameters

string]FileContent $content:

Return value

vfsStreamFile

Throws

\InvalidArgumentException

1 call to vfsStreamFile::withContent()
vfsStreamFile::setContent in vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStreamFile.php
alias for withContent()

File

vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStreamFile.php, line 96

Class

vfsStreamFile
File container.

Namespace

org\bovigo\vfs

Code

public function withContent($content) {
    if (is_string($content)) {
        $this->content = new StringBasedFileContent($content);
    }
    elseif ($content instanceof FileContent) {
        $this->content = $content;
    }
    else {
        throw new \InvalidArgumentException('Given content must either be a string or an instance of org\\bovigo\\vfs\\content\\FileContent');
    }
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal