Hi,
using the sfDoctrineGuardPlugin, I have created a new Doctrine
behaviour/template (similar to the Timestampable behaviour). This
creates two fields created_by and updated_by that *should* be foreign
keys to the sfGuardUser.id field. Currently the behaviour creates the
fields but not the relationships. Can anyone check why not?
juro
<?php
/**
* Doctrine Template that creates two fields created_by and updated_by
* @author: Roland Jungwirth
* @version: 0.9
*/
class Doctrine_Template_Usertraceable extends Doctrine_Template
{
/* Array of Timestampable options
*
* @var string
*/
protected $_options = array('created' => array('name' =>
'created_by',
'type' =>
'integer',
'length' =>
4,
'disabled' =>
false,
'options' =>
array()),
'updated' => array('name' =>
'updated_by',
'type' =>
'integer',
'length' =>
4,
'disabled' =>
false,
'options' =>
array()));
public function setTableDefinition()
{
if( ! $this->_options['created']['disabled']) {
$this->hasColumn($this->_options['created']['name'], $this-
>_options['created']['type'], 4, $this->_options['created']
['options']);
}
if( ! $this->_options['updated']['disabled']) {
$this->hasColumn($this->_options['updated']['name'], $this-
>_options['updated']['type'], 4, $this->_options['updated']
['options']);
}
}
public function setUp()
{
$this->hasOne('sfGuardUser as CreatedBy', array('local' => $this-
>_options['created']['name'], 'foreign' => 'id'));
$this->hasOne('sfGuardUser as UpdatedBy', array('local' => $this-
>_options['updated']['name'], 'foreign' => 'id'));
}
}
?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---