2 namespace Company\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * A company mobile device.
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="company_device")
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\Column(type="string", length=100, name="android_id", nullable=false)
44 * @ORM\Column(type="string", length=200, name="registration_id", nullable=true)
46 protected $registrationId;
49 * @ORM\OneToMany(targetEntity="DeviceRegistration", mappedBy="device", fetch="EXTRA_LAZY")
51 protected $deviceRegistrations;
54 * @ORM\Column(type="datetime");
59 * @ORM\Column(type="datetime", nullable=true);
64 * @ORM\Column(type="boolean");
66 protected $archived = false;
71 * Initialize collections.
73 public function __construct()
75 $this->deviceRegistrations = new \Doctrine\Common\Collections\ArrayCollection();
80 * Magic getter to expose protected properties.
81 * @param string $property
84 public function __get($property)
86 return $this->$property;
90 * Magic setter to save protected properties.
91 * @param string $property
94 public function __set($property, $value)
96 $this->$property = $value;
102 public function setCreateTime()
104 $this->created = new \DateTime("now");
110 public function setUpdateTime()
112 $this->updated = new \DateTime("now");
116 * Convert the object to an array.
117 * @param array $expand
118 * @param array $intersect
119 * @param boolean $showIdentifiers
120 * @param integer $expandAll
123 public function toArray(
124 array $expand = array(), array $intersect = array(),
125 $showIdentifiers = false, $expandAll = 0
128 $intersect = array_flip($intersect);
129 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
130 $includeAll = empty($intersect);
131 $recExpand = $expand;
132 foreach($recExpand as $i => $val)
134 if ('company' == $val || 'tradeCenter' == $val)
136 unset($recExpand[$i]);
140 ($includeAll || isset($intersect['id']))
141 && $data['id'] = $this->id;
142 ($includeAll || isset($intersect['deviceId']))
143 && $data['deviceId'] = $this->deviceId;
144 ($includeAll || isset($intersect['registrationId']))
145 && $data['registrationId'] = $this->registrationId;
146 ($includeAll || isset($intersect['created']))
147 && $data['created'] = !is_null($this->created)
148 ? $this->created->format($dateTimeFormat)
150 ($includeAll || isset($intersect['updated']))
151 && $data['updated'] = !is_null($this->updated)
152 ? $this->updated->format($dateTimeFormat)
158 * Populate from an array.
161 public function fromArray($data = array())
164 && $this->id = $data['id'];
165 isset($data['deviceId'])
166 && $this->deviceId = $data['deviceId'];
167 isset($data['registrationId'])
168 && $this->registrationId = $data['registrationId'];