2008-02-09 02:20:35 +03:00
|
|
|
<?php
|
2008-07-21 00:13:24 +04:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\Tests\Models\CMS;
|
2008-07-21 00:13:24 +04:00
|
|
|
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
2009-02-04 19:35:36 +03:00
|
|
|
* @DoctrineEntity
|
|
|
|
* @DoctrineTable(name="cms_users")
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
class CmsUser
|
2008-02-09 02:20:35 +03:00
|
|
|
{
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
|
|
|
* @DoctrineId
|
|
|
|
* @DoctrineColumn(type="integer")
|
2009-03-30 23:43:05 +04:00
|
|
|
* @DoctrineGeneratedValue(strategy="auto")
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public $id;
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
2009-05-13 19:19:27 +04:00
|
|
|
* @DoctrineColumn(type="string", length=50)
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public $status;
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
2009-05-13 19:19:27 +04:00
|
|
|
* @DoctrineColumn(type="string", length=255)
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public $username;
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
2009-05-13 19:19:27 +04:00
|
|
|
* @DoctrineColumn(type="string", length=255)
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public $name;
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
2009-02-04 19:35:36 +03:00
|
|
|
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save", "delete"})
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public $phonenumbers;
|
2009-01-05 20:25:56 +03:00
|
|
|
/**
|
2009-02-04 19:35:36 +03:00
|
|
|
* @DoctrineOneToMany(targetEntity="CmsArticle", mappedBy="user")
|
2009-01-05 20:25:56 +03:00
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public $articles;
|
2009-02-02 14:55:50 +03:00
|
|
|
/**
|
2009-02-04 19:35:36 +03:00
|
|
|
* @DoctrineOneToOne(targetEntity="CmsAddress", mappedBy="user", cascade={"save"})
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
public $address;
|
2009-02-04 19:35:36 +03:00
|
|
|
/**
|
2009-02-07 20:02:13 +03:00
|
|
|
* @DoctrineManyToMany(targetEntity="CmsGroup", cascade={"save"})
|
2009-02-04 19:35:36 +03:00
|
|
|
* @DoctrineJoinTable(name="cms_users_groups",
|
|
|
|
joinColumns={{"name"="user_id", "referencedColumnName"="id"}},
|
|
|
|
inverseJoinColumns={{"name"="group_id", "referencedColumnName"="id"}})
|
|
|
|
*/
|
|
|
|
public $groups;
|
2009-01-09 19:25:06 +03:00
|
|
|
|
2009-05-11 14:43:27 +04:00
|
|
|
public function getId() {
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStatus() {
|
|
|
|
return $this->status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsername() {
|
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
2009-01-09 19:25:06 +03:00
|
|
|
/**
|
|
|
|
* Adds a phonenumber to the user.
|
|
|
|
*
|
2009-02-02 14:55:50 +03:00
|
|
|
* @param CmsPhonenumber $phone
|
2009-01-09 19:25:06 +03:00
|
|
|
*/
|
|
|
|
public function addPhonenumber(CmsPhonenumber $phone) {
|
|
|
|
$this->phonenumbers[] = $phone;
|
2009-05-07 17:54:01 +04:00
|
|
|
if ($phone->user !== $this) {
|
|
|
|
$phone->user = $this;
|
|
|
|
}
|
2009-01-09 19:25:06 +03:00
|
|
|
}
|
2009-01-29 20:00:44 +03:00
|
|
|
|
2009-05-11 14:43:27 +04:00
|
|
|
public function getPhonenumbers() {
|
|
|
|
return $this->phonenumbers;
|
|
|
|
}
|
|
|
|
|
2009-04-09 22:12:48 +04:00
|
|
|
public function addArticle(CmsArticle $article) {
|
|
|
|
$this->articles[] = $article;
|
2009-05-07 17:54:01 +04:00
|
|
|
if ($article->user !== $this) {
|
|
|
|
$article->user = $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addGroup(CmsGroup $group) {
|
|
|
|
$this->groups[] = $group;
|
|
|
|
$group->addUser($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getGroups() {
|
|
|
|
return $this->groups;
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-01-29 20:00:44 +03: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 03:57:34 +03:00
|
|
|
}
|