2008-02-08 23:20:35 +00:00
|
|
|
<?php
|
2008-07-20 20:13:24 +00:00
|
|
|
|
2009-01-22 19:38:10 +00:00
|
|
|
namespace Doctrine\Tests\Models\CMS;
|
2008-07-20 20:13:24 +00:00
|
|
|
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
2009-01-22 19:38:10 +00:00
|
|
|
* @DoctrineEntity(tableName="cms_users")
|
2009-01-05 17:25:56 +00:00
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
class CmsUser
|
2008-02-08 23:20:35 +00:00
|
|
|
{
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
|
|
|
* @DoctrineId
|
|
|
|
* @DoctrineColumn(type="integer")
|
|
|
|
* @DoctrineIdGenerator("auto")
|
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
public $id;
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
2009-01-07 17:46:02 +00:00
|
|
|
* @DoctrineColumn(type="varchar", length=50)
|
2009-01-05 17:25:56 +00:00
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
public $status;
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
2009-01-07 17:46:02 +00:00
|
|
|
* @DoctrineColumn(type="varchar", length=255)
|
2009-01-05 17:25:56 +00:00
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
public $username;
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
2009-01-07 17:46:02 +00:00
|
|
|
* @DoctrineColumn(type="varchar", length=255)
|
2009-01-05 17:25:56 +00:00
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
public $name;
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
2009-01-22 19:38:10 +00:00
|
|
|
* @DoctrineOneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsPhonenumber",
|
2009-01-29 17:00:44 +00:00
|
|
|
mappedBy="user", cascade={"save", "delete"})
|
2009-01-05 17:25:56 +00:00
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
public $phonenumbers;
|
2009-01-05 17:25:56 +00:00
|
|
|
/**
|
2009-01-22 19:38:10 +00:00
|
|
|
* @DoctrineOneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsArticle", mappedBy="user")
|
2009-01-05 17:25:56 +00:00
|
|
|
*/
|
2008-12-18 14:08:11 +00:00
|
|
|
public $articles;
|
2009-01-09 16:25:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a phonenumber to the user.
|
|
|
|
*
|
|
|
|
* @param <type> $phone
|
|
|
|
*/
|
|
|
|
public function addPhonenumber(CmsPhonenumber $phone) {
|
|
|
|
$this->phonenumbers[] = $phone;
|
|
|
|
$phone->user = $this;
|
|
|
|
}
|
2009-01-29 17:00:44 +00:00
|
|
|
|
|
|
|
public function removePhonenumber($index) {
|
|
|
|
if (isset($this->phonenumbers[$index])) {
|
|
|
|
$ph = $this->phonenumbers[$index];
|
|
|
|
unset($this->phonenumbers[$index]);
|
|
|
|
$ph->user = null;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2008-02-15 00:57:34 +00:00
|
|
|
}
|