initial commit
[namibia] / module / Utility / src / Utility / Entity / DebugLog.php
1 <?php
2 namespace Utility\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * Runtime Debug logs.
10  * @ORM\Entity
11  * @ORM\HasLifecycleCallbacks
12  * @ORM\Table(name="lib_debug_log")
13  */
14 class DebugLog
15 {
16
17         /**
18          * Can archive records.
19          */
20         const ARCHIVE = false;
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="integer", nullable=true, name="profile_id")
39          */
40         protected $userId;
41
42         /**
43          * @ORM\Column(type="string", nullable=true, length=250, name="call_name")
44          */
45         protected $callName;
46
47         /**
48          * @ORM\Column(type="text", name="parameters")
49          */
50         protected $params;
51
52         /**
53          * @ORM\Column(type="text", name="error_string")
54          */
55         protected $errorString;
56
57         /**
58          * @ORM\Column(type="datetime");
59          */
60         protected $created;
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          * @param array $intersect
95          * @return array
96          */
97         public function toArray(array $expand = array('attachment'), array $intersect = array())
98         {
99                 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
100                 $includeAll = empty($intersect);
101                 $data = array();
102                 ($includeAll || isset($intersect['id']))
103                         && $data['id'] = $this->id;
104                 ($includeAll || isset($intersect['userId']))
105                         && $data['userId'] = $this->userId;
106                 ($includeAll || isset($intersect['callName']))
107                         && $data['callName'] = $this->callName;
108                 ($includeAll || isset($intersect['params']))
109                         && $data['params'] = !is_null($this->params)
110                                                 ? unserialize($this->params)
111                                                 : null;
112                 ($includeAll || isset($intersect['errorString']))
113                         && $data['errorString'] = $this->errorString;
114                 ($includeAll || isset($intersect['created']))
115                         && $data['created'] = !is_null($this->created)
116                                 ? $this->created->format($dateTimeFormat)
117                                 : null;
118                 return $data;
119         }
120
121         /**
122          * Populate from an array.
123          * @param array $data
124          */
125         public function fromArray($data = array())
126         {
127                 isset($data['id'])
128                         && $this->id = $data['id'];
129                 isset($data['userId'])
130                         && $this->userId = $data['userId'];
131                 isset($data['callName'])
132                         && $this->callName = $data['callName'];
133                 isset($data['emailBody'])
134                         && $this->emailBody = $data['emailBody'];
135                 isset($data['params']) && is_array($data['params'])
136                         && $this->params = serialize($data['params']);
137                 isset($data['errorString'])
138                         && $this->errorString = $data['errorString'];
139         }
140
141 }