2 namespace Stock\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * @ORM\Table(name="vehicle_year", uniqueConstraints={@ORM\UniqueConstraint(name="unique_year", columns={"name"})})
15 * Can archive records.
19 * Pull Synchronization Strategy for this table.
21 const PULL_SYNCH_STRATEGY = 'Update';
23 * Push Synchronization Strategy for this table.
25 const PUSH_SYNCH_STRATEGY = 'Update';
30 * @ORM\Column(type="integer");
31 * @ORM\GeneratedValue(strategy="AUTO")
36 * @ORM\Column(type="string", length=4, unique=true)
41 * @ORM\Column(type="smallint", nullable=true, name="create_version", options={"unsigned"=true})
43 protected $createVersion;
46 * @ORM\Column(type="smallint", nullable=true, name="update_version", options={"unsigned"=true})
48 protected $updateVersion;
51 * @ORM\Column(type="boolean");
53 protected $archived = false;
58 * Magic getter to expose protected properties.
59 * @param string $property
62 public function __get($property)
64 return $this->$property;
68 * Magic setter to save protected properties.
69 * @param string $property
72 public function __set($property, $value)
74 $this->$property = $value;
80 public function setCreateVersion()
83 $items = \Utility\Registry::getEntityManager()
84 ->getRepository('Stock\\Entity\\Year')
86 foreach ($items as $item)
88 if ($item->createVersion > $version)
90 $version = $item->createVersion;
92 if ($item->updateVersion > $version)
94 $version = $item->updateVersion;
97 $this->createVersion = $version;
103 public function setUpdateVersion()
106 $items = \Utility\Registry::getEntityManager()
107 ->getRepository('Stock\\Entity\\Year')
109 foreach ($items as $item)
111 if ($item->createVersion > $version)
113 $version = $item->createVersion;
115 if ($item->updateVersion > $version)
117 $version = $item->updateVersion;
120 $this->updateVersion = $version;
124 * Convert the object to an array.
125 * @param array $expand
126 * @param array $intersect
129 public function toArray(array $expand = array(), array $intersect = array())
131 $includeAll = empty($intersect);
133 ($includeAll || isset($intersect['id']))
134 && $data['id'] = $this->id;
135 ($includeAll || isset($intersect['name']))
136 && $data['name'] = $this->name;
141 * Convert the object to an array for synchronization.
144 public function toSynchArray()
148 'name' => $this->name
153 * Populate from an array.
156 public function fromArray($data = array())
159 && $this->id = $data['id'];
161 && $this->name = $data['name'];
162 isset($data['createVersion'])
163 && $this->createVersion = $data['createVersion'];
164 isset($data['updateVersion'])
165 && $this->updateVersion = $data['updateVersion'];