Doctrine Behavior / Templates: Is there a way overwrite or load data into the invoking Doctrine_Record from a Doctrine_Template? -
hy!
i'm new doctrine library. i'm trying take advantage of doctrine behavior (templating) system build authenticable behavior ran few problems.
this how wanted declare it:
class baseadminuser extends doctrine_record{ public function settabledefinition(){ // ... } public function setup(){ // ... $this->actas(new doctrine_template_authenticatable()); } }
this how wanted use it:
in admin bootstrap file:
// ... $admin = new adminuser(); if(!$admin->login_check()){ redirect("login.php"); }else{ // $admin->id available }
in admin login.php page:
// ... if($data = $_post){ $admin->login($data); }
i wanted template use native php sessions (using $_session
) following:
- upon login set session , save record
doctrine_core::hydrate_array
in - upon instantiation of record , template check if session data exists
, load invoking record id session
one approach tried re-route $invoker. doesn't work.
class doctrine_template_authenticatable extends doctrine_template{ // ... public function setup(){ // ... if(isset($session_data['id'])){ $invoker = &$this->getinvoker(); $invoker = $this->gettable()->find($session_data['id']); } } // ... }
i've looked trough doctrine_record api documentation , not find function load (hydrate) different table row object based on id or otherwise.
there's fromarray($arr)
, hydrate($arr, $overwrite)
:
doctrine_record::fromarray(string array, bool deep)) doctrine_record::hydrate(array data, boolean overwritelocalchanges)
but fake , load data without id.
$this->getinvoker()->hydrate($session_data); // (...) echo $admin->id; // empty $this->getinvoker()->fromarray($session_data); // uncaught exception 'doctrine_table_exception' message 'unknown relation alias id'
my question is:
there way overwrite or load data invoking doctrine_record
doctrine_template
?
Comments
Post a Comment