2 namespace Stock\Entity;
4 use Doctrine\ORM\Mapping as ORM;
10 * @ORM\HasLifecycleCallbacks
11 * @ORM\Table(name="vehicle_make", uniqueConstraints={@ORM\UniqueConstraint(name="unique_make", columns={"name"})})
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';
32 * @ORM\Column(type="integer");
33 * @ORM\GeneratedValue(strategy="AUTO")
38 * @ORM\Column(type="string", length=75, unique=true)
43 * @ORM\Column(type="datetime");
48 * @ORM\Column(type="datetime", nullable=true);
53 * @ORM\Column(type="smallint", nullable=true, name="create_version", options={"unsigned"=true})
55 protected $createVersion;
58 * @ORM\Column(type="smallint", nullable=true, name="update_version", options={"unsigned"=true})
60 protected $updateVersion;
63 * @ORM\Column(type="boolean");
65 protected $archived = false;
68 * @ORM\OneToMany(targetEntity="Model", mappedBy="make", fetch="EXTRA_LAZY")
74 * Initialize collections.
76 public function __construct()
78 $this->models = new \Doctrine\Common\Collections\ArrayCollection();
82 * Add a new Model to this item.
84 * @return \Stock\Entity\Make
86 public function addModel(Model $model)
88 $this->models[] = $model;
93 * Magic getter to expose protected properties.
94 * @param string $property
97 public function __get($property)
99 return $this->$property;
103 * Magic setter to save protected properties.
104 * @param string $property
105 * @param mixed $value
107 public function __set($property, $value)
109 $this->$property = $value;
115 public function setCreateTime()
117 $this->created = new \DateTime("now");
123 public function setUpdateTime()
125 $this->updated = new \DateTime("now");
129 * Convert the object to an array.
130 * @param array $expand
131 * @param array $intersect
134 public function toArray(array $expand = array(), array $intersect = array())
136 $includeAll = empty($intersect);
138 ($includeAll || isset($intersect['id']))
139 && $data['id'] = $this->id;
140 ($includeAll || isset($intersect['name']))
141 && $data['name'] = $this->name;
146 * Convert the object to an array for synchronization.
149 public function toSynchArray()
153 'name' => $this->name
158 * Populate from an array.
161 public function fromArray($data = array())
164 && $this->id = $data['id'];
166 && $this->name = $data['name'];
167 isset($data['createVersion'])
168 && $this->createVersion = $data['createVersion'];
169 isset($data['updateVersion'])
170 && $this->updateVersion = $data['updateVersion'];