[BUGFIX] Clean-up responsibilities of FAL classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / FileInterface.php
1 <?php
2 namespace TYPO3\CMS\Core\Resource;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Ingmar Schlecht <ingmar@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * File Interface
31 *
32 * @author Ingmar Schlecht <ingmar@typo3.org>
33 */
34 interface FileInterface extends ResourceInterface {
35 /*******************************
36 * VARIOUS FILE PROPERTY GETTERS
37 *******************************/
38 /**
39 * Returns true if the given key exists for this file.
40 *
41 * @param string $key
42 * @return boolean
43 */
44 public function hasProperty($key);
45
46 /**
47 * Get the value of the $key property.
48 *
49 * @param string $key
50 * @return string
51 */
52 public function getProperty($key);
53
54 /**
55 * Returns the size of this file
56 *
57 * @return integer
58 */
59 public function getSize();
60
61 /**
62 * Returns the Sha1 of this file
63 *
64 * @return string
65 */
66 public function getSha1();
67
68 /**
69 * Returns the basename (the name without extension) of this file.
70 *
71 * @return string
72 */
73 public function getNameWithoutExtension();
74
75 /**
76 * Get the file extension
77 *
78 * @return string The file extension
79 */
80 public function getExtension();
81
82 /**
83 * Get the MIME type of this file
84 *
85 * @return array file information
86 */
87 public function getMimeType();
88
89 /**
90 * Returns the modification time of the file as Unix timestamp
91 *
92 * @return integer
93 */
94 public function getModificationTime();
95
96 /**
97 * Returns the creation time of the file as Unix timestamp
98 *
99 * @return integer
100 */
101 public function getCreationTime();
102
103 /******************
104 * CONTENTS RELATED
105 ******************/
106 /**
107 * Get the contents of this file
108 *
109 * @return string File contents
110 */
111 public function getContents();
112
113 /**
114 * Replace the current file contents with the given string.
115 *
116 * @TODO : Consider to remove this function from the interface, as its
117 * @TODO : At the same time, it could be considered whether to make the whole
118 * @param string $contents The contents to write to the file.
119 * @return File The file object (allows chaining).
120 */
121 public function setContents($contents);
122
123 /****************************************
124 * STORAGE AND MANAGEMENT RELATED METHDOS
125 ****************************************/
126 /**
127 * Deletes this file from its storage. This also means that this object becomes useless.
128 *
129 * @return boolean TRUE if deletion succeeded
130 */
131 public function delete();
132
133 /**
134 * Renames this file.
135 *
136 * @param string $newName The new file name
137 * @return File
138 */
139 public function rename($newName);
140
141 /*****************
142 * SPECIAL METHODS
143 *****************/
144 /**
145 * Returns a publicly accessible URL for this file
146 *
147 * WARNING: Access to the file may be restricted by further means, e.g.
148 * some web-based authentication. You have to take care of this yourself.
149 *
150 * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
151 * @return string
152 */
153 public function getPublicUrl($relativeToCurrentScript = FALSE);
154
155 /**
156 * Returns TRUE if this file is indexed
157 *
158 * @return boolean
159 */
160 public function isIndexed();
161
162 /**
163 * Returns a path to a local version of this file to process it locally (e.g. with some system tool).
164 * If the file is normally located on a remote storages, this creates a local copy.
165 * If the file is already on the local system, this only makes a new copy if $writable is set to TRUE.
166 *
167 * @param bool $writable Set this to FALSE if you only want to do read operations on the file.
168 * @return string
169 */
170 public function getForLocalProcessing($writable = TRUE);
171
172 /**
173 * Returns an array representation of the file.
174 * (This is used by the generic listing module vidi when displaying file records.)
175 *
176 * @return array Array of main data of the file. Don't rely on all data to be present here, it's just a selection of the most relevant information.
177 */
178 public function toArray();
179
180 }