diff options
author | Stanislav <stanislau.wolski@gmail.com> | 2012-05-22 01:34:33 +0300 |
---|---|---|
committer | Stanislav <stanislau.wolski@gmail.com> | 2012-05-22 01:34:33 +0300 |
commit | a421d3fd4c07c21dcae99a23678904b8d749728a (patch) | |
tree | f1947054de3b3c74b6d3ffa52c4bd6db3714098c /codebase/base_connector.php | |
parent | b2532d1a751c728174287d9c8e2fc46c18de437f (diff) | |
download | connector-php-a421d3fd4c07c21dcae99a23678904b8d749728a.zip connector-php-a421d3fd4c07c21dcae99a23678904b8d749728a.tar.gz connector-php-a421d3fd4c07c21dcae99a23678904b8d749728a.tar.bz2 |
[add] model can intercept loading and saving
Diffstat (limited to 'codebase/base_connector.php')
-rw-r--r-- | codebase/base_connector.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php index c831c8e..66f1f4c 100644 --- a/codebase/base_connector.php +++ b/codebase/base_connector.php @@ -283,6 +283,9 @@ class Connector { protected $names;//!< hash of names for used classes
protected $encoding="utf-8";//!< assigned encoding (UTF-8 by default)
protected $editing=false;//!< flag of edit mode ( response for dataprocessor )
+
+ protected $model=false;
+
private $updating=false;//!< flag of update mode ( response for data-update )
private $db; //!< db connection resource
protected $dload;//!< flag of dyn. loading mode
@@ -357,6 +360,14 @@ class Connector { }
+ //model is a class, which will be used for all data operations
+ //we expect that it has next methods get, update, insert, delete
+ //if method was not defined - we will use default logic
+ public function useModel($model){
+ $this->model = $model;
+ }
+
+
/*! config connector based on table
@param table
@@ -458,7 +469,11 @@ class Connector { $this->event->trigger("beforeFilter",$wrap);
$wrap->store();
- $this->output_as_xml($this->get_resource());
+
+ if ($this->model && method_exists($this->model, "get"))
+ $this->output_as_xml( call_user_func(array($this->model, "get"), $this->request));
+ else
+ $this->output_as_xml($this->get_resource());
}
}
$this->end_run();
|