ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\SimpleFile Class Reference

SimpleFile. More...

+ Inheritance diagram for Sabre\DAV\SimpleFile:
+ Collaboration diagram for Sabre\DAV\SimpleFile:

Public Member Functions

 __construct ($name, $contents, $mimeType=null)
 Creates this node. More...
 
 getName ()
 Returns the node name for this file. More...
 
 get ()
 Returns the data. More...
 
 getSize ()
 Returns the size of the file, in bytes. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 getContentType ()
 Returns the mime-type for a file. More...
 
- Public Member Functions inherited from Sabre\DAV\File
 put ($data)
 Replaces the contents of the file. More...
 
 get ()
 Returns the data. More...
 
 getSize ()
 Returns the size of the file, in bytes. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 getContentType ()
 Returns the mime-type for a file. More...
 
- Public Member Functions inherited from Sabre\DAV\Node
 getLastModified ()
 Returns the last modification time as a unix timestamp. More...
 
 delete ()
 Deletes the current node. More...
 
 setName ($name)
 Renames the node. More...
 

Protected Attributes

 $contents = []
 
 $name
 
 $mimeType
 

Detailed Description

SimpleFile.

The 'SimpleFile' class is used to easily add read-only immutable files to the directory structure. One usecase would be to add a 'readme.txt' to a root of a webserver with some standard content.

Author
Evert Pot (http://evertpot.com/) http://sabre.io/license/ Modified BSD License

Definition at line 16 of file SimpleFile.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\DAV\SimpleFile::__construct (   $name,
  $contents,
  $mimeType = null 
)

Creates this node.

The name of the node must be passed, as well as the contents of the file.

Parameters
string$name
string$contents
string | null$mimeType

Definition at line 49 of file SimpleFile.php.

References Sabre\DAV\SimpleFile\$contents, Sabre\DAV\SimpleFile\$mimeType, and Sabre\DAV\SimpleFile\$name.

49  {
50 
51  $this->name = $name;
52  $this->contents = $contents;
53  $this->mimeType = $mimeType;
54 
55  }

Member Function Documentation

◆ get()

Sabre\DAV\SimpleFile::get ( )

Returns the data.

This method may either return a string or a readable stream resource

Returns
mixed

Implements Sabre\DAV\IFile.

Definition at line 77 of file SimpleFile.php.

References Sabre\DAV\SimpleFile\$contents.

77  {
78 
79  return $this->contents;
80 
81  }

◆ getContentType()

Sabre\DAV\SimpleFile::getContentType ( )

Returns the mime-type for a file.

If null is returned, we'll assume application/octet-stream

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 115 of file SimpleFile.php.

References Sabre\DAV\SimpleFile\$mimeType.

115  {
116 
117  return $this->mimeType;
118 
119  }

◆ getETag()

Sabre\DAV\SimpleFile::getETag ( )

Returns the ETag for a file.

An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. The ETag is an arbitrary string, but MUST be surrounded by double-quotes.

Return null if the ETag can not effectively be determined

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 103 of file SimpleFile.php.

103  {
104 
105  return '"' . sha1($this->contents) . '"';
106 
107  }

◆ getName()

Sabre\DAV\SimpleFile::getName ( )

Returns the node name for this file.

This name is used to construct the url.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 64 of file SimpleFile.php.

References Sabre\DAV\SimpleFile\$name.

64  {
65 
66  return $this->name;
67 
68  }

◆ getSize()

Sabre\DAV\SimpleFile::getSize ( )

Returns the size of the file, in bytes.

Returns
int

Implements Sabre\DAV\IFile.

Definition at line 88 of file SimpleFile.php.

88  {
89 
90  return strlen($this->contents);
91 
92  }

Field Documentation

◆ $contents

Sabre\DAV\SimpleFile::$contents = []
protected

Definition at line 23 of file SimpleFile.php.

Referenced by Sabre\DAV\SimpleFile\__construct(), and Sabre\DAV\SimpleFile\get().

◆ $mimeType

Sabre\DAV\SimpleFile::$mimeType
protected

◆ $name

Sabre\DAV\SimpleFile::$name
protected

The documentation for this class was generated from the following file: