app/Plugin/NZCustomPlugin/Entity/CustomForm.php line 13

Open in your IDE?
  1. <?php
  2. namespace Plugin\NZCustomPlugin\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Eccube\Entity\Layout;
  6. /**
  7.  * @ORM\Table(name="plg_nzcustomplugin_form")
  8.  * @ORM\Entity(repositoryClass="Plugin\NZCustomPlugin\Repository\CustomFormRepository")
  9.  */
  10. class CustomForm
  11. {
  12.     /**
  13.      * @var int
  14.      * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="IDENTITY")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @var string
  21.      * @ORM\Column(name="name", type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @var string
  26.      * @ORM\Column(name="form_key", type="string", length=255, unique=true)
  27.      */
  28.     private $form_key;
  29.     /**
  30.      * @var string|null
  31.      * @ORM\Column(name="description", type="text", nullable=true)
  32.      */
  33.     private $description;
  34.     /**
  35.      * @var bool
  36.      * @ORM\Column(name="is_active", type="boolean", options={"default":true})
  37.      */
  38.     private $is_active true;
  39.     /**
  40.      * @var \DateTime
  41.      * @ORM\Column(name="create_date", type="datetime")
  42.      */
  43.     private $create_date;
  44.     /**
  45.      * @var \DateTime
  46.      * @ORM\Column(name="update_date", type="datetime")
  47.      */
  48.     private $update_date;
  49.     /**
  50.      * @var bool
  51.      * @ORM\Column(name="send_customer_mail", type="boolean", options={"default":true})
  52.      */
  53.     private $send_customer_mail true;
  54.     /**
  55.      * @var bool
  56.      * @ORM\Column(name="send_admin_mail", type="boolean", options={"default":true})
  57.      */
  58.     private $send_admin_mail true;
  59.     /**
  60.      * @var string|null
  61.      * @ORM\Column(name="admin_mail_address", type="string", length=255, nullable=true)
  62.      */
  63.     private $admin_mail_address;
  64.     /**
  65.      * @var string|null
  66.      * @ORM\Column(name="mail_subject", type="string", length=255, nullable=true)
  67.      */
  68.     private $mail_subject;
  69.     /**
  70.      * @var string|null
  71.      * @ORM\Column(name="mail_template", type="text", nullable=true)
  72.      */
  73.     private $mail_template;
  74.     /**
  75.      * @var string|null
  76.      * @ORM\Column(name="complete_message", type="text", nullable=true)
  77.      */
  78.     private $complete_message;
  79.     /**
  80.      * @var \DateTime|null
  81.      * @ORM\Column(name="publish_start_date", type="datetime", nullable=true)
  82.      */
  83.     private $publish_start_date;
  84.     /**
  85.      * @var \DateTime|null
  86.      * @ORM\Column(name="publish_end_date", type="datetime", nullable=true)
  87.      */
  88.     private $publish_end_date;
  89.     /**
  90.      * @var bool
  91.      * @ORM\Column(name="require_login", type="boolean", options={"default":false})
  92.      */
  93.     private $require_login false;
  94.     /**
  95.      * @var Layout|null
  96.      * @ORM\ManyToOne(targetEntity="Eccube\Entity\Layout")
  97.      * @ORM\JoinColumn(name="layout_id", referencedColumnName="id", nullable=true)
  98.      */
  99.     private $Layout;
  100.     /**
  101.      * @var Layout|null
  102.      * @ORM\ManyToOne(targetEntity="Eccube\Entity\Layout")
  103.      * @ORM\JoinColumn(name="layout_id_mobile", referencedColumnName="id", nullable=true)
  104.      */
  105.     private $LayoutMobile;
  106.     /**
  107.      * @var ArrayCollection|FormField[]
  108.      * @ORM\OneToMany(targetEntity="Plugin\NZCustomPlugin\Entity\FormField", mappedBy="customForm", cascade={"persist", "remove"})
  109.      * @ORM\OrderBy({"sort_no" = "ASC"})
  110.      */
  111.     private $formFields;
  112.     /**
  113.      * @var ArrayCollection|FormSubmission[]
  114.      * @ORM\OneToMany(targetEntity="Plugin\NZCustomPlugin\Entity\FormSubmission", mappedBy="customForm", cascade={"remove"})
  115.      */
  116.     private $formSubmissions;
  117.     public function __construct()
  118.     {
  119.         $this->formFields = new ArrayCollection();
  120.         $this->formSubmissions = new ArrayCollection();
  121.         $this->create_date = new \DateTime();
  122.         $this->update_date = new \DateTime();
  123.     }
  124.     public function getId()
  125.     {
  126.         return $this->id;
  127.     }
  128.     public function getName()
  129.     {
  130.         return $this->name;
  131.     }
  132.     public function setName($name)
  133.     {
  134.         $this->name $name;
  135.         return $this;
  136.     }
  137.     public function getFormKey()
  138.     {
  139.         return $this->form_key;
  140.     }
  141.     public function setFormKey($form_key)
  142.     {
  143.         $this->form_key $form_key;
  144.         return $this;
  145.     }
  146.     public function getDescription()
  147.     {
  148.         return $this->description;
  149.     }
  150.     public function setDescription($description)
  151.     {
  152.         $this->description $description;
  153.         return $this;
  154.     }
  155.     public function isActive()
  156.     {
  157.         return $this->is_active;
  158.     }
  159.     public function getIsActive()
  160.     {
  161.         return $this->is_active;
  162.     }
  163.     public function setIsActive($is_active)
  164.     {
  165.         $this->is_active $is_active;
  166.         return $this;
  167.     }
  168.     public function getCreateDate()
  169.     {
  170.         return $this->create_date;
  171.     }
  172.     public function setCreateDate($create_date)
  173.     {
  174.         $this->create_date $create_date;
  175.         return $this;
  176.     }
  177.     public function getUpdateDate()
  178.     {
  179.         return $this->update_date;
  180.     }
  181.     public function setUpdateDate($update_date)
  182.     {
  183.         $this->update_date $update_date;
  184.         return $this;
  185.     }
  186.     public function isSendCustomerMail()
  187.     {
  188.         return $this->send_customer_mail;
  189.     }
  190.     public function getSendCustomerMail()
  191.     {
  192.         return $this->send_customer_mail;
  193.     }
  194.     public function setSendCustomerMail($send_customer_mail)
  195.     {
  196.         $this->send_customer_mail $send_customer_mail;
  197.         return $this;
  198.     }
  199.     public function isSendAdminMail()
  200.     {
  201.         return $this->send_admin_mail;
  202.     }
  203.     public function getSendAdminMail()
  204.     {
  205.         return $this->send_admin_mail;
  206.     }
  207.     public function setSendAdminMail($send_admin_mail)
  208.     {
  209.         $this->send_admin_mail $send_admin_mail;
  210.         return $this;
  211.     }
  212.     public function getAdminMailAddress()
  213.     {
  214.         return $this->admin_mail_address;
  215.     }
  216.     public function setAdminMailAddress($admin_mail_address)
  217.     {
  218.         $this->admin_mail_address $admin_mail_address;
  219.         return $this;
  220.     }
  221.     public function getMailSubject()
  222.     {
  223.         return $this->mail_subject;
  224.     }
  225.     public function setMailSubject($mail_subject)
  226.     {
  227.         $this->mail_subject $mail_subject;
  228.         return $this;
  229.     }
  230.     public function getMailTemplate()
  231.     {
  232.         return $this->mail_template;
  233.     }
  234.     public function setMailTemplate($mail_template)
  235.     {
  236.         $this->mail_template $mail_template;
  237.         return $this;
  238.     }
  239.     public function getCompleteMessage()
  240.     {
  241.         return $this->complete_message;
  242.     }
  243.     public function setCompleteMessage($complete_message)
  244.     {
  245.         $this->complete_message $complete_message;
  246.         return $this;
  247.     }
  248.     public function getPublishStartDate()
  249.     {
  250.         return $this->publish_start_date;
  251.     }
  252.     public function setPublishStartDate($publish_start_date)
  253.     {
  254.         $this->publish_start_date $publish_start_date;
  255.         return $this;
  256.     }
  257.     public function getPublishEndDate()
  258.     {
  259.         return $this->publish_end_date;
  260.     }
  261.     public function setPublishEndDate($publish_end_date)
  262.     {
  263.         $this->publish_end_date $publish_end_date;
  264.         return $this;
  265.     }
  266.     public function isRequireLogin()
  267.     {
  268.         return $this->require_login;
  269.     }
  270.     public function getRequireLogin()
  271.     {
  272.         return $this->require_login;
  273.     }
  274.     public function setRequireLogin($require_login)
  275.     {
  276.         $this->require_login $require_login;
  277.         return $this;
  278.     }
  279.     /**
  280.      * @return Layout|null
  281.      */
  282.     public function getLayout()
  283.     {
  284.         return $this->Layout;
  285.     }
  286.     /**
  287.      * @param Layout|null $Layout
  288.      * @return $this
  289.      */
  290.     public function setLayout(Layout $Layout null)
  291.     {
  292.         $this->Layout $Layout;
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Layout|null
  297.      */
  298.     public function getLayoutMobile()
  299.     {
  300.         return $this->LayoutMobile;
  301.     }
  302.     /**
  303.      * @param Layout|null $LayoutMobile
  304.      * @return $this
  305.      */
  306.     public function setLayoutMobile(Layout $LayoutMobile null)
  307.     {
  308.         $this->LayoutMobile $LayoutMobile;
  309.         return $this;
  310.     }
  311.     public function isPublished()
  312.     {
  313.         if (!$this->is_active) {
  314.             return false;
  315.         }
  316.         $now = new \DateTime();
  317.         
  318.         if ($this->publish_start_date && $now $this->publish_start_date) {
  319.             return false;
  320.         }
  321.         
  322.         if ($this->publish_end_date && $now $this->publish_end_date) {
  323.             return false;
  324.         }
  325.         
  326.         return true;
  327.     }
  328.     public function getFormFields()
  329.     {
  330.         return $this->formFields;
  331.     }
  332.     public function addFormField(FormField $formField)
  333.     {
  334.         if (!$this->formFields->contains($formField)) {
  335.             $this->formFields->add($formField);
  336.             $formField->setCustomForm($this);
  337.         }
  338.         return $this;
  339.     }
  340.     public function removeFormField(FormField $formField)
  341.     {
  342.         if ($this->formFields->contains($formField)) {
  343.             $this->formFields->removeElement($formField);
  344.         }
  345.         return $this;
  346.     }
  347.     public function getFormSubmissions()
  348.     {
  349.         return $this->formSubmissions;
  350.     }
  351. }