Advertisement
Guest User

QuoteEntity

a guest
Jul 24th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.61 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Application\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. use Zend\InputFilter\Factory as InputFactory;
  8. use Zend\InputFilter\InputFilter;
  9. use Zend\InputFilter\InputFilterAwareInterface;
  10. use Zend\InputFilter\InputFilterInterface;
  11.  
  12. use \Application\Entity\AbstractEntity;
  13.  
  14. /**
  15.  * @ORM\Entity
  16.  * @ORM\Table(name="quotes")
  17.  */
  18. class Quote extends AbstractEntity implements InputFilterAwareInterface
  19. {
  20.    
  21.     /**
  22.      * @ORM\Column(name="id", type="integer", nullable=false)
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     protected $id;
  27.    
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity="Service")
  30.      */
  31.     protected $service;
  32.    
  33.     /**
  34.      * @ORM\Column(name="name", nullable=false)
  35.      */
  36.     protected $name;
  37.    
  38.     /**
  39.      * @ORM\Column(name="email", nullable=false)
  40.      */
  41.     protected $email;
  42.    
  43.     /**
  44.      * @ORM\Column(name="phone_number", nullable=false)
  45.      */
  46.     protected $phone_number;
  47.    
  48.     /**
  49.      * @ORM\Column(name="budget", type="decimal", precision=2, nullable=true)
  50.      */
  51.     protected $budget;
  52.    
  53.     /**
  54.      * @ORM\Column(name="content", type="text", nullable=false)
  55.      */
  56.     protected $content;
  57.    
  58.     /**
  59.      * @ORM\Column(name="date_posted", type="datetime")
  60.      */
  61.     protected $date_posted;
  62.    
  63.     public function setInputFilter(InputFilterInterface $inputFilter)
  64.     {
  65.         $this->inputFilter = $inputFilter;
  66.     }
  67.    
  68.     public function getInputFilter()
  69.     {
  70.         if (!$this->inputFilter) {
  71.             $inputFilter = new InputFilter();
  72.             $factory     = new InputFactory();
  73.  
  74.             $inputFilter->add($factory->createInput(array(
  75.                 'name'     => 'name',
  76.                 'required' => true,
  77.                 'filters'  => array(
  78.                     array('name' => 'StripTags'),
  79.                     array('name' => 'StringTrim'),
  80.                 ),
  81.             )));
  82.  
  83.             $inputFilter->add($factory->createInput(array(
  84.                 'name'     => 'email',
  85.                 'required' => true,
  86.                 'filters'  => array(
  87.                     array('name' => 'StripTags'),
  88.                     array('name' => 'StringTrim'),
  89.                 ),
  90.                 'validators' => array(
  91.                     array('name' => 'EmailAddress'),
  92.                 ),
  93.             )));
  94.            
  95.             $inputFilter->add($factory->createInput(array(
  96.                 'name'     => 'phone_number',
  97.                 'required' => true,
  98.                 'filters'  => array(
  99.                     array('name' => 'StripTags'),
  100.                     array('name' => 'StringTrim'),
  101.                 ),
  102.                 'validators' => array(
  103.                     array(
  104.                         'name' => 'PhoneNumber',
  105.                         'options' => array(
  106.                             'country' => 'CA',
  107.                             'allowPossible' => true,
  108.                         ),
  109.                     ),
  110.                 ),
  111.             )));
  112.            
  113.             $inputFilter->add($factory->createInput(array(
  114.                 'name'     => 'content',
  115.                 'required' => true,
  116.                 'filters'  => array(
  117.                     array('name' => 'StripTags'),
  118.                     array('name' => 'StringTrim'),
  119.                 ),
  120.                 'validators' => array(
  121.                     array(
  122.                         'name' => 'StringLength',
  123.                         'options' => array(
  124.                             'encoding' => 'UTF-8',
  125.                             'min'      => 20,
  126.                             'max'      => 500,
  127.                         ),
  128.                     ),
  129.                 ),
  130.             )));
  131.  
  132.             $this->inputFilter = $inputFilter;
  133.         }
  134.  
  135.         return $this->inputFilter;
  136.     }
  137.    
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement