vendor/score/cms/src/Entity/Form/Webform.php line 17

Open in your IDE?
  1. <?php
  2. namespace Score\CmsBundle\Entity\Form;
  3. use App\Repository\Score\CmsBundle\Entity\Form\WebformRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Score\BaseBundle\Entity\BaseEntity;
  8. use Score\CmsBundle\Entity\User;
  9. /**
  10.  * @ORM\Table(name="cms_form")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @ORM\Entity()
  13.  */
  14. class Webform extends BaseEntity
  15. {
  16.     /**
  17.      * @ORM\Column(type="integer", name="creator_id")
  18.      */
  19.     private $creatorId;
  20.     /**
  21.      * One form has many fields. This is the inverse side.
  22.      * @ORM\OneToMany(targetEntity="WebformField", mappedBy="form")
  23.      */
  24.     private $fields;
  25.     /**
  26.      * One form has many values. This is the inverse side.
  27.      * @ORM\OneToMany(targetEntity="WebformValue", mappedBy="form")
  28.      */
  29.     private $values;
  30.     /**
  31.      * @ORM\Column(type="string", name="identifier", length=1000)
  32.      */
  33.     private $identifier;
  34.     /**
  35.      * @ORM\Column(type="string", name="f_name", length=1000)
  36.      */
  37.     private $name;
  38.     /**
  39.      * @ORM\Column(type="string", name="f_description", length=5000, nullable=true)
  40.      */
  41.     private $description;
  42.     /**
  43.      * @ORM\Column(type="string", name="success_message", length=1000, nullable=true)
  44.      */
  45.     private $successMessage;
  46.     /**
  47.      * @ORM\Column(type="boolean", name="is_active")
  48.      */
  49.     private $isActive true;
  50.     /**
  51.      * @ORM\Column(type="boolean", name="send_mail", nullable=true)
  52.      */
  53.     private $sendMail;
  54.     /**
  55.      * @ORM\Column(type="string", name="mail_list", length=1000, nullable=true)
  56.      */
  57.     private $mailList;
  58.     /**
  59.      * @ORM\Column(type="string", name="f_params", length=1000, nullable=true)
  60.      */
  61.     private $params;
  62.     public function __construct()
  63.     {
  64.         $this->fields = new ArrayCollection();
  65.         $this->values = new ArrayCollection();
  66.     }
  67.     /**
  68.      * @return Collection
  69.      */
  70.     public function getFields(): Collection
  71.     {
  72.         return $this->fields;
  73.     }
  74.     public function addField(WebformField $field): self
  75.     {
  76.         if (!$this->fields->contains($field)) {
  77.             $this->fields[] = $field;
  78.             $field->setForm($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeField(WebformField $field): self
  83.     {
  84.         if ($this->fields->removeElement($field)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($field->getForm() === $this) {
  87.                 $field->setForm(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection
  94.      */
  95.     public function getValues(): Collection
  96.     {
  97.         return $this->values;
  98.     }
  99.     public function addValue(WebformValue $value): self
  100.     {
  101.         if (!$this->values->contains($value)) {
  102.             $this->values[] = $value;
  103.             $value->setForm($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeValue(WebformValue $value): self
  108.     {
  109.         if ($this->values->removeElement($value)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($value->getForm() === $this) {
  112.                 $value->setForm(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     public function getCreatorId(): ?int
  118.     {
  119.         return $this->creatorId;
  120.     }
  121.     public function setCreatorId(int $creatorId): self
  122.     {
  123.         $this->creatorId $creatorId;
  124.         return $this;
  125.     }
  126.     public function getIdentifier(): ?string
  127.     {
  128.         return $this->identifier;
  129.     }
  130.     public function setIdentifier(string $identifier): self
  131.     {
  132.         $this->identifier $identifier;
  133.         return $this;
  134.     }
  135.     public function getName(): ?string
  136.     {
  137.         return $this->name;
  138.     }
  139.     public function setName(string $name): self
  140.     {
  141.         $this->name $name;
  142.         return $this;
  143.     }
  144.     public function getDescription(): ?string
  145.     {
  146.         return $this->description;
  147.     }
  148.     public function setDescription(?string $description): self
  149.     {
  150.         $this->description $description;
  151.         return $this;
  152.     }
  153.     public function getSuccessMessage(): ?string
  154.     {
  155.         return $this->successMessage;
  156.     }
  157.     public function setSuccessMessage(?string $successMessage): self
  158.     {
  159.         $this->successMessage $successMessage;
  160.         return $this;
  161.     }
  162.     public function getIsActive(): ?bool
  163.     {
  164.         return $this->isActive;
  165.     }
  166.     public function setIsActive(bool $isActive): self
  167.     {
  168.         $this->isActive $isActive;
  169.         return $this;
  170.     }
  171.     public function getSendMail(): ?bool
  172.     {
  173.         return $this->sendMail;
  174.     }
  175.     public function setSendMail(bool $sendMail): self
  176.     {
  177.         $this->sendMail $sendMail;
  178.         return $this;
  179.     }
  180.     public function getMailList(): ?string
  181.     {
  182.         return $this->mailList;
  183.     }
  184.     public function setMailList(?string $mailList): self
  185.     {
  186.         $this->mailList $mailList;
  187.         return $this;
  188.     }
  189.     public function getMailListArr(): ?array
  190.     {
  191.         return json_decode($this->mailListtrue);
  192.     }
  193.     public function setMailListArr(?array $mailList): self
  194.     {
  195.         $this->mailList json_encode($mailList);
  196.         return $this;
  197.     }
  198.     public function getParams(): ?string
  199.     {
  200.         return $this->params;
  201.     }
  202.     public function setParams(?string $params): self
  203.     {
  204.         $this->params $params;
  205.         return $this;
  206.     }
  207.     public function getParamsArr(): ?array
  208.     {
  209.         return json_decode($this->paramstrue);
  210.     }
  211.     public function setParamsArr(?array $params): self
  212.     {
  213.         $this->params json_encode($params);
  214.         return $this;
  215.     }
  216.     public function getFilledCount(): ?int
  217.     {
  218.         $result = [];
  219.         foreach ($this->values as $value) {
  220.             if (!in_array($value->getIdentifier(), $result)) {
  221.                 $result[] = $value->getIdentifier();
  222.             }
  223.         }
  224.         return count($result);
  225.     }
  226. }