modules/CSI/Testimonials/src/Model/Testimonial.php line 27

Open in your IDE?
  1. <?php
  2. // vim: set ts=4 sw=4 sts=4 et:
  3. /**
  4.  * Testimonials Module
  5.  *
  6.  * @category  X-Cart_5_5_Module
  7.  * @package   Testimonials
  8.  * @author    CFL Systems, Inc. <support@cflsystems.com>
  9.  * @copyright 2022 CFL Systems, Inc. All rights reserved.
  10.  * @license   License Agreement - https://www.cflsystems.com/software-license-agreement.html
  11.  * @link      https://www.cflsystems.com/testimonials-for-x-cart-5.html
  12.  */
  13. namespace CSI\Testimonials\Model;
  14. use XLite\Model\Profile;
  15. use XLite\Core\Converter;
  16. use Doctrine\ORM\Mapping as ORM;
  17. /**
  18.  * The "testimonials" model class
  19.  *
  20.  * @ORM\Entity
  21.  * @ORM\Table  (name="csi_testimonials")
  22.  */
  23. class Testimonial extends \XLite\Model\AEntity
  24. {
  25.     /**
  26.      * Entry unique ID
  27.      *
  28.      * @var integer
  29.      *
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue (strategy="AUTO")
  32.      * @ORM\Column         (type="integer")
  33.      */
  34.     protected $id;
  35.     /**
  36.      * Customer name
  37.      *
  38.      * @var string
  39.      *
  40.      * @ORM\Column (type="string", length=32)
  41.      */
  42.     protected $name;
  43.     /**
  44.      * Customer email
  45.      *
  46.      * @var string
  47.      *
  48.      * @ORM\Column (type="string", length=128)
  49.      */
  50.     protected $email;
  51.     /**
  52.      * The profile id
  53.      *
  54.      * @var Profile
  55.      *
  56.      * @ORM\ManyToOne  (targetEntity="XLite\Model\Profile", inversedBy="testimonials")
  57.      * @ORM\JoinColumn (name="profile_id", referencedColumnName="profile_id")
  58.      */
  59.     protected $profile;
  60.     /**
  61.      * Testimonial title
  62.      *
  63.      * @var string
  64.      *
  65.      * @ORM\Column (type="string", length=255)
  66.      */
  67.     protected $title;
  68.     /**
  69.      * Customer location
  70.      *
  71.      * @var string
  72.      *
  73.      * @ORM\Column (type="string", length=255)
  74.      */
  75.     protected $location;
  76.     /**
  77.      * Testimonial date
  78.      *
  79.      * @var integer
  80.      *
  81.      * @ORM\Column (type="integer")
  82.      */
  83.     protected $date 0;
  84.     /**
  85.      * Testimonial text
  86.      *
  87.      * @var text
  88.      *
  89.      * @ORM\Column (type="text")
  90.      */
  91.     protected $testimonial;
  92.     /**
  93.      * Remote ip2long
  94.      *
  95.      * @var integer
  96.      *
  97.      * @ORM\Column (type="bigint")
  98.      */
  99.     protected $ip 0;
  100.     /**
  101.      * Status
  102.      * P - Pending
  103.      * D - Declined
  104.      * A - Approved
  105.      *
  106.      * @var string
  107.      *
  108.      * @ORM\Column (type="string", length=1, options={ "default": "P" })
  109.      */
  110.     protected $status 'P';
  111.     /**
  112.      * Is testimonial visible or not
  113.      *
  114.      * @var boolean
  115.      *
  116.      * @ORM\Column (type="boolean")
  117.      */
  118.     protected $enabled true;
  119.     /**
  120.      * Prepare date
  121.      *
  122.      * @return void
  123.      *
  124.      * @ORM\PrePersist
  125.      */
  126.     public function prepareBeforeCreate()
  127.     {
  128.         if (!$this->getDate()) {
  129.             $this->setDate(Converter::time());
  130.         }
  131.     }
  132.     /**
  133.      * Map data to entity columns
  134.      *
  135.      * @param array $data Array of data
  136.      *
  137.      * @return self
  138.      */
  139.     public function map(array $data)
  140.     {
  141.         $data array_filter($data, function ($name) {
  142.             return $this->isPropertyExists($name);
  143.         }, ARRAY_FILTER_USE_KEY);
  144.         return parent::map($data);
  145.     }
  146.     /**
  147.      * Get id
  148.      *
  149.      * @return integer
  150.      */
  151.     public function getId()
  152.     {
  153.         return $this->id;
  154.     }
  155.     /**
  156.      * Set name
  157.      *
  158.      * @param string $name
  159.      *
  160.      * @return self
  161.      */
  162.     public function setName(string $name)
  163.     {
  164.         $this->name $name;
  165.         return $this;
  166.     }
  167.     /**
  168.      * Get name
  169.      *
  170.      * @return string
  171.      */
  172.     public function getName()
  173.     {
  174.         return $this->name;
  175.     }
  176.     /**
  177.      * Set email
  178.      *
  179.      * @param string $email
  180.      *
  181.      * @return self
  182.      */
  183.     public function setEmail(string $email)
  184.     {
  185.         $this->email $email;
  186.         return $this;
  187.     }
  188.     /**
  189.      * Get email
  190.      *
  191.      * @return string
  192.      */
  193.     public function getEmail()
  194.     {
  195.         return $this->email;
  196.     }
  197.     /**
  198.      * Set title
  199.      *
  200.      * @param string $title
  201.      *
  202.      * @return self
  203.      */
  204.     public function setTitle(string $title)
  205.     {
  206.         $this->title $title;
  207.         return $this;
  208.     }
  209.     /**
  210.      * Get title
  211.      *
  212.      * @return string
  213.      */
  214.     public function getTitle()
  215.     {
  216.         return $this->title;
  217.     }
  218.     /**
  219.      * Set location
  220.      *
  221.      * @param string $location
  222.      *
  223.      * @return self
  224.      */
  225.     public function setLocation(string $location)
  226.     {
  227.         $this->location $location;
  228.         return $this;
  229.     }
  230.     /**
  231.      * Get location
  232.      *
  233.      * @return string
  234.      */
  235.     public function getLocation()
  236.     {
  237.         return $this->location;
  238.     }
  239.     /**
  240.      * Set date
  241.      *
  242.      * @param integer $date
  243.      *
  244.      * @return self
  245.      */
  246.     public function setDate(int $date)
  247.     {
  248.         $this->date = (int) $date;
  249.         return $this;
  250.     }
  251.     /**
  252.      * Get date
  253.      *
  254.      * @return integer
  255.      */
  256.     public function getDate()
  257.     {
  258.         return $this->date;
  259.     }
  260.     /**
  261.      * Set testimonial
  262.      *
  263.      * @param text $testimonial
  264.      *
  265.      * @return self
  266.      */
  267.     public function setTestimonial(string $testimonial)
  268.     {
  269.         $this->testimonial $testimonial;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Get testimonial
  274.      *
  275.      * @return text
  276.      */
  277.     public function getTestimonial()
  278.     {
  279.         return $this->testimonial;
  280.     }
  281.     /**
  282.      * Set ip
  283.      *
  284.      * @param bigint $ip
  285.      *
  286.      * @return self
  287.      */
  288.     public function setIp($ip)
  289.     {
  290.         $this->ip $ip;
  291.         return $this;
  292.     }
  293.     /**
  294.      * Get ip
  295.      *
  296.      * @return bigint
  297.      */
  298.     public function getIp()
  299.     {
  300.         return $this->ip;
  301.     }
  302.     /**
  303.      * Set status
  304.      *
  305.      * @param string $status
  306.      *
  307.      * @return self
  308.      */
  309.     public function setStatus(string $status)
  310.     {
  311.         $this->status $status;
  312.         return $this;
  313.     }
  314.     /**
  315.      * Get status
  316.      *
  317.      * @return string
  318.      */
  319.     public function getStatus()
  320.     {
  321.         return $this->status;
  322.     }
  323.     /**
  324.      * Set enabled
  325.      *
  326.      * @param boolean $enabled
  327.      *
  328.      * @return self
  329.      */
  330.     public function setEnabled(bool $enabled)
  331.     {
  332.         $this->enabled = (bool) $enabled;
  333.         return $this;
  334.     }
  335.     /**
  336.      * Get enabled
  337.      *
  338.      * @return boolean
  339.      */
  340.     public function getEnabled()
  341.     {
  342.         return $this->enabled;
  343.     }
  344.     /**
  345.      * Set profile
  346.      *
  347.      * @param Profile $profile
  348.      *
  349.      * @return self
  350.      */
  351.     public function setProfile(Profile $profile null)
  352.     {
  353.         $this->profile $profile;
  354.         return $this;
  355.     }
  356.     /**
  357.      * Get profile
  358.      *
  359.      * @return Profile
  360.      */
  361.     public function getProfile()
  362.     {
  363.         return $this->profile;
  364.     }
  365. }