apps/uvdesk/custom-fields/src/Entity/CustomFields.php line 14

Open in your IDE?
  1. <?php
  2. namespace UVDesk\CommunityPackages\UVDesk\CustomFields\Entity;
  3. use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * CustomFields
  8.  * @ORM\Table(name="uv_pkg_uvdesk_form_component_custom_fields")
  9.  * @ORM\Entity(repositoryClass="UVDesk\CommunityPackages\UVDesk\CustomFields\Repository\CustomFieldsRepository")
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class CustomFields
  13. {
  14.     /**
  15.      * @var integer
  16.      * 
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var string
  24.      * @ORM\Column(type="string", length=255)
  25.      * @Assert\NotBlank
  26.      */
  27.     private $name;
  28.     /**
  29.      * @var string
  30.      * @ORM\Column(type="string", length=255)
  31.      * @Assert\NotBlank(message="Please select a FieldType")
  32.      */ 
  33.     private $fieldType;
  34.     /**
  35.      * @var string
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $value;
  39.     /**
  40.      * @var string
  41.      * @ORM\Column(type="string", length=255, nullable=true)
  42.      */
  43.     private $placeholder;
  44.     /**
  45.      * @var boolean
  46.      * @ORM\Column(type="boolean", nullable=true)
  47.      */
  48.     private $required;
  49.     /**
  50.      * @var boolean
  51.      * @ORM\Column(type="boolean", nullable=true)
  52.      */
  53.     private $status;
  54.     /**
  55.      * @var integer
  56.      * @ORM\Column(type="integer", nullable=true)
  57.      * @Assert\NotBlank
  58.      */
  59.     private $sortOrder;
  60.     /**
  61.      * @var \DateTime
  62.      * @ORM\Column(type="datetime")
  63.      */
  64.     private $dateAdded;
  65.     /**
  66.      * @var \DateTime
  67.      * @ORM\Column(type="datetime")
  68.      */
  69.     private $dateUpdated;
  70.     /**
  71.      * @var \Doctrine\Common\Collections\Collection
  72.      * @ORM\OneToMany(targetEntity="UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\CustomFieldsValues", mappedBy="customFields")
  73.      */
  74.     private $customFieldValues;
  75.     /**
  76.      * @var \Doctrine\Common\Collections\Collection
  77.      * 
  78.      */
  79.     private $customFieldValuesSorted;
  80.     /**
  81.      * @var \Doctrine\Common\Collections\Collection
  82.      * @ORM\OneToMany(targetEntity="UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\TicketCustomFieldsValues", mappedBy="ticketCustomFieldsValues")
  83.      */
  84.     private $ticketValues;
  85.     
  86.     /**
  87.      * @var \Doctrine\Common\Collections\Collection
  88.      * 
  89.      * @ORM\ManyToMany(targetEntity="Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketType")
  90.      * @ORM\JoinTable(name="uv_pkg_uvdesk_form_component_custom_fields_types",
  91.      *      joinColumns={@ORM\JoinColumn(name="custom_fields_id", referencedColumnName="id")},
  92.      *      inverseJoinColumns={@ORM\JoinColumn(name="ticket_type_id", referencedColumnName="id")})
  93.      * 
  94.      */
  95.     private $customFieldsDependency;
  96.     /**
  97.      * @var \Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketType
  98.      */
  99.     public $dependency;
  100.     
  101.     /**
  102.      * Constructor
  103.      */
  104.     public function __construct()
  105.     {
  106.         $this->customFieldValues = new \Doctrine\Common\Collections\ArrayCollection();
  107.         $this->ticketValues = new \Doctrine\Common\Collections\ArrayCollection();
  108.         $this->customFieldsDependency = new \Doctrine\Common\Collections\ArrayCollection();
  109.     } 
  110.     /**
  111.      * Get id
  112.      *
  113.      * @return integer 
  114.      */
  115.     public function getId()
  116.     {
  117.         return $this->id;
  118.     }
  119.     /**
  120.      * Set name
  121.      *
  122.      * @param string $name
  123.      * @return CustomFields
  124.      */
  125.     public function setName($name)
  126.     {
  127.         $this->name $name;
  128.         return $this;
  129.     }
  130.     /**
  131.      * Get name
  132.      *
  133.      * @return string 
  134.      */
  135.     public function getName()
  136.     {
  137.         return $this->name;
  138.     }
  139.     /**
  140.      * Set fieldType
  141.      *
  142.      * @param string $fieldType
  143.      * @return CustomFields
  144.      */
  145.     public function setFieldType($fieldType)
  146.     {
  147.         $this->fieldType $fieldType;
  148.         return $this;
  149.     }
  150.     /**
  151.      * Get fieldType
  152.      *
  153.      * @return string 
  154.      */
  155.     public function getFieldType()
  156.     {
  157.         return $this->fieldType;
  158.     }
  159.     /**
  160.      * Set value
  161.      *
  162.      * @param string $value
  163.      * @return CustomFields
  164.      */
  165.     public function setValue($value)
  166.     {
  167.         $this->value $value;
  168.         return $this;
  169.     }
  170.     /**
  171.      * Get value
  172.      *
  173.      * @return string 
  174.      */
  175.     public function getValue()
  176.     {
  177.         return $this->value;
  178.     }
  179.     /**
  180.      * Set placeholder
  181.      *
  182.      * @param string $placeholder
  183.      * @return CustomFields
  184.      */
  185.     public function setPlaceholder($placeholder)
  186.     {
  187.         $this->placeholder $placeholder;
  188.         return $this;
  189.     }
  190.     /**
  191.      * Get placeholder
  192.      *
  193.      * @return string 
  194.      */
  195.     public function getPlaceholder()
  196.     {
  197.         return $this->placeholder;
  198.     }
  199.     /**
  200.      * Set required
  201.      *
  202.      * @param boolean $required
  203.      * @return CustomFields
  204.      */
  205.     public function setRequired($required)
  206.     {
  207.         $this->required $required;
  208.         return $this;
  209.     }
  210.     /**
  211.      * Get required
  212.      *
  213.      * @return boolean 
  214.      */
  215.     public function getRequired()
  216.     {
  217.         return $this->required;
  218.     }
  219.     /**
  220.      * Set status
  221.      *
  222.      * @param boolean $status
  223.      * @return CustomFields
  224.      */
  225.     public function setStatus($status)
  226.     {
  227.         $this->status $status;
  228.         return $this;
  229.     }
  230.     /**
  231.      * Get status
  232.      *
  233.      * @return boolean 
  234.      */
  235.     public function getStatus()
  236.     {
  237.         return $this->status;
  238.     }
  239.     /**
  240.      * Set sortOrder
  241.      *
  242.      * @param integer $sortOrder
  243.      * @return CustomFields
  244.      */
  245.     public function setSortOrder($sortOrder)
  246.     {
  247.         $this->sortOrder $sortOrder;
  248.         return $this;
  249.     }
  250.     /**
  251.      * Get sortOrder
  252.      *
  253.      * @return integer 
  254.      */
  255.     public function getSortOrder()
  256.     {
  257.         return $this->sortOrder;
  258.     }
  259.     /**
  260.      * Set dateAdded
  261.      *
  262.      * @param \DateTime $dateAdded
  263.      * @return CustomFields
  264.      */
  265.     public function setDateAdded($dateAdded)
  266.     {
  267.         $this->dateAdded $dateAdded;
  268.         return $this;
  269.     }
  270.     /**
  271.      * Get dateAdded
  272.      *
  273.      * @return \DateTime 
  274.      */
  275.     public function getDateAdded()
  276.     {
  277.         return $this->dateAdded;
  278.     }
  279.     /**
  280.      * Set dateUpdated
  281.      *
  282.      * @param \DateTime $dateUpdated
  283.      * @return CustomFields
  284.      */
  285.     public function setDateUpdated($dateUpdated)
  286.     {
  287.         $this->dateUpdated $dateUpdated;
  288.         return $this;
  289.     }
  290.     /**
  291.      * Get dateUpdated
  292.      *
  293.      * @return \DateTime 
  294.      */
  295.     public function getDateUpdated()
  296.     {
  297.         return $this->dateUpdated;
  298.     }
  299.     /**
  300.      * Add customFieldValues
  301.      *
  302.      * @param \UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\CustomFieldsValues $customFieldValues
  303.      * @return CustomFields
  304.      */
  305.     public function addCustomFieldValue(CustomFieldsValues $customFieldValues)
  306.     {
  307.         $this->customFieldValues[] = $customFieldValues;
  308.         return $this;
  309.     }
  310.     /**
  311.      * Remove customFieldValues
  312.      *
  313.      * @param \UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\CustomFieldsValues $customFieldValues
  314.      */
  315.     public function removeCustomFieldValue(CustomFieldsValues $customFieldValues)
  316.     {
  317.         $this->customFieldValues->removeElement($customFieldValues);
  318.     }
  319.     public function sortCustomFieldValues($a$b)
  320.     {
  321.         return strcmp($a->getSortOrder(), $b->getSortOrder());
  322.     }
  323.     /**
  324.      * Get customFieldValues
  325.      *
  326.      * @return \Doctrine\Common\Collections\Collection 
  327.      */
  328.     public function getCustomFieldValues($force false)
  329.     {   
  330.         if(!$this->customFieldValuesSorted || $force){
  331.             $this->customFieldValuesSorted $this->customFieldValues->toArray();
  332.             usort($this->customFieldValuesSorted , array($this"sortCustomFieldValues"));
  333.         }
  334.         
  335.         return $this->customFieldValuesSorted;
  336.     }
  337.     /**
  338.      * Add ticketValues
  339.      *
  340.      * @param \UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\TicketCustomFieldsValues $ticketValues
  341.      * @return CustomFields
  342.      */
  343.     public function addTicketValue(TicketCustomFieldsValues $ticketValues)
  344.     {
  345.         $this->ticketValues[] = $ticketValues;
  346.         return $this;
  347.     }
  348.     /**
  349.      * Remove ticketValues
  350.      *
  351.      * @param \UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\TicketCustomFieldsValues $ticketValues
  352.      */
  353.     public function removeTicketValue(TicketCustomFieldsValues $ticketValues)
  354.     {
  355.         $this->ticketValues->removeElement($ticketValues);
  356.     }
  357.     /**
  358.      * Get ticketValues
  359.      *
  360.      * @return \Doctrine\Common\Collections\Collection 
  361.      */
  362.     public function getTicketValues()
  363.     {
  364.         return $this->ticketValues;
  365.     }
  366.     /**
  367.      * Add customFieldsDependency
  368.      *
  369.      * @param \Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketType $customFieldsDependency
  370.      * @return CustomFields
  371.      */
  372.     public function addCustomFieldsDependency(\Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketType $customFieldsDependency)
  373.     {
  374.         $this->customFieldsDependency[] = $customFieldsDependency;
  375.         return $this;
  376.     }
  377.     /**
  378.      * Remove customFieldsDependency
  379.      *
  380.      * @param \Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketType $customFieldsDependency
  381.      */
  382.     public function removeCustomFieldsDependency(\Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketType $customFieldsDependency)
  383.     {
  384.         $this->customFieldsDependency->removeElement($customFieldsDependency);
  385.     }
  386.     /**
  387.      * Get customFieldsDependency
  388.      *
  389.      * @return \Doctrine\Common\Collections\Collection 
  390.      */
  391.     public function getCustomFieldsDependency()
  392.     {
  393.         return $this->customFieldsDependency;
  394.     }
  395.     /**
  396.      * @ORM\PrePersist
  397.      */
  398.     public function setCreatedAtValue()
  399.     {
  400.         $this->dateAdded = new \DateTime();
  401.         $this->dateUpdated = new \DateTime();
  402.     }
  403.     /**
  404.      * @ORM\PreUpdate
  405.      */
  406.     public function setUpdatedAtValue()
  407.     {
  408.         $this->dateUpdated = new \DateTime();
  409.     }
  410.     /**
  411.      * @var string
  412.      * @ORM\Column(type="string", length=255)
  413.      * @Assert\NotBlank(message="Please select a Agent Type")
  414.      */
  415.     private $agentType;
  416.     /**
  417.      * Set agentType
  418.      *
  419.      * @param string $agentType
  420.      * @return CustomFields
  421.      */
  422.     public function setAgentType($agentType)
  423.     {
  424.         $this->agentType $agentType;
  425.         return $this;
  426.     }
  427.     /**
  428.      * Get agentType
  429.      *
  430.      * @return string 
  431.      */
  432.     public function getAgentType()
  433.     {
  434.         return $this->agentType;
  435.     }
  436.     /**
  437.      * @var array
  438.      * @ORM\Column(type="json_array", nullable=true)
  439.      */
  440.     private $validation;
  441.     /**
  442.      * Set validation
  443.      *
  444.      * @param array $validation
  445.      * @return CustomFields
  446.      */
  447.     public function setValidation($validation)
  448.     {
  449.         $this->validation $validation;
  450.         return $this;
  451.     }
  452.     /**
  453.      * Get validation
  454.      *
  455.      * @return array 
  456.      */
  457.     public function getValidation()
  458.     {
  459.         return $this->validation;
  460.     }
  461.     /**
  462.      * @var boolean
  463.      * @ORM\Column(type="boolean", nullable=true, options={"default":false})
  464.      */
  465.     private $encryption;
  466.     /**
  467.      * Set encryption
  468.      *
  469.      * @param boolean $encryption
  470.      * @return CustomFields
  471.      */
  472.     public function setEncryption($encryption)
  473.     {
  474.         $this->encryption $encryption;
  475.         return $this;
  476.     }
  477.     /**
  478.      * Get encryption
  479.      *
  480.      * @return boolean 
  481.      */
  482.     public function getEncryption()
  483.     {
  484.         return $this->encryption;
  485.     }
  486. }