Advertisement
Guest User

xq sale creatAt JMSSerializer¿

a guest
Jul 10th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.59 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Nvia\CommonBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation\Exclude;
  7. use JMS\Serializer\Annotation\ExclusionPolicy;
  8. use JMS\Serializer\Annotation\Expose;
  9.  
  10. /**
  11.  * Country
  12.  *
  13.  * @ORM\Table(name="country")
  14.  * @ORM\Entity(repositoryClass="Nvia\CommonBundle\Entity\Repository\CountryRepository")
  15.  * @ExclusionPolicy("all")
  16.  */
  17. class Country
  18. {
  19.     /**
  20.      * @var string
  21.      *
  22.      * @ORM\Column(name="id", type="string", length=3)
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="NONE")
  25.      * @Expose
  26.      */
  27.     private $id;
  28.  
  29.     /**
  30.      * @var string
  31.      *
  32.      * @ORM\Column(name="name", type="string", length=45, nullable=false)
  33.      * @Expose
  34.      */
  35.     private $name;
  36.  
  37.     /**
  38.      * @var \Nvia\CommonBundle\Entity\Currency
  39.      *
  40.      * @ORM\ManyToOne(targetEntity="Nvia\CommonBundle\Entity\Currency")
  41.      * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
  42.      */
  43.     private $currency;
  44.  
  45.     /**
  46.      * @var \Nvia\CommonBundle\Entity\Language
  47.      *
  48.      * @ORM\ManyToOne(targetEntity="Nvia\CommonBundle\Entity\Language")
  49.      * @ORM\JoinColumn(name="language_id", referencedColumnName="id", nullable=false)
  50.      */
  51.     private $language;
  52.  
  53.     /**
  54.      * @var \DateTime
  55.      *
  56.      * @ORM\Column(name="created_at", type="datetime", nullable=false)
  57.      * @Exclude
  58.      */
  59.     private $createdAt;
  60.  
  61.  
  62.     function __construct($id)
  63.     {
  64.         $this->createdAt = new \DateTime('now');
  65.         $this->id = $id;
  66.     }
  67.  
  68.     public  function __toString()
  69.     {
  70.         return $this->name;
  71.     }
  72.  
  73.     /**
  74.      * Set name
  75.      *
  76.      * @param string $name
  77.      * @return Country
  78.      */
  79.     public function setName($name)
  80.     {
  81.         $this->name = $name;
  82.  
  83.         return $this;
  84.     }
  85.  
  86.     /**
  87.      * Get name
  88.      *
  89.      * @return string
  90.      */
  91.     public function getName()
  92.     {
  93.         return $this->name;
  94.     }
  95.  
  96.     /**
  97.      * Get id
  98.      *
  99.      * @return string
  100.      */
  101.     public function getId()
  102.     {
  103.         return $this->id;
  104.     }
  105.  
  106.     /**
  107.      * Set currency
  108.      *
  109.      * @param \Nvia\CommonBundle\Entity\Currency $currency
  110.      * @return Country
  111.      */
  112.     public function setCurrency(\Nvia\CommonBundle\Entity\Currency $currency = null)
  113.     {
  114.         $this->currency = $currency;
  115.  
  116.         return $this;
  117.     }
  118.  
  119.     /**
  120.      * Get currency
  121.      *
  122.      * @return \Nvia\CommonBundle\Entity\Currency
  123.      */
  124.     public function getCurrency()
  125.     {
  126.         return $this->currency;
  127.     }
  128.  
  129.     /**
  130.      * Set language
  131.      *
  132.      * @param \Nvia\CommonBundle\Entity\Language $language
  133.      * @return Country
  134.      */
  135.     public function setLanguage(\Nvia\CommonBundle\Entity\Language $language = null)
  136.     {
  137.         $this->language = $language;
  138.  
  139.         return $this;
  140.     }
  141.  
  142.     /**
  143.      * Get language
  144.      *
  145.      * @return \Nvia\CommonBundle\Entity\Language
  146.      */
  147.     public function getLanguage()
  148.     {
  149.         return $this->language;
  150.     }
  151.  
  152.     /**
  153.      * Set createdAt
  154.      *
  155.      * @param \DateTime $createdAt
  156.      * @return Country
  157.      */
  158.     private function setCreatedAt($createdAt)
  159.     {
  160.         $this->createdAt = $createdAt;
  161.  
  162.         return $this;
  163.     }
  164.  
  165.     /**
  166.      * Get createdAt
  167.      *
  168.      * @return \DateTime
  169.      */
  170.     public function getCreatedAt()
  171.     {
  172.         return $this->createdAt;
  173.     }
  174.  
  175.     /**
  176.      * Set id
  177.      *
  178.      * @param string $id
  179.      * @return Country
  180.      */
  181.     private function setId($id)
  182.     {
  183.         $this->id = $id;
  184.  
  185.         return $this;
  186.     }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement