create timesheet for multiple users (#1716)

This commit is contained in:
Kevin Papst
2020-05-18 23:35:43 +02:00
committed by GitHub
parent 9da46bbdcd
commit e61ffe4db4
20 changed files with 548 additions and 16 deletions

View File

@@ -0,0 +1,86 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Form\Model;
use App\Entity\Team;
use App\Entity\Timesheet;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @App\Validator\Constraints\TimesheetMultiUser
*/
final class MultiUserTimesheet extends Timesheet
{
/**
* @var Collection<User>
*/
private $users;
/**
* @var Collection<Team>
*/
private $teams;
public function __construct()
{
parent::__construct();
$this->users = new ArrayCollection();
$this->teams = new ArrayCollection();
}
/**
* @return Collection<User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user)
{
$this->users->add($user);
return $this;
}
public function removeUser(User $user)
{
if ($this->users->contains($user)) {
$this->users->remove($user);
}
return $this;
}
/**
* @return Collection<Team>
*/
public function getTeams(): Collection
{
return $this->teams;
}
public function addTeam(Team $team)
{
$this->teams->add($team);
return $this;
}
public function removeTeam(Team $team)
{
if ($this->teams->contains($team)) {
$this->teams->remove($team);
}
return $this;
}
}