2 namespace Stock\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * @ORM\Table(name="vehicle_accessory", uniqueConstraints={@ORM\UniqueConstraint(name="unique_accessory",
16 * Can archive records.
20 * Pull Synchronization Strategy for this table.
22 const PULL_SYNCH_STRATEGY = 'Update';
24 * Push Synchronization Strategy for this table.
26 const PUSH_SYNCH_STRATEGY = 'Update';
31 * @ORM\Column(type="integer");
32 * @ORM\GeneratedValue(strategy="AUTO")
37 * @ORM\Column(type="string", length=75, unique=true)
42 * @ORM\Column(type="smallint", nullable=true, name="create_version", options={"unsigned"=true})
44 protected $createVersion;
47 * @ORM\Column(type="smallint", nullable=true, name="update_version", options={"unsigned"=true})
49 protected $updateVersion;
52 * @ORM\Column(type="boolean");
54 protected $archived = false;
59 * Magic getter to expose protected properties.
60 * @param string $property
63 public function __get($property)
65 return $this->$property;
69 * Magic setter to save protected properties.
70 * @param string $property
73 public function __set($property, $value)
75 $this->$property = $value;
81 public function setCreateVersion()
84 $items = \Utility\Registry::getEntityManager()
85 ->getRepository('Stock\\Entity\\Accessory')
87 foreach ($items as $item)
89 if ($item->createVersion > $version)
91 $version = $item->createVersion;
93 if ($item->updateVersion > $version)
95 $version = $item->updateVersion;
98 $this->createVersion = $version;
104 public function setUpdateVersion()
107 $items = \Utility\Registry::getEntityManager()
108 ->getRepository('Stock\\Entity\\Accessory')
110 foreach ($items as $item)
112 if ($item->createVersion > $version)
114 $version = $item->createVersion;
116 if ($item->updateVersion > $version)
118 $version = $item->updateVersion;
121 $this->updateVersion = $version;
125 * Convert the object to an array.
126 * @param array $expand
127 * @param array $intersect
130 public function toArray(array $expand = array(), array $intersect = array())
133 && $intersect = array_flip($intersect);
134 $includeAll = empty($intersect);
136 ($includeAll || isset($intersect['id']))
137 && $data['id'] = $this->id;
138 ($includeAll || isset($intersect['name']))
139 && $data['name'] = $this->name;
144 * Convert the object to an array for synchronization.
147 public function toSynchArray()
151 'name' => $this->name
156 * Populate from an array.
159 public function fromArray($data = array())
162 && $this->id = $data['id'];
164 && $this->name = $data['name'];
165 isset($data['createVersion'])
166 && $this->createVersion = $data['createVersion'];
167 isset($data['updateVersion'])
168 && $this->updateVersion = $data['updateVersion'];