--- /dev/null
+<?php
+/**
+ * @file src/Model/Storage/IStorage.php
+ * @brief Storage backend system
+ */
+
+namespace Friendica\Model\Storage;
+
+/**
+ * @brief Interface for storage backends
+ */
+interface IStorage
+{
+ /**
+ * @brief Get data from backend
+ * @param string $ref Data reference
+ * @return string
+ */
+ public static function get($ref);
+
+ /**
+ * @brief Put data in backend as $ref. If $ref is null a new reference is created.
+ * @param string $data Data to save
+ * @param string $ref Data referece. Optional.
+ * @return string Saved data referece
+ */
+ public static function put($data, $ref = null);
+
+ /**
+ * @brief Remove data from backend
+ * @param string $ref Data referece
+ * @return boolean True on success
+ */
+ public static function delete($ref);
+}
\ No newline at end of file
<?php
/**
* @file src/Model/Storage/SystemStorage.php
+ * @brief Storage backend system
*/
namespace Friendica\Model\Storage;
* This class is used to load system resources, like images.
* Is not itended to be selectable by admins as default storage class.
*/
-class SystemResource
+class SystemResource implements IStorage
{
// Valid folders to look for resources
const VALID_FOLDERS = [ "images" ];
- /**
- * @brief get data
- *
- * @param string $resourceid
- *
- * @return string
- */
- static function get($filename)
+ public static function get($filename)
{
$folder = dirname($filename);
if (!in_array($folder, self::VALID_FOLDERS)) return "";
return file_get_contents($filename);
}
- static function put($filename, $data)
+
+ public static function put($data, $filename=null)
+ {
+ throw new \BadMethodCallException();
+ }
+
+ public static function delete($filename)
{
throw new \BadMethodCallException();
}
+
}