* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ namespace Chill\ActivityBundle\Entity; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Center; use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Entity\ActivityType; use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; /** * Class Activity * * @package Chill\ActivityBundle\Entity * @ORM\Entity() * @ORM\Table(name="activity") * @ORM\HasLifecycleCallbacks() * @UserCircleConsistency( * "CHILL_ACTIVITY_SEE_DETAILS", * getUserFunction="getUser", * path="scope") */ class Activity implements HasCenterInterface, HasScopeInterface { /** * @var integer * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var User * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") */ private $user; /** * @var \DateTime * @ORM\Column(type="datetime") */ private $date; /** * @var \DateTime * @ORM\Column(type="time") */ private $durationTime; /** * @var boolean * @ORM\Column(type="boolean") */ private $attendee; /** * @var ActivityReason * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") */ private $reasons; /** * @var ActivityType * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") */ private $type; /** * @var Scope * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") */ private $scope; /** * @var Person * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ private $person; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") */ private $comment; /** * Activity constructor. */ public function __construct() { $this->reasons = new ArrayCollection(); $this->comment = new CommentEmbeddable(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set user * * @param User $user * @return Activity */ public function setUser(User $user) { $this->user = $user; return $this; } /** * Get user * * @return User */ public function getUser() { return $this->user; } /** * Set date * * @param \DateTime $date * @return Activity */ public function setDate($date) { $this->date = $date; return $this; } /** * Get date * * @return \DateTime */ public function getDate() { return $this->date; } /** * Set durationTime * * @param \DateTime $durationTime * @return Activity */ public function setDurationTime($durationTime) { $this->durationTime = $durationTime; return $this; } /** * Get durationTime * * @return \DateTime */ public function getDurationTime() { return $this->durationTime; } /** * Set attendee * * @param boolean $attendee * @return Activity */ public function setAttendee($attendee) { $this->attendee = $attendee; return $this; } /** * Get attendee * * @return boolean */ public function getAttendee() { return $this->attendee; } /** * Add a reason * * @param ActivityReason $reason * @return Activity */ public function addReason(ActivityReason $reason) { $this->reasons[] = $reason; return $this; } /** * @param ActivityReason $reason */ public function removeReason(ActivityReason $reason) { $this->reasons->removeElement($reason); } /** * Get reasons * * @return Collection */ public function getReasons() { return $this->reasons; } /** * Set type * * @param ActivityType $type * @return Activity */ public function setType(ActivityType $type) { $this->type = $type; return $this; } /** * Get type * * @return ActivityType */ public function getType() { return $this->type; } /** * Set scope * * @param Scope $scope * @return Activity */ public function setScope(Scope $scope) { $this->scope = $scope; return $this; } /** * Get scope * * @return Scope */ public function getScope() { return $this->scope; } /** * Set person * * @param Person $person * @return Activity */ public function setPerson(Person $person) { $this->person = $person; return $this; } /** * Get person * * @return Person */ public function getPerson() { return $this->person; } /** * get the center * center is extracted from person * * @return Center */ public function getCenter() { return $this->person->getCenter(); } /** * @return \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable */ public function getComment() { return $this->comment; } /** * @param \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable $comment */ public function setComment($comment) { $this->comment = $comment; } }