Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
File.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Filesystem;
3 
11 class File {
12 
14  private $directory;
15 
17  private $path;
18 
25  public function __construct(Directory $directory, $path) {
26  $this->directory = $directory;
27  $this->path = $path;
28  }
29 
33  public function exists() {
34  return $this->directory->isFile($this->path);
35  }
36 
40  public function getBasename() {
41  return pathinfo($this->path, PATHINFO_BASENAME);
42  }
43 
49  public function getContents() {
50  return $this->directory->getContents($this->path);
51  }
52 
59  public function putContents($content) {
60  $this->directory->putContents($this->path, $content);
61  }
62 
66  public function getExtension() {
67  return pathinfo($this->path, PATHINFO_EXTENSION);
68  }
69 
73  public function getPath() {
74  return $this->directory->getPath($this->path);
75  }
76 
84  public function includeFile() {
85  return $this->directory->includeFile($this->path);
86  }
87 
89  public function __toString() {
90  return $this->path;
91  }
92 }
A simple directory abstraction.
Definition: Directory.php:13
putContents($content)
Put content into this file.
Definition: File.php:59
__construct(Directory $directory, $path)
Constructor.
Definition: File.php:25
$CONFIG path
The full path where Elgg is installed.
Definition: config.php:16
getContents()
Get the text content of this file.
Definition: File.php:49
Represents a file that may or may not actually exist.
Definition: File.php:11
includeFile()
Do a PHP include of the file and return the result.
Definition: File.php:84
$content
Set robots.txt action.
Definition: set_robots.php:6