<?php
namespace App\Entity;
use App\Repository\ProgrammeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ProgrammeRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
*/
class Programme
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Expose
* @Groups({"user"})
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="programme")
*/
private $users;
public function __construct()
{
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName( string $name ): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser( User $user ): self
{
if ( !$this->users->contains( $user ) ) {
$this->users[] = $user;
$user->setProgramme( $this );
}
return $this;
}
public function removeUser( User $user ): self
{
if ( $this->users->removeElement( $user ) ) {
// set the owning side to null (unless already changed)
if ( $user->getProgramme() === $this ) {
$user->setProgramme( NULL );
}
}
return $this;
}
}