summaryrefslogtreecommitdiff
path: root/src/StorageAccess.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2014-05-24 14:45:13 +0200
committerKevin Chabowski <kevin@kch42.de>2014-05-24 14:45:13 +0200
commit3c51baa4167d5a68ff010dc81525b9340c5f1329 (patch)
tree87dbb507a20a8946f93ea8b26a1a784d5eec62ea /src/StorageAccess.php
parent9f86139b7604ea782a35e09bf9d0c55154197051 (diff)
downloadste-3c51baa4167d5a68ff010dc81525b9340c5f1329.tar.gz
ste-3c51baa4167d5a68ff010dc81525b9340c5f1329.tar.bz2
ste-3c51baa4167d5a68ff010dc81525b9340c5f1329.zip
Moved code into src subfolder and fixed docu
Diffstat (limited to 'src/StorageAccess.php')
-rw-r--r--src/StorageAccess.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/StorageAccess.php b/src/StorageAccess.php
new file mode 100644
index 0000000..81f7439
--- /dev/null
+++ b/src/StorageAccess.php
@@ -0,0 +1,55 @@
+<?php
+
+// File: StorageAccess.php
+
+// Namespace: kch42\ste
+namespace kch42\ste;
+
+/*
+ * Class: StorageAccess
+ * An interface.
+ * A StorageAccess implementation is used to access the templates from any storage.
+ * This means, that you are not limited to store the Templates inside directories, you can also use a database or something else.
+ */
+interface StorageAccess {
+ /*
+ * Constants: Template modes
+ *
+ * MODE_SOURCE - The Templates source
+ * MODE_TRANSCOMPILED - The transcompiled template
+ */
+ const MODE_SOURCE = 0;
+ const MODE_TRANSCOMPILED = 1;
+
+ /*
+ * Function: load
+ * Loading a template.
+ *
+ * Parameters:
+ * $tpl - The name of the template.
+ * &$mode - Which mode is preferred? One of the <Template modes>.
+ * If <MODE_SOURCE>, the raw sourcecode is expected, if <MODE_TRANSCOMPILED> the transcompiled template *as a callable function* (expecting an <STECore> instance as first parameter) is expected.
+ * If the transcompiled version is not available or older than the source, you can set this parameter to <MODE_SOURCE> and return the source.
+ *
+ * Throws:
+ * A <CantLoadTemplate> exception if the template could not be loaded.
+ *
+ * Returns:
+ * Either the sourcecode or a callable function (first, and only parameter: an <STECore> instance).
+ */
+ public function load($tpl, &$mode);
+
+ /*
+ * Function: save
+ * Saves a template.
+ *
+ * Throws:
+ * A <CantSaveTemplate> exception if the template could not be saved.
+ *
+ * Parameters:
+ * $tpl -The name of the template.
+ * $data - The data to be saved.
+ * $mode - A <Template mode> constant.
+ */
+ public function save($tpl, $data, $mode);
+}