<?phpdeclare(strict_types=1);namespace Hitso\Bundle\TicketsBundle\Entity;use Doctrine\Common\Collections\ArrayCollection;use Hitso\Bundle\CommonBundle\Annotation\Loggable;use Hitso\Bundle\CommonBundle\Doctrine\Behaviours\Identifiable;use Hitso\Bundle\CommonBundle\Doctrine\Behaviours\SiteIdTrait;use Hitso\Bundle\CommonBundle\Entity\EntityInterface;use Hitso\Bundle\CommonBundle\Entity\User;use Hitso\Bundle\CommonBundle\Interfaces\Timestampable;use Hitso\Bundle\CommonBundle\Traits\TimestampableTrait;use Hitso\Bundle\MultiSiteBundle\Annotation\FilterBySiteId;use Hitso\Extra\TicketsBundle\Entity\TicketExtraTrait;/** * Class Ticket * * @package Hitso\Bundle\TicketsBundle\Entity * * @FilterBySiteId * @Loggable( * createMsg={"Utworzono zgłoszenie", "%user% utworzył(|a) nowe zgłoszenie %label%"}, * updateMsg={"Aktualizacja zgłoszenia", "%user% zaktualizował(|a) zgłoszenie %label%"}, * removeMsg={"Usunięcie zgłoszenia", "%user% usun(ął|ęła) zgłoszenie %label%"}, * routeName="hitso_tickets_edit", * labelSource="nameWithStatus" * ) * @codeCoverageIgnore */class Ticket implements EntityInterface, Timestampable{ use Identifiable; use TicketExtraTrait; use SiteIdTrait; use TimestampableTrait; /** * @var string */ private $name; /** * @var string */ private $content; /** * @var string */ private $answer; /** * @var Status */ private $status; /** * @var string */ private $source; /** * @var ArrayCollection */ private $operations; /** * @var User */ private $author; /** * @var string */ private $authorEmail; /** * @var string */ private $authorFirstName; /** * @var string */ private $authorLastName; /** * Ticket constructor. */ public function __construct() { $this->operations = new ArrayCollection(); } /** * Set name * * @param string $name * * @return Ticket */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Set content * * @param string $content * * @return Ticket */ public function setContent($content) { $this->content = $content; return $this; } /** * Get content * * @return string */ public function getContent() { return $this->content; } /** * Set answer * * @param string $answer * * @return Ticket */ public function setAnswer($answer) { $this->answer = $answer; return $this; } /** * Get answer * * @return string */ public function getAnswer() { return $this->answer; } /** * Set status * * @param Status $status * * @return Ticket */ public function setStatus($status) { $this->status = $status; return $this; } /** * Get status * * @return Status */ public function getStatus() { return $this->status; } /** * Get status with status * * @return string */ public function getNameWithStatus() { if ($this->status) { $status = $this->status->getName(); return $this->name . ' (' . $status . ')'; } else { return $this->name; } } /** * Set source * * @param string $source * * @return Ticket */ public function setSource($source) { $this->source = $source; return $this; } /** * Get source * * @return string $source */ public function getSource() { return $this->source; } /** * Set operations * * @param ArrayCollection $operations * * @return Ticket */ public function setOperations(ArrayCollection $operations) { $this->operations = $operations; return $this; } /** * Get operations * * @return ArrayCollection */ public function getOperations() { return $this->operations; } /** * Add operation * * @param Operation $operation * * @return Ticket */ public function addOperation(Operation $operation) { $operation->setTicket($this); $this->operations->add($operation); return $this; } /** * Set author * * @param User $author * * @return Ticket */ public function setAuthor($author) { $this->author = $author; $this->authorEmail = $author->getEmail(); return $this; } /** * Get author * * @return User */ public function getAuthor() { return $this->author; } /** * Set author email * * @param string $authorEmail email * * @return Ticket */ public function setAuthorEmail($authorEmail) { $this->authorEmail = $authorEmail; return $this; } /** * Get author email * * @return string */ public function getAuthorEmail() { return $this->authorEmail; } /** * Set author first name * * @param string $authorFirstName first names * * @return Ticket */ public function setAuthorFirstName($authorFirstName) { $this->authorFirstName = $authorFirstName; return $this; } /** * Get author first name * * @return string */ public function getAuthorFirstName() { return $this->authorFirstName; } /** * Set author last name * * @param string $authorLastName last name * * @return Ticket */ public function setAuthorLastName($authorLastName) { $this->authorLastName = $authorLastName; return $this; } /** * Get author last name * * @return string */ public function getAuthorLastName() { return $this->authorLastName; } /** * Get author name * * @return string */ public function getAuthorName() { return trim($this->authorFirstName . ' ' . $this->authorLastName); }}