text changes to registration mail content
[namibia] / module / Utility / src / Utility / Entity / Document.php
1 <?php
2 namespace Utility\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A document.
10  * @ORM\Entity
11  * @ORM\HasLifecycleCallbacks
12  * @ORM\Table(name="lib_document")
13  */
14 class Document
15 {
16
17         /**
18          * Can archive records.
19          */
20         const ARCHIVE = true;
21         /**
22          * Pull Synchronization Strategy for this table.
23          */
24         const PULL_SYNCH_STRATEGY = false;
25         /**
26          * Push Synchronization Strategy for this table.
27          */
28         const PUSH_SYNCH_STRATEGY = false;
29
30         /**
31          * @ORM\Id
32          * @ORM\Column(type="integer");
33          * @ORM\GeneratedValue(strategy="AUTO")
34          */
35         protected $id;
36
37         /**
38          * @ORM\Column(type="string", length=250)
39          */
40         protected $filename;
41
42         /**
43          * @ORM\Column(type="string", length=200, name="mime_type")
44          */
45         protected $mimeType;
46
47         /**
48          * @ORM\Column(type="integer")
49          */
50         protected $downloads = 0;
51
52         /**
53          * @ORM\Column(type="datetime");
54          */
55         protected $created;
56
57         /**
58          * @ORM\Column(type="boolean");
59          */
60         protected $archived = false;
61
62
63         /**
64          * Magic getter to expose protected properties.
65          * @param string $property
66          * @return mixed
67          */
68         public function __get($property)
69         {
70                 return $this->$property;
71         }
72
73         /**
74          * Magic setter to save protected properties.
75          * @param string $property
76          * @param mixed $value
77          */
78         public function __set($property, $value)
79         {
80                 $this->$property = $value;
81         }
82
83         /**
84          * @ORM\PrePersist
85          */
86         public function setCreateTime()
87         {
88                 $this->created = new \DateTime("now");
89         }
90
91         /**
92          * Convert the object to an array.
93          * @param array $expand
94          * @return array
95          */
96         public function toArray(array $expand = array())
97         {
98                 return array(
99                                 'id'        => $this->id,
100                                 'filename'  => $this->filename,
101                                 'mimeType'  => $this->mimeType,
102                                 'downloads' => $this->downloads,
103                                 'created'   => !is_null($this->created)
104                                         ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
105                                         : null
106                 );
107         }
108
109         /**
110          * Populate from an array.
111          * @param array $data
112          */
113         public function fromArray($data = array())
114         {
115                 isset($data['id'])
116                         && $this->id = $data['id'];
117                 isset($data['filename'])
118                         && $this->filename  = $data['filename'];
119                 isset($data['mimeType'])
120                         && $this->mimeType  = $data['mimeType'];
121                 isset($data['downloads'])
122                         && $this->downloads  = $data['downloads'];
123         }
124
125 }