1
0
mirror of synced 2025-01-18 06:21:40 +03:00
This commit is contained in:
zYne 2007-09-01 17:46:42 +00:00
parent 3fe5b807a1
commit 862791957a

View File

@ -190,8 +190,33 @@ class AuthTemplate extends Doctrine_Record
Now you can simply use the methods found in AuthTemplate within the User class as shown above. Now you can simply use the methods found in AuthTemplate within the User class as shown above.
<code type="php"> <code type="php">
$user = new User();
$user->login($username, $password); $user->login($username, $password);
</code> </code>
You can get the record that invoked the delegate method by using the getInvoker() method of Doctrine_Template. Consider the AuthTemplate example. If we want to have access to User object we just need to do the following:
<code type="php">
class AuthTemplate extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('username', 'string', 16);
$this->hasColumn('password', 'string', 16);
}
public function login($username, $password)
{
// do something with the Invoker object here
$object = $this->getInvoker();
}
}
</code>
++ Working with multiple templates
Each class can consists of multiple templates. If the templates contain similar definitions the most recently loaded template always overrides the former.