2 namespace Company\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * A company mobile device registration.
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="company_device_registration")
15 class DeviceRegistration
19 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = false;
27 * Push Synchronization Strategy for this table.
29 const PUSH_SYNCH_STRATEGY = false;
33 * @ORM\Column(type="integer");
34 * @ORM\GeneratedValue(strategy="AUTO")
39 * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
40 * @ORM\JoinColumn(nullable=false, name="company_id")
45 * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
46 * @ORM\JoinColumn(nullable=false, name="profile_id")
51 * @ORM\ManyToOne(targetEntity="\Company\Entity\Device")
52 * @ORM\JoinColumn(nullable=false, name="device_id")
57 * @ORM\Column(type="string", length=100, name="push_key", nullable=false)
62 * @ORM\Column(type="datetime");
67 * @ORM\Column(type="datetime", nullable=true);
72 * @ORM\Column(type="boolean");
74 protected $archived = false;
81 * Magic getter to expose protected properties.
82 * @param string $property
85 public function __get($property)
87 return $this->$property;
91 * Magic setter to save protected properties.
92 * @param string $property
95 public function __set($property, $value)
97 $this->$property = $value;
103 public function setCreateTime()
105 $this->created = new \DateTime("now");
111 public function setUpdateTime()
113 $this->updated = new \DateTime("now");
117 * Convert the object to an array.
118 * @param array $expand
119 * @param array $intersect
120 * @param boolean $showIdentifiers
121 * @param integer $expandAll
124 public function toArray(
125 array $expand = array(), array $intersect = array(),
126 $showIdentifiers = false, $expandAll = 0
129 $intersect = array_flip($intersect);
130 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
131 $includeAll = empty($intersect);
132 $recExpand = $expand;
133 foreach($recExpand as $i => $val)
135 if ('company' == $val || 'tradeCenter' == $val)
137 unset($recExpand[$i]);
141 ($includeAll || isset($intersect['id']))
142 && $data['id'] = $this->id;
143 ($includeAll || isset($intersect['pushKey']))
144 && $data['pushKey'] = $this->pushKey;
145 ($includeAll || isset($intersect['company']))
146 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
147 && !is_null($this->company)
148 ? (!$showIdentifiers || in_array('company', $expand) ? $this->company->toArray(
149 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
150 ) : $this->company->id)
152 ($includeAll || isset($intersect['profile']))
153 && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers)
154 && !is_null($this->profile)
155 ? (!$showIdentifiers || in_array('profile', $expand) ? $this->profile->toArray(
156 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
157 ) : $this->profile->id)
159 ($includeAll || isset($intersect['device']))
160 && $data['device'] = (in_array('device', $expand) || $expandAll || $showIdentifiers)
161 && !is_null($this->device)
162 ? (!$showIdentifiers || in_array('device', $expand) ? $this->device->toArray(
163 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
164 ) : $this->device->id)
166 ($includeAll || isset($intersect['created']))
167 && $data['created'] = !is_null($this->created)
168 ? $this->created->format($dateTimeFormat)
170 ($includeAll || isset($intersect['updated']))
171 && $data['updated'] = !is_null($this->updated)
172 ? $this->updated->format($dateTimeFormat)
178 * Populate from an array.
181 public function fromArray($data = array())
184 && $this->id = $data['id'];
185 isset($data['pushKey'])
186 && $this->pushKey = $data['pushKey'];
187 isset($data['company'])
188 && $this->company = $data['company'];
189 isset($data['profile'])
190 && $this->profile = $data['profile'];
191 isset($data['device'])
192 && $this->device = $data['device'];