Advertisement
Eddz

Untitled

Sep 3rd, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Fcm\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Events;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping\ManyToOne;
  9. use Doctrine\ORM\Mapping\OneToMany;
  10.  
  11. /**
  12. * @ORM\Table(name="client")
  13. * @ORM\Entity(repositoryClass="Fcm\Entity\Repository\ClientRepository")
  14. * @ORM\HasLifecycleCallbacks
  15. * @property integer $id
  16. * @property string $name
  17. * @property string $website
  18. * @property string $email
  19. * @property string $contact
  20. * @property string $phone
  21. * @property string $comment
  22. * @property date $created
  23. */
  24. class Client
  25. {
  26.  
  27. /**
  28. * @ORM\Id
  29. * @ORM\GeneratedValue(strategy="AUTO")
  30. * @ORM\Column(type="integer")
  31. */
  32. protected $id;
  33.  
  34. /** @ORM\Column(type="string", length=120, nullable=false, unique=false)
  35. *
  36. */
  37. protected $name;
  38.  
  39. /** @ORM\Column(type="string", length=120, nullable=true, unique=false) */
  40. protected $website;
  41.  
  42. /** @ORM\Column(type="string", length=120, nullable=true, unique=true) */
  43. protected $email;
  44.  
  45. /** @ORM\Column(type="string", length=120, nullable=true, unique=false) */
  46. protected $contact;
  47.  
  48. /** @ORM\Column(type="string", length=120, nullable=true, unique=false) */
  49. protected $phone;
  50.  
  51. /** @ORM\Column(type="string",length=255, nullable=true, unique=false) */
  52. protected $comment;
  53.  
  54. /** @ORM\OneToMany(targetEntity="Campaign", mappedBy="client", cascade={"remove"}) */
  55. protected $campaigns;
  56.  
  57. /** @ORM\OneToMany(targetEntity="User", mappedBy="client", cascade={"remove"}) */
  58. protected $users;
  59.  
  60. /**
  61. * @var date $created
  62. *
  63. * @ORM\Column(name="created", type="date", nullable=false)
  64. */
  65. protected $created;
  66.  
  67. /**
  68. * @var date $updated
  69. *
  70. * @ORM\Column(name="updated", type="date", nullable=false)
  71. */
  72. protected $updated;
  73.  
  74. public function __construct()
  75. {
  76. // may be useless
  77. $this->campaigns = new \Doctrine\Common\Collections\ArrayCollection();
  78. }
  79.  
  80. /**
  81. * Magic getter to expose protected properties.
  82. *
  83. * @param string $property
  84. * @return mixed
  85. */
  86. public function __get($property)
  87. {
  88. return $this->$property;
  89. }
  90.  
  91. /**
  92. * Magic setter to save protected properties.
  93. *
  94. * @param string $property
  95. * @param mixed $value
  96. */
  97. public function __set($property, $value)
  98. {
  99. $this->$property = $value;
  100. }
  101.  
  102. /**
  103. * Convert the object to an array.
  104. *
  105. * @return array
  106. */
  107. public function getArrayCopy()
  108. {
  109. return get_object_vars($this);
  110. }
  111.  
  112. /**
  113. * Populate from an array.
  114. *
  115. * @param array $data
  116. */
  117. public function populate($data = array())
  118. {
  119. //$this->id = $data['id'];
  120. $this->name = $data['name'];
  121. $this->website = $data['website'];
  122. $this->contact = $data['contact'];
  123. $this->email = $data['email'];
  124. $this->phone = $data['phone'];
  125. $this->comment = $data['comment'];
  126. }
  127.  
  128. /** @ORM\PrePersist */
  129. public function onPrePersist()
  130. {
  131. $this->created = $this->updated = new \DateTime('now');
  132. }
  133.  
  134. /** @ORM\PreUpdate */
  135. public function onPreUpdate()
  136. {
  137. $this->updated = new \DateTime('now');
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement