text changes to registration mail content
[namibia] / module / Valuation / src / Valuation / Entity / CustomerPublicValuation.php
1 <?php
2 namespace Valuation\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A valuation.
10  *
11  * @ORM\Entity
12  * @ORM\HasLifecycleCallbacks
13  * @ORM\Table(name="customer_public_valuation")
14  */
15 class CustomerPublicValuation
16 {
17
18         /**
19          * Can archive records.
20          */
21         const ARCHIVE = true;
22         /**
23          * Pull Synchronization Strategy for this table.
24          */
25         const PULL_SYNCH_STRATEGY = 'Build';
26         /**
27          * Push Synchronization Strategy for this table.
28          */
29         const PUSH_SYNCH_STRATEGY = 'Update';
30         /**
31          * Post insert action must be called after new entity is flushed to database.
32          */
33         const HAVE_POST_INSERT = true;
34         /**
35          * Handle as a job queue for mobile devices.
36          */
37         const JOB_QUEUE = true;
38
39
40
41
42         /* ------------------------------------ Identification ------------------------------------ */
43         /**
44          * @ORM\Id
45          * @ORM\Column(type="integer");
46          * @ORM\GeneratedValue(strategy="AUTO")
47          */
48         protected $id;
49
50         /**
51          * @ORM\Column(type="string", length=255, nullable=true, name="customer_hash");
52          */
53         protected $customerHash;
54
55
56         /* ------------------------------------ Ownership ------------------------------------ */
57         /**
58          * @ORM\ManyToOne(targetEntity="\Stock\Entity\Stock", cascade={"all"})
59          * @ORM\JoinColumn(nullable=false, name="stock_id")
60          **/
61         protected $stock;
62
63     /**
64      * @ORM\ManyToOne(targetEntity="\Valuation\Entity\Valuation", cascade={"all"})
65      * @ORM\JoinColumn(nullable=false, name="valuation_id")
66      **/
67     protected $valuation;
68
69         /**
70          * @ORM\Column(type="datetime");
71          */
72         protected $created;
73
74         /**
75          * @ORM\Column(type="datetime", nullable=true);
76          */
77         protected $updated;
78
79         /**
80          * @ORM\Column(type="boolean");
81          */
82         protected $archived = false;
83
84     /**
85      * Magic getter to expose protected properties.
86      *
87      * @param string $property
88      * @return mixed
89      */
90     public function __get($property)
91     {
92         return $this->$property;
93     }
94
95 //    /**
96 //     * Magic setter to save protected properties.
97 //     *
98 //     * @param string $property
99 //     * @param mixed $value
100 //     */
101 //    public function __set($property, $value)
102 //    {
103 //        if ('password' == $property)
104 //        {
105 //            $this->customerHash = md5($value);
106 //            return;
107 //        }
108 //        $this->$property = $value;
109 //    }
110
111     /**
112      * @ORM\PrePersist
113      */
114     public function setCreateTime()
115     {
116         $this->created = new \DateTime("now");
117     }
118
119     /**
120      * @ORM\PreUpdate
121      */
122     public function setUpdateTime()
123     {
124         $this->updated = new \DateTime("now");
125     }
126
127     /**
128      * Convert the object to an array.
129      * @param array $expand
130      * @param array $intersect
131      * @param boolean $showIdentifiers
132      * @param integer $expandAll
133      * @return array
134      */
135     public function toArray(
136         array $expand = array(), array $intersect = array(),
137         $showIdentifiers = false, $expandAll = 0
138     )
139     {
140         $intersect = array_flip($intersect);
141         $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
142         $includeAll = empty($intersect);
143         $data = array();
144         ($includeAll || isset($intersect['id']))
145         && $data['id'] = $this->id;
146         ($includeAll || isset($intersect['customerHash']))
147         && $data['customerHash'] = $this->customerHash;
148         ($includeAll || isset($intersect['stock']))
149         && $data['stock'] = $this->stock;
150         ($includeAll || isset($intersect['valuation']))
151         && $data['valuation'] = $this->valuation;
152         ($includeAll || isset($intersect['created']))
153         && $data['created'] = !is_null($this->created)
154             ? $this->created->format($dateTimeFormat)
155             : null;
156         ($includeAll || isset($intersect['updated']))
157         && $data['updated'] = !is_null($this->updated)
158             ? $this->updated->format($dateTimeFormat)
159             : null;
160         ($includeAll || isset($intersect['archived']))
161         && $data['archived'] = $this->archived;
162         return $data;
163     }
164
165     /**
166      * Populate from an array.
167      * @param array $data
168      */
169     public function fromArray($data = array())
170     {
171         isset($data['id'])
172         && $this->id = $data['id'];
173         isset($data['customerHash'])
174         && $this->customerHash = $data['customerHash'];
175         isset($data['stock'])
176         && $this->stock = $data['stock'];
177         isset($data['valuation'])
178         && $this->valuation = $data['valuation'];
179
180     }
181
182 }
183