$property; } /** * Magic setter to save protected properties. * @param string $property * @param mixed $value */ public function __set($property, $value) { $this->$property = $value; } /** * @ORM\PrePersist */ public function setCreateVersion() { $version = 1; $items = \Utility\Registry::getEntityManager() ->getRepository('Stock\\Entity\\Accessory') ->findAll(); foreach ($items as $item) { if ($item->createVersion > $version) { $version = $item->createVersion; } if ($item->updateVersion > $version) { $version = $item->updateVersion; } } $this->createVersion = $version; } /** * @ORM\PreUpdate */ public function setUpdateVersion() { $version = 1; $items = \Utility\Registry::getEntityManager() ->getRepository('Stock\\Entity\\Accessory') ->findAll(); foreach ($items as $item) { if ($item->createVersion > $version) { $version = $item->createVersion; } if ($item->updateVersion > $version) { $version = $item->updateVersion; } } $this->updateVersion = $version; } /** * Convert the object to an array. * @param array $expand * @param array $intersect * @return array */ public function toArray(array $expand = array(), array $intersect = array()) { !empty($intersect) && $intersect = array_flip($intersect); $includeAll = empty($intersect); $data = array(); ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id; ($includeAll || isset($intersect['name'])) && $data['name'] = $this->name; return $data; } /** * Convert the object to an array for synchronization. * @return array */ public function toSynchArray() { return array( 'id' => $this->id, 'name' => $this->name ); } /** * Populate from an array. * @param array $data */ public function fromArray($data = array()) { isset($data['id']) && $this->id = $data['id']; isset($data['name']) && $this->name = $data['name']; isset($data['createVersion']) && $this->createVersion = $data['createVersion']; isset($data['updateVersion']) && $this->updateVersion = $data['updateVersion']; } }