diff --git a/docs/classes.svg b/docs/classes.svg index 8855c7f..f903d95 100644 --- a/docs/classes.svg +++ b/docs/classes.svg @@ -4,74 +4,74 @@ - - + + G - + cluster_default - - - - - + + + + + \\DB_Reg - -DB_Reg + +DB_Reg \\Settings - -Settings + +Settings \\DB_SQL - -«abstract» -DB_SQL + +«abstract» +DB_SQL \\DB_PDO - -«abstract» -DB_PDO + +«abstract» +DB_PDO -\\PDO +\\PDO \PDO \\DB_PDO->\\PDO - - + + \\Query_Builder - -Query_Builder + +Query_Builder \\DB_Util - -«abstract» -DB_Util + +«abstract» +DB_Util @@ -83,8 +83,8 @@ \\PgSQL_SQL->\\DB_SQL - - + + \\PgSQL_Util @@ -95,20 +95,20 @@ \\PgSQL_Util->\\DB_Util - - + + \\PgSQL - -PgSQL + +PgSQL \\PgSQL->\\DB_PDO - - + + \\ODBC_Util @@ -119,8 +119,8 @@ \\ODBC_Util->\\DB_Util - - + + \\ODBC_SQL @@ -131,8 +131,8 @@ \\ODBC_SQL->\\DB_SQL - - + + \\ODBC @@ -143,20 +143,20 @@ \\ODBC->\\DB_PDO - - + + \\MySQL_Util - -MySQL_Util + +MySQL_Util \\MySQL_Util->\\DB_Util - - + + \\MySQL @@ -167,20 +167,20 @@ \\MySQL->\\DB_PDO - - + + \\MySQL_SQL - -MySQL_SQL + +MySQL_SQL \\MySQL_SQL->\\DB_SQL - - + + \\SQLite_Util @@ -191,8 +191,8 @@ \\SQLite_Util->\\DB_Util - - + + \\SQLite @@ -203,8 +203,8 @@ \\SQLite->\\DB_PDO - - + + \\SQLite_SQL @@ -215,8 +215,8 @@ \\SQLite_SQL->\\DB_SQL - - + + \\Firebird_SQL @@ -227,8 +227,8 @@ \\Firebird_SQL->\\DB_SQL - - + + \\Firebird_Result @@ -238,7 +238,7 @@ -\\PDOStatement +\\PDOStatement \PDOStatement @@ -250,14 +250,14 @@ \\Firebird - -Firebird + +Firebird \\Firebird->\\DB_PDO - - + + \\Firebird_Util @@ -268,128 +268,135 @@ \\Firebird_Util->\\DB_Util - - + + \\MM_Model - -MM_Model + +MM_Model \\miniMVC - -miniMVC + +miniMVC \\MM_Model->\\miniMVC - - + + \\DB - -DB + +DB \\DB->\\Query_Builder - - + + \\MM - -MM + +MM -\\ArrayObject - -\ArrayObject +\\ArrayObject + +\ArrayObject \\MM->\\ArrayObject - - + + \\miniMVC->\\MM - - + + \\MM_Page - -MM_Page + +MM_Page \\MM_Page->\\MM - - + + \\MM_Controller - -MM_Controller + +MM_Controller \\MM_Controller->\\miniMVC - - + + \\MM_Output - -MM_Output + +MM_Output \\MM_Output->\\MM - - + + + + +\\MM_Data_Store + + +MM_Data_Store + -\\MM_Session +\\MM_Session MM_Session -\\Welcome_Model +\\Welcome_Model - -Welcome_Model + +Welcome_Model \\Welcome_Model->\\MM_Model - - + + -\\Welcome +\\Welcome - -Welcome + +Welcome \\Welcome->\\MM_Controller - - + + diff --git a/docs/classes/DB.html b/docs/classes/DB.html index 8343d9a..cb4e83b 100644 --- a/docs/classes/DB.html +++ b/docs/classes/DB.html @@ -1585,7 +1585,7 @@ for complex select queries
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index a260e13..21d12a8 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -708,7 +708,7 @@ the connection/database
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/DB_Reg.html b/docs/classes/DB_Reg.html index 8aad493..7822971 100644 --- a/docs/classes/DB_Reg.html +++ b/docs/classes/DB_Reg.html @@ -154,7 +154,7 @@ and organizes database connections

