Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.29 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Entity;
  4.  
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Groups;
  9.  
  10. /**
  11.  * Button
  12.  *
  13.  * @Serializer\ExclusionPolicy("all")
  14.  * @ORM\Table(name="buttons")
  15.  * @ORM\Entity(repositoryClass="AppBundle\Repository\ButtonRepository")
  16.  */
  17. class Button
  18. {
  19.     /**
  20.      * @var int
  21.      *
  22.      * @Serializer\Expose()
  23.      * @Groups({"test"})
  24.      * @ORM\Column(name="id", type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $id;
  29.  
  30.     /**
  31.      * @var string
  32.      *
  33.      * @Serializer\Expose()
  34.      * @Groups({"history", "historyDetails", "test", "line", "lineEdit", "reportDetails", "agroupDetails"})
  35.      * @ORM\Column(name="name", type="string", length=255)
  36.      */
  37.     private $name;
  38.  
  39.     /**
  40.      * @var boolean
  41.      * @Serializer\Expose()
  42.      * @ORM\Column(name="state", type="boolean")
  43.      */
  44.     private $state;
  45.  
  46.     /**
  47.      * @var boolean
  48.      * @Serializer\Expose()
  49.      * @Groups({"history", "lineEdit"})
  50.      * @ORM\Column(name="is_reported", type="boolean")
  51.      */
  52.     private $isReported;
  53.  
  54.     /**
  55.      * @Serializer\Expose()
  56.      * @Groups({"history", "historyDetails", "agroupDetails", "reportDetails"})
  57.      * Many Buttons have One Line
  58.      * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Line", inversedBy="buttons")
  59.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  60.      */
  61.     private $line;
  62.  
  63.     /**
  64.      * @Serializer\Expose()
  65.      * Many Buttons have Many AssignmentGroups.
  66.      * @ORM\ManyToMany(targetEntity="AppBundle\Entity\AssignmentGroup", inversedBy="buttons")
  67.      * @ORM\JoinTable(name="buttons_assignmentGroups")
  68.      */
  69.     private $assignmentGroups;
  70.  
  71.     /**
  72.      * @ORM\OneToMany(targetEntity="AppBundle\Entity\History", mappedBy="button", cascade={"persist"})
  73.      */
  74.     private $historyEntries;
  75.  
  76.  
  77.     public function __construct()
  78.     {
  79.         $this->assignmentGroups = new ArrayCollection();
  80.     }
  81.  
  82.     /**
  83.      * @Serializer\VirtualProperty()
  84.      * @Serializer\SerializedName("assignmentGroups")
  85.      * @Groups({"lineEdit"})
  86.      */
  87.     public function getOnlyId()
  88.     {
  89.         return $this->getAssignmentGroups()->map(function ($i) {  return $i->getId(); });
  90.     }
  91.  
  92.     /**
  93.      * Get id
  94.      *
  95.      * @return int
  96.      */
  97.     public function getId()
  98.     {
  99.         return $this->id;
  100.     }
  101.  
  102.     /**
  103.      * Get name
  104.      *
  105.      * @return string
  106.      */
  107.     public function getName()
  108.     {
  109.         return $this->name;
  110.     }
  111.  
  112.     /**
  113.      * Set name
  114.      *
  115.      * @param string $name
  116.      *
  117.      * @return Button
  118.      */
  119.     public function setName($name)
  120.     {
  121.         $this->name = $name;
  122.     }
  123.  
  124.     /**
  125.      * @return bool
  126.      */
  127.     public function getState()
  128.     {
  129.         return $this->state;
  130.     }
  131.  
  132.     /**
  133.      * @param bool $state
  134.      */
  135.     public function setState($state)
  136.     {
  137.         $this->state = $state;
  138.     }
  139.  
  140.     /**
  141.      * @return mixed
  142.      */
  143.     public function getLine()
  144.     {
  145.         return $this->line;
  146.     }
  147.  
  148.     /**
  149.      * @param mixed $line
  150.      */
  151.     public function setLine($line)
  152.     {
  153.         $this->line = $line;
  154.     }
  155.  
  156.     /**
  157.      * @return mixed
  158.      */
  159.     public function getAssignmentGroups()
  160.     {
  161.         return $this->assignmentGroups;
  162.     }
  163.  
  164.     /**
  165.      * @return bool
  166.      */
  167.     public function isReported()
  168.     {
  169.         return $this->isReported;
  170.     }
  171.  
  172.     /**
  173.      * @param bool $isReported
  174.      */
  175.     public function setIsReported($isReported)
  176.     {
  177.         $this->isReported = $isReported;
  178.     }
  179.  
  180.     /**
  181.      * @param mixed $assignmentGroups
  182.      */
  183.     public function setAssignmentGroups($assignmentGroups)
  184.     {
  185.         $this->assignmentGroups = $assignmentGroups;
  186.     }
  187.  
  188.     /**
  189.      * @return mixed
  190.      */
  191.     public function getHistoryEntries()
  192.     {
  193.         return $this->historyEntries;
  194.     }
  195.  
  196.     /**
  197.      * @param mixed $historyEntries
  198.      */
  199.     public function setHistoryEntries($historyEntries)
  200.     {
  201.         $this->historyEntries = $historyEntries;
  202.     }
  203.  
  204.     public function addAssignmentGroup(AssignmentGroup $assignmentGroup)
  205.     {
  206.         $this->assignmentGroups->add($assignmentGroup);
  207.     }
  208.  
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement