mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 17:28:23 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			333 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			333 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| /**
 | |
|  * Chill is a software for social workers
 | |
|  *
 | |
|  * For the full copyright and license information, please view
 | |
|  * the LICENSE file that was distributed with this source code.
 | |
|  */
 | |
| 
 | |
| namespace Chill\ActivityBundle\Entity;
 | |
| 
 | |
| use Chill\MainBundle\Entity\Center;
 | |
| use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
 | |
| use Chill\MainBundle\Entity\HasCenterInterface;
 | |
| use Chill\MainBundle\Entity\HasScopeInterface;
 | |
| use Chill\MainBundle\Entity\Scope;
 | |
| use Chill\MainBundle\Entity\User;
 | |
| use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
 | |
| use Chill\PersonBundle\Entity\Person;
 | |
| use DateTime;
 | |
| use Doctrine\Common\Collections\ArrayCollection;
 | |
| use Doctrine\Common\Collections\Collection;
 | |
| use Doctrine\ORM\Mapping as ORM;
 | |
| 
 | |
| /**
 | |
|  * Class Activity.
 | |
|  *
 | |
|  * @ORM\Entity
 | |
|  * @ORM\Table(name="activity")
 | |
|  * @ORM\HasLifecycleCallbacks
 | |
|  * @UserCircleConsistency(
 | |
|  *     "CHILL_ACTIVITY_SEE_DETAILS",
 | |
|  *     getUserFunction="getUser",
 | |
|  * path="scope")
 | |
|  */
 | |
| class Activity implements HasCenterInterface, HasScopeInterface
 | |
| {
 | |
|     /**
 | |
|      * @var bool
 | |
|      * @ORM\Column(type="boolean")
 | |
|      */
 | |
|     private $attendee;
 | |
| 
 | |
|     /**
 | |
|      * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
 | |
|      */
 | |
|     private $comment;
 | |
| 
 | |
|     /**
 | |
|      * @var DateTime
 | |
|      * @ORM\Column(type="datetime")
 | |
|      */
 | |
|     private $date;
 | |
| 
 | |
|     /**
 | |
|      * @var DateTime
 | |
|      * @ORM\Column(type="time")
 | |
|      */
 | |
|     private $durationTime;
 | |
| 
 | |
|     /**
 | |
|      * @var int
 | |
|      *
 | |
|      * @ORM\Id
 | |
|      * @ORM\Column(name="id", type="integer")
 | |
|      * @ORM\GeneratedValue(strategy="AUTO")
 | |
|      */
 | |
|     private $id;
 | |
| 
 | |
|     /**
 | |
|      * @var Person
 | |
|      * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
 | |
|      */
 | |
|     private $person;
 | |
| 
 | |
|     /**
 | |
|      * @var ActivityReason
 | |
|      * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
 | |
|      */
 | |
|     private $reasons;
 | |
| 
 | |
|     /**
 | |
|      * @var Scope
 | |
|      * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
 | |
|      */
 | |
|     private $scope;
 | |
| 
 | |
|     /**
 | |
|      * @var ActivityType
 | |
|      * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
 | |
|      */
 | |
|     private $type;
 | |
| 
 | |
|     /**
 | |
|      * @var User
 | |
|      * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
 | |
|      */
 | |
|     private $user;
 | |
| 
 | |
|     /**
 | |
|      * Activity constructor.
 | |
|      */
 | |
|     public function __construct()
 | |
|     {
 | |
|         $this->reasons = new ArrayCollection();
 | |
|         $this->comment = new CommentEmbeddable();
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Add a reason.
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function addReason(ActivityReason $reason)
 | |
|     {
 | |
|         $this->reasons[] = $reason;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get attendee.
 | |
|      *
 | |
|      * @return bool
 | |
|      */
 | |
|     public function getAttendee()
 | |
|     {
 | |
|         return $this->attendee;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 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;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get date.
 | |
|      *
 | |
|      * @return DateTime
 | |
|      */
 | |
|     public function getDate()
 | |
|     {
 | |
|         return $this->date;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get durationTime.
 | |
|      *
 | |
|      * @return DateTime
 | |
|      */
 | |
|     public function getDurationTime()
 | |
|     {
 | |
|         return $this->durationTime;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get id.
 | |
|      *
 | |
|      * @return int
 | |
|      */
 | |
|     public function getId()
 | |
|     {
 | |
|         return $this->id;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get person.
 | |
|      *
 | |
|      * @return Person
 | |
|      */
 | |
|     public function getPerson()
 | |
|     {
 | |
|         return $this->person;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get reasons.
 | |
|      *
 | |
|      * @return Collection
 | |
|      */
 | |
|     public function getReasons()
 | |
|     {
 | |
|         return $this->reasons;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get scope.
 | |
|      *
 | |
|      * @return Scope
 | |
|      */
 | |
|     public function getScope()
 | |
|     {
 | |
|         return $this->scope;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get type.
 | |
|      *
 | |
|      * @return ActivityType
 | |
|      */
 | |
|     public function getType()
 | |
|     {
 | |
|         return $this->type;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get user.
 | |
|      *
 | |
|      * @return User
 | |
|      */
 | |
|     public function getUser()
 | |
|     {
 | |
|         return $this->user;
 | |
|     }
 | |
| 
 | |
|     public function removeReason(ActivityReason $reason)
 | |
|     {
 | |
|         $this->reasons->removeElement($reason);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set attendee.
 | |
|      *
 | |
|      * @param bool $attendee
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setAttendee($attendee)
 | |
|     {
 | |
|         $this->attendee = $attendee;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable $comment
 | |
|      */
 | |
|     public function setComment($comment)
 | |
|     {
 | |
|         $this->comment = $comment;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set date.
 | |
|      *
 | |
|      * @param DateTime $date
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setDate($date)
 | |
|     {
 | |
|         $this->date = $date;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set durationTime.
 | |
|      *
 | |
|      * @param DateTime $durationTime
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setDurationTime($durationTime)
 | |
|     {
 | |
|         $this->durationTime = $durationTime;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set person.
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setPerson(Person $person)
 | |
|     {
 | |
|         $this->person = $person;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set scope.
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setScope(Scope $scope)
 | |
|     {
 | |
|         $this->scope = $scope;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set type.
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setType(ActivityType $type)
 | |
|     {
 | |
|         $this->type = $type;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Set user.
 | |
|      *
 | |
|      * @return Activity
 | |
|      */
 | |
|     public function setUser(User $user)
 | |
|     {
 | |
|         $this->user = $user;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| }
 |