2 namespace Newsletter\Entity;
4 use Doctrine\ORM\Mapping as ORM;
11 * @ORM\HasLifecycleCallbacks
12 * @ORM\Table(name="newsletter")
18 * Can archive records.
22 * Pull Synchronization Strategy for this table.
24 const PULL_SYNCH_STRATEGY = false;
26 * Push Synchronization Strategy for this table.
28 const PUSH_SYNCH_STRATEGY = false;
32 * @ORM\Column(type="integer");
33 * @ORM\GeneratedValue(strategy="AUTO")
38 * @ORM\Column(type="string", length=100)
43 * @ORM\Column(type="text")
48 * @ORM\Column(type="integer", name="sent_to")
50 protected $sentTo = 0;
53 * @ORM\ManyToOne(targetEntity="\Utility\Entity\Attachment")
54 * @ORM\JoinColumn(nullable=true, name="lib_attachment_id")
56 protected $attachment;
59 * @ORM\Column(type="string", length=25, nullable=true, name="previous_status");
61 protected $previousState;
64 * @ORM\Column(type="string", length=25, nullable=true, name="status");
69 * @ORM\Column(type="datetime");
74 * @ORM\Column(type="datetime", nullable=true);
79 * @ORM\Column(type="boolean");
81 protected $archived = false;
85 * Magic getter to expose protected properties.
86 * @param string $property
89 public function __get($property)
91 return $this->$property;
95 * Magic setter to save protected properties.
96 * @param string $property
99 public function __set($property, $value)
101 $this->$property = $value;
107 public function setCreateTime()
109 $this->created = new \DateTime("now");
115 public function setUpdateTime()
117 $this->updated = new \DateTime("now");
121 * Convert the object to an array.
122 * @param array $expand
125 public function toArray(array $expand = array('attachment'))
129 'subject' => $this->subject,
130 'content' => $this->content,
131 'sentTo' => $this->sentTo,
132 'attachment' => in_array('attachment', $expand)
133 && !is_null($this->attachment)
134 ? $this->attachment->toArray($expand)
136 'jobState' => $this->jobState,
137 'created' => !is_null($this->created)
138 ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
140 'updated' => !is_null($this->updated)
141 ? $this->updated->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
147 * Populate from an array.
150 public function fromArray($data = array())
153 && $this->id = $data['id'];
154 isset($data['subject'])
155 && $this->subject = $data['subject'];
156 isset($data['content'])
157 && $this->content = $data['content'];
158 isset($data['sentTo'])
159 && $this->sentTo = $data['sentTo'];
160 isset($data['attachment'])
161 && $this->attachment = $data['attachment'];