2 namespace Stock\Entity;
4 use Doctrine\ORM\Mapping as ORM;
10 * @ORM\HasLifecycleCallbacks
11 * @ORM\Table(name="vehicle_type")
17 * Can archive records.
21 * Pull Synchronization Strategy for this table.
23 const PULL_SYNCH_STRATEGY = 'Update';
25 * Push Synchronization Strategy for this table.
27 const PUSH_SYNCH_STRATEGY = 'Update';
31 * @ORM\Column(type="integer");
32 * @ORM\GeneratedValue(strategy="AUTO")
37 * @ORM\ManyToOne(targetEntity="Model", inversedBy="types")
38 * @ORM\JoinColumn(name="vehicle_model_id", referencedColumnName="id")
43 * @ORM\ManyToOne(targetEntity="Category")
44 * @ORM\JoinColumn(name="vehicle_category_id", referencedColumnName="id")
49 * @ORM\Column(type="string", length=150)
54 * @ORM\Column(type="string", length=10, name="mm_code")
59 * @ORM\ManyToOne(targetEntity="Year")
60 * @ORM\JoinColumn(nullable=false, name="intro_vehicle_year_id")
65 * @ORM\Column(type="smallint", name="intro_month")
67 protected $introMonth;
70 * @ORM\ManyToOne(targetEntity="Year")
71 * @ORM\JoinColumn(nullable=true, name="disc_vehicle_year_id")
76 * @ORM\Column(type="smallint", nullable=true, name="disc_month")
81 * @ORM\Column(type="smallint", nullable=true)
86 * @ORM\Column(type="integer", nullable=true, name="cubic_capacity")
88 protected $cubicCapacity;
91 * @ORM\Column(type="smallint", nullable=true)
96 * @ORM\Column(type="string", nullable=true, length=25, name="body_type")
101 * @ORM\Column(type="smallint", nullable=true)
107 * @ORM\Column(type="datetime");
112 * @ORM\Column(type="datetime", nullable=true);
117 * @ORM\Column(type="smallint", nullable=true, name="create_version", options={"unsigned"=true})
119 protected $createVersion;
122 * @ORM\Column(type="smallint", nullable=true, name="update_version", options={"unsigned"=true})
124 protected $updateVersion;
127 * @ORM\Column(type="boolean");
129 protected $archived = false;
133 * Magic getter to expose protected properties.
135 * @param string $property
138 public function __get($property)
140 return $this->$property;
144 * Magic setter to save protected properties.
146 * @param string $property
147 * @param mixed $value
149 public function __set($property, $value)
151 $this->$property = $value;
157 public function setCreateTime()
159 $this->created = new \DateTime("now");
165 public function setUpdateTime()
167 $this->updated = new \DateTime("now");
171 * Convert the object to an array.
172 * @param array $expand
173 * @param array $intersect
176 public function toArray(array $expand = array(), array $intersect = array())
178 $includeAll = empty($intersect);
180 ($includeAll || isset($intersect['id']))
181 && $data['id'] = $this->id;
182 ($includeAll || isset($intersect['model']))
183 && in_array('model', $expand)
184 && $data['model'] = $this->model->toArray($expand, $intersect);
185 ($includeAll || isset($intersect['category']))
186 && in_array('category', $expand)
187 && $data['category'] = $this->category->toArray($expand, $intersect);
188 ($includeAll || isset($intersect['name']))
189 && $data['name'] = $this->name;
190 ($includeAll || isset($intersect['mmCode']))
191 && $data['mmCode'] = $this->mmCode;
192 ($includeAll || isset($intersect['introYear']))
193 && in_array('introYear', $expand)
194 && $data['introYear'] = $this->introYear->toArray($expand, $intersect);
195 ($includeAll || isset($intersect['introMonth']))
196 && $data['introMonth'] = $this->introMonth;
197 ($includeAll || isset($intersect['discYear']))
198 && in_array('discYear', $expand)
199 && $data['discYear'] = !is_null($this->discYear)
200 ? $this->discYear->toArray($expand, $intersect)
202 ($includeAll || isset($intersect['discMonth']))
203 && $data['discMonth'] = $this->discMonth;
204 ($includeAll || isset($intersect['created']))
205 && $data['created'] = !is_null($this->created)
206 ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
208 ($includeAll || isset($intersect['updated']))
209 && $data['updated'] = !is_null($this->updated)
210 ? $this->updated->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
216 * Convert the object to an array for synchronization.
219 public function toSynchArray()
223 'model' => $this->model->id,
224 'category' => $this->category->id,
225 'name' => $this->name,
226 'mmCode' => $this->mmCode,
227 'introYear' => $this->introYear->id,
228 'diskYear' => !is_null($this->discYear)
229 ? $this->discYear->id
235 * Populate from an array.
238 public function fromArray($data = array())
241 && $this->id = $data['id'];
242 isset($data['model'])
243 && $this->model = $data['model'];
244 isset($data['category'])
245 && $this->category = $data['category'];
247 && $this->name = $data['name'];
248 isset($data['mmCode'])
249 && $this->mmCode = $data['mmCode'];
250 isset($data['introYear'])
251 && $this->introYear = $data['introYear'];
252 isset($data['introMonth'])
253 && $this->introMonth = $data['introMonth'];
254 isset($data['discYear'])
255 && $this->discYear = $data['discYear'];
256 isset($data['discMonth'])
257 && $this->discMonth = $data['discMonth'];
258 isset($data['cylinders'])
259 && $this->cylinders = $data['cylinders'];
260 isset($data['cubicCapacity'])
261 && $this->cubicCapacity = $data['cubicCapacity'];
262 isset($data['kilowatts'])
263 && $this->kilowatts = $data['kilowatts'];
264 isset($data['bodyType'])
265 && $this->bodyType = $data['bodyType'];
266 isset($data['doors'])
267 && $this->doors = $data['doors'];
268 isset($data['createVersion'])
269 && $this->createVersion = $data['createVersion'];
270 isset($data['updateVersion'])
271 && $this->updateVersion = $data['updateVersion'];