+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/DB_SQL.html b/docs/classes/DB_SQL.html index dfe3aa0..ed7413b 100644 --- a/docs/classes/DB_SQL.html +++ b/docs/classes/DB_SQL.html @@ -300,7 +300,7 @@ specified table
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index 7603761..67dbe8b 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -211,7 +211,7 @@
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index a0f6b90..ef538d9 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -870,7 +870,7 @@ the last query executed
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 709faaa..9070001 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -506,7 +506,7 @@ the query
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 83d367a..edc2adf 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -310,7 +310,7 @@
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index a4fa734..d7cf0f8 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -214,7 +214,7 @@
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/MM.html b/docs/classes/MM.html index d33b3c2..d401ff1 100644 --- a/docs/classes/MM.html +++ b/docs/classes/MM.html @@ -436,7 +436,7 @@ dynamic methods
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/MM_Controller.html b/docs/classes/MM_Controller.html index 9e4abf3..dea7868 100644 --- a/docs/classes/MM_Controller.html +++ b/docs/classes/MM_Controller.html @@ -762,7 +762,7 @@
+ generated on 2012-05-15T10:23:19-04:00.
diff --git a/docs/classes/MM_Data_Store.html b/docs/classes/MM_Data_Store.html new file mode 100644 index 0000000..88e492b --- /dev/null +++ b/docs/classes/MM_Data_Store.html @@ -0,0 +1,208 @@ + + + + + +miniMVC » \MM_Data_Store + + + + + + + + + + +
+ +
+ +
+
+

Class for using JSON as a key->value data store

+
+

+ + + + + + + + + +
packageminiMVC
subpackageLibraries
+

+ Methods

+
+

Magic function called when cloning an object

+
__clone() 
+
+

+
+
+

Output the data on destruct

+
__destruct() 
+
+

+
+
+

Magic method to simplify isset checking for config options

+
__get(string $key) : mixed
+
+
+

+

Parameters

+
+

$key

+string +
+

Returns

+
mixed
+
+
+
+

Magic method to simplify setting config options

+
__set(string $key, $val) 
+
+
+

+

Parameters

+
+

$key

+string +
+
+

$val

+

mixed

+
+
+
+

Removes a key from the data store

+
del(string $key) : void
+
+
+

+

Parameters

+
+

$key

+string +
+
+
+
+

Return the entire data store object

+
get_all() : object
+
+
+

+

Returns

+
object
+
+
+
+

Static method to retreive current instance +of the singleton

+
get_instance() : \MM_Data_Store
+
+
+

+ + + +
fluentThis method is part of a fluent interface and will return the same instance
+

Returns

+ +
+
+
+

Create and/or load json file

+
__construct() 
+
+

+
+

+ Properties

+ 
+

Settings object represented by the currently loaded JSON file

+
$current 
+
+

+
+ 
+

Singleton instance

+
$instance 
+
+

