2008-02-11 20:08:22 +03:00
|
|
|
<?php
|
|
|
|
|
2008-12-18 17:08:11 +03:00
|
|
|
#namespace Doctrine\Tests\ORM\Models\Forum;
|
2008-07-21 00:13:24 +04:00
|
|
|
|
2008-12-18 17:08:11 +03:00
|
|
|
#use Doctrine\ORM\Entity;
|
|
|
|
#use Doctrine\Common\VirtualPropertySystem;
|
2008-07-21 00:13:24 +04:00
|
|
|
|
2008-12-18 17:08:11 +03:00
|
|
|
class ForumUser
|
2008-02-11 20:08:22 +03:00
|
|
|
{
|
2008-12-18 17:08:11 +03:00
|
|
|
public $id;
|
|
|
|
public $username;
|
|
|
|
public $avatar;
|
2008-07-21 00:13:24 +04:00
|
|
|
|
|
|
|
public static function initMetadata($mapping)
|
2008-02-11 20:08:22 +03:00
|
|
|
{
|
|
|
|
// inheritance mapping
|
2008-07-21 00:13:24 +04:00
|
|
|
$mapping->setInheritanceType('joined', array(
|
2008-02-11 20:08:22 +03:00
|
|
|
'discriminatorColumn' => 'dtype',
|
|
|
|
'discriminatorMap' => array(
|
2008-02-12 01:33:12 +03:00
|
|
|
'user' => 'ForumUser',
|
|
|
|
'admin' => 'ForumAdministrator')
|
2008-02-11 20:08:22 +03:00
|
|
|
));
|
2008-03-23 14:30:29 +03:00
|
|
|
// register subclasses
|
2008-07-21 00:13:24 +04:00
|
|
|
$mapping->setSubclasses(array('ForumAdministrator'));
|
2008-02-12 01:33:12 +03:00
|
|
|
|
2008-03-23 14:30:29 +03:00
|
|
|
// column-to-field mapping
|
2008-07-21 00:13:24 +04:00
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'id',
|
|
|
|
'type' => 'integer',
|
|
|
|
'id' => true,
|
2008-07-27 23:38:56 +04:00
|
|
|
'idGenerator' => 'auto'
|
2008-07-21 00:13:24 +04:00
|
|
|
));
|
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'username',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 50
|
|
|
|
));
|
2008-02-12 01:33:12 +03:00
|
|
|
|
2008-08-16 23:40:59 +04:00
|
|
|
$mapping->mapOneToOne(array(
|
|
|
|
'fieldName' => 'avatar',
|
|
|
|
'targetEntity' => 'ForumAvatar',
|
|
|
|
'joinColumns' => array('avatar_id' => 'id'),
|
2008-08-22 13:05:14 +04:00
|
|
|
'cascade' => array('save')
|
2008-12-18 17:08:11 +03:00
|
|
|
));
|
2008-02-11 20:08:22 +03:00
|
|
|
}
|
|
|
|
}
|