<?php
namespace MedBrief\MSR\Entity;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use MedBrief\MSR\Repository\ProjectUserRepository;
/**
* ProjectUser
*
* @ORM\Table(name="ProjectUser")
*
* @ORM\Entity(repositoryClass=ProjectUserRepository::class)
*
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class ProjectUser
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \DateTime|null
*
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*
* @Gedmo\Timestampable(on="create")
*/
private $created;
/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
*
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* @var bool|null
*
* @ORM\Column(name="authenticated", type="boolean", nullable=true)
*/
private $authenticated = true;
/**
* @var Collection
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="userPrivateCollection", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="privateCollection_id", referencedColumnName="id", unique=true)
* })
*/
private $privateCollection;
/**
* @var Collection
*
* @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="userPrivateSandboxCollection", cascade={"all"})
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="privateSandboxCollection_id", referencedColumnName="id", unique=true)
* })
*/
private $privateSandboxCollection;
/**
* @var Project
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="projectUsers")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="project_id", referencedColumnName="id")
* })
*/
private $project;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="projectUsers")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
* })
*/
private $user;
public function __toString()
{
return (string) $this->getId();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return ProjectUser
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set created
*
* @param \DateTime $created
*
* @return ProjectUser
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* @param \DateTime $updated
*
* @return ProjectUser
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set project
*
* @param Project $project
*
* @return ProjectUser
*/
public function setProject(?Project $project = null)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* Set user
*
* @param User $user
*
* @return ProjectUser
*/
public function setUser(?User $user = null)
{
$this->user = $user;
// When we change the user, we should also change the collection names to the new user.
if ($user) {
// Set the PrivateCollection name to that of the user's fullname
if ($this->privateCollection) {
$this->privateCollection->setName($user->getFullName());
}
// Set the PrivateSandboxCollection name to that of the user's fullname
if ($this->privateSandboxCollection) {
$this->privateSandboxCollection->setName($user->getFullName());
}
}
return $this;
}
/**
* Get user
*
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* Set privateCollection
*
* @param Collection $privateCollection
*
* @return ProjectUser
*/
public function setPrivateCollection(?Collection $privateCollection = null)
{
$this->privateCollection = $privateCollection;
return $this;
}
/**
* Get privateCollection
*
* @return Collection
*/
public function getPrivateCollection()
{
return $this->privateCollection;
}
/**
* Set privateSandboxCollection
*
* @param Collection $privateSandboxCollection
*
* @return ProjectUser
*/
public function setPrivateSandboxCollection(?Collection $privateSandboxCollection = null)
{
$this->privateSandboxCollection = $privateSandboxCollection;
return $this;
}
/**
* Get privateSandboxCollection
*
* @return Collection
*/
public function getPrivateSandboxCollection()
{
return $this->privateSandboxCollection;
}
/**
* Set authenticated.
*
* @param bool $authenticated
*
* @return ProjectUser
*/
public function setAuthenticated($authenticated)
{
$this->authenticated = $authenticated;
return $this;
}
/**
* Get authenticated.
*
* @return bool
*/
public function getAuthenticated()
{
return $this->authenticated;
}
}