added team permissions for activities (#1872)

This commit is contained in:
Kevin Papst
2020-08-08 18:50:04 +02:00
committed by GitHub
parent dc162bf385
commit 0914ebf737
84 changed files with 4300 additions and 3279 deletions

View File

@@ -114,12 +114,27 @@ class Team
* @ORM\ManyToMany(targetEntity="Project", mappedBy="teams", fetch="EXTRA_LAZY")
*/
private $projects;
/**
* Activities
*
* All activities assigned to the team
*
* @var Activity[]|ArrayCollection
*
* @Serializer\Expose()
* @Serializer\Groups({"Team_Entity", "Expanded"})
* @SWG\Property(type="array", @SWG\Items(ref="#/definitions/Activity"))
*
* @ORM\ManyToMany(targetEntity="Activity", mappedBy="teams", fetch="EXTRA_LAZY")
*/
private $activities;
public function __construct()
{
$this->users = new ArrayCollection();
$this->customers = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->activities = new ArrayCollection();
}
public function getId(): ?int
@@ -256,6 +271,39 @@ class Team
return $this->projects;
}
public function hasActivity(Activity $activity): bool
{
return $this->activities->contains($activity);
}
public function addActivity(Activity $activity)
{
if ($this->activities->contains($activity)) {
return;
}
$this->activities->add($activity);
$activity->addTeam($this);
}
public function removeActivity(Activity $activity)
{
if (!$this->activities->contains($activity)) {
return;
}
$this->activities->removeElement($activity);
$activity->removeTeam($this);
}
/**
* @return Collection<Activity>
*/
public function getActivities(): iterable
{
return $this->activities;
}
/**
* @return string
*/