+
+
+
+
+
+
+
+ + diff --git a/docs/classes/MM_Model.html b/docs/classes/MM_Model.html index fb5de55..748aadf 100644 --- a/docs/classes/MM_Model.html +++ b/docs/classes/MM_Model.html @@ -81,7 +81,6 @@
ksort()
  • Method to load classes into the singleton
    load_class()
  • Convenience function to load config files
    load_config()
  • -
  • Adds the database class to the current model class
    load_db()
  • natcasesort()
    natcasesort()
  • natsort() @@ -399,19 +398,6 @@ -
    -

    Adds the database class to the current model class

    -
    load_db(string $name) : void
    -
    -
    -

    -

    Parameters

    -
    -

    $name

    -string -
    -
    -

    natcasesort()

    @@ -726,7 +712,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/MM_Output.html b/docs/classes/MM_Output.html index 27b7f7a..6025aa0 100644 --- a/docs/classes/MM_Output.html +++ b/docs/classes/MM_Output.html @@ -642,7 +642,7 @@ Used for outputing HTML
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/MM_Page.html b/docs/classes/MM_Page.html index b7a642b..90b1d7b 100644 --- a/docs/classes/MM_Page.html +++ b/docs/classes/MM_Page.html @@ -974,7 +974,7 @@ supports

    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/MM_Session.html b/docs/classes/MM_Session.html index 21d7fa0..e30c9f6 100644 --- a/docs/classes/MM_Session.html +++ b/docs/classes/MM_Session.html @@ -146,7 +146,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index c0909ca..ec313b4 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -906,7 +906,7 @@ the connection/database
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index 83fc0ac..1c48d5f 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -315,7 +315,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index 281082b..ff0b4a0 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -210,7 +210,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index 49f5246..b70fcd4 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -908,7 +908,7 @@ the connection/database
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index 98ec112..f973ba7 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -310,7 +310,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index 8c25462..49803b7 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -205,7 +205,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index e2e8b97..dcb2b9e 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -908,7 +908,7 @@ the connection/database
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index 1353700..8290f2b 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -310,7 +310,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index c0f8c3b..ce7af01 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -210,7 +210,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index f584d56..a5817ab 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -1224,7 +1224,7 @@ for complex select queries
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index c928c51..9000fe5 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -923,7 +923,7 @@ method if the database does not support 'TRUNCATE';
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index 1e10942..66f67a3 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -310,7 +310,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index 2e5478e..d55f7b7 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -210,7 +210,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/Settings.html b/docs/classes/Settings.html index cde4a73..3e707b8 100644 --- a/docs/classes/Settings.html +++ b/docs/classes/Settings.html @@ -246,7 +246,7 @@ directly - the settings should be safe!
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/Welcome.html b/docs/classes/Welcome.html index 3c94c3d..b9f2c5b 100644 --- a/docs/classes/Welcome.html +++ b/docs/classes/Welcome.html @@ -904,7 +904,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/Welcome_Model.html b/docs/classes/Welcome_Model.html index fffab93..6d107fb 100644 --- a/docs/classes/Welcome_Model.html +++ b/docs/classes/Welcome_Model.html @@ -81,7 +81,6 @@
    ksort()
  • Method to load classes into the singleton
    load_class()
  • Convenience function to load config files
    load_config()
  • -
  • Adds the database class to the current model class
    load_db()
  • natcasesort()
    natcasesort()
  • natsort() @@ -453,23 +452,6 @@ -
    -

    Adds the database class to the current model class

    -
    load_db(string $name) : void
    -
    Inherited
    -
    -

    - - - -
    inherited_from\MM_Model::load_db()
    -

    Parameters

    -
    -

    $name

    -string -
    -
    -

    natcasesort()

    @@ -844,7 +826,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/classes/miniMVC.html b/docs/classes/miniMVC.html index a136311..3afdf27 100644 --- a/docs/classes/miniMVC.html +++ b/docs/classes/miniMVC.html @@ -613,7 +613,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/deprecated.html b/docs/deprecated.html index 61f543c..76aff4b 100644 --- a/docs/deprecated.html +++ b/docs/deprecated.html @@ -69,7 +69,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/errors.html b/docs/errors.html index 225e019..0462596 100644 --- a/docs/errors.html +++ b/docs/errors.html @@ -104,12 +104,13 @@
    +
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/graph_class.html b/docs/graph_class.html index 006fe2d..e2bb32c 100644 --- a/docs/graph_class.html +++ b/docs/graph_class.html @@ -66,7 +66,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/index.html b/docs/index.html index 47bac4e..064eac5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -84,7 +84,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/markers.html b/docs/markers.html index 7610bf2..0bdb556 100644 --- a/docs/markers.html +++ b/docs/markers.html @@ -183,7 +183,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/namespaces/default.html b/docs/namespaces/default.html index 7c43381..0ca83b4 100644 --- a/docs/namespaces/default.html +++ b/docs/namespaces/default.html @@ -422,6 +422,13 @@ data-fetching methods

    « More » +
    +

    MM_Data_Store +

    +

    Class for using JSON as a key->value data store

    +
    +« More » +

    MM_Model

    @@ -710,7 +717,7 @@ instantiates the specific db driver

    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/.html b/docs/packages/.html index 8ecb4d4..6869fef 100644 --- a/docs/packages/.html +++ b/docs/packages/.html @@ -69,7 +69,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/Default.html b/docs/packages/Default.html index 4133121..d511c93 100644 --- a/docs/packages/Default.html +++ b/docs/packages/Default.html @@ -194,7 +194,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/Query.Drivers.html b/docs/packages/Query.Drivers.html index 99f1a41..c474f62 100644 --- a/docs/packages/Query.Drivers.html +++ b/docs/packages/Query.Drivers.html @@ -213,7 +213,7 @@ data-fetching methods

    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/Query.Helper Classes.html b/docs/packages/Query.Helper Classes.html index bb23ea4..7405e8d 100644 --- a/docs/packages/Query.Helper Classes.html +++ b/docs/packages/Query.Helper Classes.html @@ -99,7 +99,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/Query.Query.html b/docs/packages/Query.Query.html index 9936dcf..1719b96 100644 --- a/docs/packages/Query.Query.html +++ b/docs/packages/Query.Query.html @@ -117,7 +117,7 @@ instantiates the specific db driver

    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/Query.html b/docs/packages/Query.html index d3089ce..bdcefac 100644 --- a/docs/packages/Query.html +++ b/docs/packages/Query.html @@ -318,7 +318,7 @@ instantiates the specific db driver

    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/miniMVC.App.html b/docs/packages/miniMVC.App.html index 3b58d3e..67d24fb 100644 --- a/docs/packages/miniMVC.App.html +++ b/docs/packages/miniMVC.App.html @@ -141,7 +141,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/miniMVC.Libraries.html b/docs/packages/miniMVC.Libraries.html index 958c6d9..03f982c 100644 --- a/docs/packages/miniMVC.Libraries.html +++ b/docs/packages/miniMVC.Libraries.html @@ -64,6 +64,7 @@
  • +
  • MM_Data_Store
  • MM_Session
  • @@ -78,6 +79,13 @@

    Classes and interfaces

    +
    +

    MM_Data_Store +

    +

    Class for using JSON as a key->value data store

    +
    +« More » +

    MM_Session

    @@ -91,7 +99,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/miniMVC.System.html b/docs/packages/miniMVC.System.html index cdcf17d..86cee9e 100644 --- a/docs/packages/miniMVC.System.html +++ b/docs/packages/miniMVC.System.html @@ -139,7 +139,7 @@
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/packages/miniMVC.html b/docs/packages/miniMVC.html index 53727df..9e75ef6 100644 --- a/docs/packages/miniMVC.html +++ b/docs/packages/miniMVC.html @@ -416,6 +416,13 @@ display them cleanly

    Classes and interfaces

    +
    +

    MM_Data_Store +

    +

    Class for using JSON as a key->value data store

    +
    +« More » +

    MM_Session

    @@ -490,7 +497,7 @@ display them cleanly
    + generated on 2012-05-15T10:23:19-04:00.
    diff --git a/docs/structure.xml b/docs/structure.xml index 24f7095..60020f7 100644 --- a/docs/structure.xml +++ b/docs/structure.xml @@ -5416,7 +5416,7 @@ the last query executed]]> - + Convention-based micro-framework for PHP

    ]]>
    @@ -5447,25 +5447,6 @@ the last query executed]]>
    - - load_db - function - - - - - string - - - void - - - - $name - - - -
    @@ -5582,7 +5563,7 @@ the last query executed]]> - + Convention-based micro-framework for PHP

    ]]>
    @@ -5806,33 +5787,33 @@ dynamic methods]]> - + unload function - + - + string - + $name - + load_config function - + - + string - + $name @@ -6643,6 +6624,151 @@ Used for outputing HTML]]>
    + + + + Convention-based micro-framework for PHP

    ]]>
    + + + + + +
    + + MM_Data_Store + \MM_Data_Store + + + value data store]]> + + + + + + $current + + + + + + + + $instance + + + + + + + + __construct + function + + + + + + + __destruct + function + + + + + + + __clone + function + + + + + + + __get + function + + + + + string + + + mixed + + + + $key + + + + + + __set + function + + + + + string + + + + + $key + + + + + $val + + + + + + get_instance + function + + + + + \self + + + + + del + function + + + + + string + + + void + + + + $key + + + + + + get_all + function + + + + + object + + + + +
    diff --git a/sys/core/miniMVC.php b/sys/core/miniMVC.php index f93f933..1b5e66d 100644 --- a/sys/core/miniMVC.php +++ b/sys/core/miniMVC.php @@ -356,12 +356,10 @@ class miniMVC extends MM { // Call a singleton, if the get_instance method exists if (method_exists($class, 'get_instance')) { - $this->$name =& $class::get_instance(); - return; + return $this->$name =& $class::get_instance(); } - $this->$name = new $class; - return; + return $this->$name = new $class; } } } diff --git a/sys/libraries/data_store.php b/sys/libraries/data_store.php new file mode 100644 index 0000000..e450d9c --- /dev/null +++ b/sys/libraries/data_store.php @@ -0,0 +1,150 @@ +value data store + * + * @package miniMVC + * @subpackage Libraries + */ +class MM_Data_Store { + + /** + * Settings object represented by the currently loaded JSON file + */ + private $current; + + /** + * Singleton instance + */ + private static $instance; + + /** + * Create and/or load json file + */ + protected function __construct() + { + $path = MM_APP_PATH .'config/data_store.json'; + + if ( ! is_file($path)) + { + touch($path); + $this->current = new StdClass(); + } + else + { + // Load the file + $json = file_get_contents($path); + + // Load the object into the class + $this->current = json_decode($json); + } + } + + // -------------------------------------------------------------------------- + + /** + * Output the data on destruct + */ + public function __destruct() + { + $file_string = json_encode($this->current, JSON_PRETTY_PRINT); + + file_put_contents(MM_APP_PATH .'config/data_store.json', $file_string); + } + + // -------------------------------------------------------------------------- + + /** + * Magic function called when cloning an object + */ + public function __clone() + { + trigger_error('Clone is not allowed.', E_USER_ERROR); + } + + // -------------------------------------------------------------------------- + + /** + * Magic method to simplify isset checking for config options + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return (isset($this->current->{$key})) + ? $this->current->{$key} + : NULL; + } + + // -------------------------------------------------------------------------- + + /** + * Magic method to simplify setting config options + * + * @param string $key + * @param mixed + */ + public function __set($key, $val) + { + return $this->current->{$key} = $val; + } + + // -------------------------------------------------------------------------- + + /** + * Static method to retreive current instance + * of the singleton + * + * @return self + */ + public static function &get_instance() + { + if( ! isset(self::$instance)) + { + $name = __CLASS__; + self::$instance = new $name(); + } + + return self::$instance; + } + + // -------------------------------------------------------------------------- + + /** + * Removes a key from the data store + * + * @param string $key + * @return void + */ + public function del($key) + { + unset($this->current->{$key}); + } + + // -------------------------------------------------------------------------- + + /** + * Return the entire data store object + * + * @return object + */ + public function get_all() + { + return $this->current; + } +} +// End of data store.php \ No newline at end of file