src/Hitso/Bundle/TicketsBundle/Entity/Ticket.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Hitso\Bundle\TicketsBundle\Entity;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Hitso\Bundle\CommonBundle\Annotation\Loggable;
  6. use Hitso\Bundle\CommonBundle\Doctrine\Behaviours\Identifiable;
  7. use Hitso\Bundle\CommonBundle\Doctrine\Behaviours\SiteIdTrait;
  8. use Hitso\Bundle\CommonBundle\Entity\EntityInterface;
  9. use Hitso\Bundle\CommonBundle\Entity\User;
  10. use Hitso\Bundle\CommonBundle\Interfaces\Timestampable;
  11. use Hitso\Bundle\CommonBundle\Traits\TimestampableTrait;
  12. use Hitso\Bundle\MultiSiteBundle\Annotation\FilterBySiteId;
  13. use Hitso\Extra\TicketsBundle\Entity\TicketExtraTrait;
  14. /**
  15.  * Class Ticket
  16.  *
  17.  * @package Hitso\Bundle\TicketsBundle\Entity
  18.  *
  19.  * @FilterBySiteId
  20.  * @Loggable(
  21.  *     createMsg={"Utworzono zgłoszenie", "%user% utworzył(|a) nowe zgłoszenie %label%"},
  22.  *     updateMsg={"Aktualizacja zgłoszenia", "%user% zaktualizował(|a) zgłoszenie %label%"},
  23.  *     removeMsg={"Usunięcie zgłoszenia", "%user% usun(ął|ęła) zgłoszenie %label%"},
  24.  *     routeName="hitso_tickets_edit",
  25.  *     labelSource="nameWithStatus"
  26.  * )
  27.  * @codeCoverageIgnore
  28.  */
  29. class Ticket implements EntityInterfaceTimestampable
  30. {
  31.     use Identifiable;
  32.     use TicketExtraTrait;
  33.     use SiteIdTrait;
  34.     use TimestampableTrait;
  35.     /**
  36.      * @var string
  37.      */
  38.     private $name;
  39.     /**
  40.      * @var string
  41.      */
  42.     private $content;
  43.     /**
  44.      * @var string
  45.      */
  46.     private $answer;
  47.     /**
  48.      * @var Status
  49.      */
  50.     private $status;
  51.     /**
  52.      * @var string
  53.      */
  54.     private $source;
  55.     /**
  56.      * @var ArrayCollection
  57.      */
  58.     private $operations;
  59.     /**
  60.      * @var User
  61.      */
  62.     private $author;
  63.     /**
  64.      * @var string
  65.      */
  66.     private $authorEmail;
  67.     /**
  68.      * @var string
  69.      */
  70.     private $authorFirstName;
  71.     /**
  72.      * @var string
  73.      */
  74.     private $authorLastName;
  75.     /**
  76.      * Ticket constructor.
  77.      */
  78.     public function __construct()
  79.     {
  80.         $this->operations = new ArrayCollection();
  81.     }
  82.     /**
  83.      * Set name
  84.      *
  85.      * @param string $name
  86.      *
  87.      * @return Ticket
  88.      */
  89.     public function setName($name)
  90.     {
  91.         $this->name $name;
  92.         return $this;
  93.     }
  94.     /**
  95.      * Get name
  96.      *
  97.      * @return string
  98.      */
  99.     public function getName()
  100.     {
  101.         return $this->name;
  102.     }
  103.     /**
  104.      * Set content
  105.      *
  106.      * @param string $content
  107.      *
  108.      * @return Ticket
  109.      */
  110.     public function setContent($content)
  111.     {
  112.         $this->content $content;
  113.         return $this;
  114.     }
  115.     /**
  116.      * Get content
  117.      *
  118.      * @return string
  119.      */
  120.     public function getContent()
  121.     {
  122.         return $this->content;
  123.     }
  124.     /**
  125.      * Set answer
  126.      *
  127.      * @param string $answer
  128.      *
  129.      * @return Ticket
  130.      */
  131.     public function setAnswer($answer)
  132.     {
  133.         $this->answer $answer;
  134.         return $this;
  135.     }
  136.     /**
  137.      * Get answer
  138.      *
  139.      * @return string
  140.      */
  141.     public function getAnswer()
  142.     {
  143.         return $this->answer;
  144.     }
  145.     /**
  146.      * Set status
  147.      *
  148.      * @param Status $status
  149.      *
  150.      * @return Ticket
  151.      */
  152.     public function setStatus($status)
  153.     {
  154.         $this->status $status;
  155.         return $this;
  156.     }
  157.     /**
  158.      * Get status
  159.      *
  160.      * @return Status
  161.      */
  162.     public function getStatus()
  163.     {
  164.         return $this->status;
  165.     }
  166.     /**
  167.      * Get status with status
  168.      *
  169.      * @return string
  170.      */
  171.     public function getNameWithStatus()
  172.     {
  173.         if ($this->status) {
  174.             $status $this->status->getName();
  175.             return $this->name ' (' $status ')';
  176.         } else {
  177.             return $this->name;
  178.         }
  179.     }
  180.     /**
  181.      * Set source
  182.      *
  183.      * @param string $source
  184.      *
  185.      * @return Ticket
  186.      */
  187.     public function setSource($source)
  188.     {
  189.         $this->source $source;
  190.         return $this;
  191.     }
  192.     /**
  193.      * Get source
  194.      *
  195.      * @return string $source
  196.      */
  197.     public function getSource()
  198.     {
  199.         return $this->source;
  200.     }
  201.     /**
  202.      * Set operations
  203.      *
  204.      * @param ArrayCollection $operations
  205.      *
  206.      * @return Ticket
  207.      */
  208.     public function setOperations(ArrayCollection $operations)
  209.     {
  210.         $this->operations $operations;
  211.         return $this;
  212.     }
  213.     /**
  214.      * Get operations
  215.      *
  216.      * @return ArrayCollection
  217.      */
  218.     public function getOperations()
  219.     {
  220.         return $this->operations;
  221.     }
  222.     /**
  223.      * Add operation
  224.      *
  225.      * @param Operation $operation
  226.      *
  227.      * @return Ticket
  228.      */
  229.     public function addOperation(Operation $operation)
  230.     {
  231.         $operation->setTicket($this);
  232.         $this->operations->add($operation);
  233.         return $this;
  234.     }
  235.     /**
  236.      * Set author
  237.      *
  238.      * @param User $author
  239.      *
  240.      * @return Ticket
  241.      */
  242.     public function setAuthor($author)
  243.     {
  244.         $this->author      $author;
  245.         $this->authorEmail $author->getEmail();
  246.         return $this;
  247.     }
  248.     /**
  249.      * Get author
  250.      *
  251.      * @return User
  252.      */
  253.     public function getAuthor()
  254.     {
  255.         return $this->author;
  256.     }
  257.     /**
  258.      * Set author email
  259.      *
  260.      * @param string $authorEmail email
  261.      *
  262.      * @return Ticket
  263.      */
  264.     public function setAuthorEmail($authorEmail)
  265.     {
  266.         $this->authorEmail $authorEmail;
  267.         return $this;
  268.     }
  269.     /**
  270.      * Get author email
  271.      *
  272.      * @return string
  273.      */
  274.     public function getAuthorEmail()
  275.     {
  276.         return $this->authorEmail;
  277.     }
  278.     /**
  279.      * Set author first name
  280.      *
  281.      * @param string $authorFirstName first names
  282.      *
  283.      * @return Ticket
  284.      */
  285.     public function setAuthorFirstName($authorFirstName)
  286.     {
  287.         $this->authorFirstName $authorFirstName;
  288.         return $this;
  289.     }
  290.     /**
  291.      * Get author first name
  292.      *
  293.      * @return string
  294.      */
  295.     public function getAuthorFirstName()
  296.     {
  297.         return $this->authorFirstName;
  298.     }
  299.     /**
  300.      * Set author last name
  301.      *
  302.      * @param string $authorLastName last name
  303.      *
  304.      * @return Ticket
  305.      */
  306.     public function setAuthorLastName($authorLastName)
  307.     {
  308.         $this->authorLastName $authorLastName;
  309.         return $this;
  310.     }
  311.     /**
  312.      * Get author last name
  313.      *
  314.      * @return string
  315.      */
  316.     public function getAuthorLastName()
  317.     {
  318.         return $this->authorLastName;
  319.     }
  320.     /**
  321.      * Get author name
  322.      *
  323.      * @return string
  324.      */
  325.     public function getAuthorName()
  326.     {
  327.         return trim($this->authorFirstName ' ' $this->authorLastName);
  328.     }
  329. }