2008-02-08 23:20:35 +00:00
|
|
|
<?php
|
2008-07-20 20:13:24 +00:00
|
|
|
|
2008-12-18 14:08:11 +00:00
|
|
|
#namespace Doctrine\Tests\ORM\Models\Cms;
|
2008-07-20 20:13:24 +00:00
|
|
|
|
2008-12-18 14:08:11 +00:00
|
|
|
#use Doctrine\ORM\Entity;
|
|
|
|
#use Doctrine\Common\VirtualPropertySystem;
|
2008-07-20 20:13:24 +00:00
|
|
|
|
2008-12-18 14:08:11 +00:00
|
|
|
class CmsUser
|
2008-02-08 23:20:35 +00:00
|
|
|
{
|
2008-12-18 14:08:11 +00:00
|
|
|
public $id;
|
|
|
|
public $status;
|
|
|
|
public $username;
|
|
|
|
public $name;
|
|
|
|
public $phonenumbers;
|
|
|
|
public $articles;
|
|
|
|
|
|
|
|
/*static function construct() {
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'id', 'int');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'status', 'int');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'username', 'string');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'name', 'string');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'phonenumbers', 'CmsPhonenumber');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'articles', 'CmsArticle');
|
|
|
|
}*/
|
2008-07-20 20:13:24 +00:00
|
|
|
|
|
|
|
public static function initMetadata($mapping)
|
|
|
|
{
|
2008-12-18 14:08:11 +00:00
|
|
|
/* NEW
|
|
|
|
$mapping->addFieldMetadata('id', array(
|
|
|
|
'doctrine.id' => true, 'doctrine.idGenerator' => 'auto'
|
|
|
|
));
|
|
|
|
$mapping->addFieldMetadata('status', array(
|
|
|
|
'doctrine.length' => 50
|
|
|
|
));
|
|
|
|
$mapping->addFieldMetadata('phonenumbers', array(
|
|
|
|
'doctrine.oneToMany' => array('mappedBy' => 'user')
|
|
|
|
));
|
|
|
|
$mapping->addFieldMetadata('articles', array(
|
|
|
|
'doctrine.oneToMany' => array('mappedBy' => 'user')
|
|
|
|
));
|
|
|
|
*/
|
|
|
|
|
2008-07-20 20:13:24 +00:00
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'id',
|
|
|
|
'type' => 'integer',
|
|
|
|
'id' => true,
|
2008-07-27 19:38:56 +00:00
|
|
|
'idGenerator' => 'auto'
|
2008-07-20 20:13:24 +00:00
|
|
|
));
|
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'status',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 50
|
|
|
|
));
|
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'username',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 255
|
|
|
|
));
|
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'name',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 255
|
|
|
|
));
|
2008-08-16 19:40:59 +00:00
|
|
|
|
|
|
|
$mapping->mapOneToMany(array(
|
|
|
|
'fieldName' => 'phonenumbers',
|
|
|
|
'targetEntity' => 'CmsPhonenumber',
|
2008-08-22 09:05:14 +00:00
|
|
|
'mappedBy' => 'user'
|
2008-08-16 19:40:59 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$mapping->mapOneToMany(array(
|
|
|
|
'fieldName' => 'articles',
|
|
|
|
'targetEntity' => 'CmsArticle',
|
2008-08-22 09:05:14 +00:00
|
|
|
'mappedBy' => 'user'
|
2008-08-16 19:40:59 +00:00
|
|
|
));
|
|
|
|
|
2008-07-20 20:13:24 +00:00
|
|
|
}
|
2008-02-15 00:57:34 +00:00
|
|
|
}
|