2 namespace PriceGuide\Entity;
4 use Doctrine\ORM\Mapping as ORM;
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="price_guide_club")
19 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = false;
27 * Push Synchronization Strategy for this table.
29 const PUSH_SYNCH_STRATEGY = false;
33 /* ------------------------------------ Identification ------------------------------------ */
36 * @ORM\Column(type="integer");
37 * @ORM\GeneratedValue(strategy="AUTO")
42 /* ------------------------------------ Ownership ------------------------------------ */
44 * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
45 * @ORM\JoinColumn(nullable=false, name="company_id")
50 /* ------------------------------------ Customer ------------------------------------ */
52 * @ORM\Column(type="string", length=50, nullable=true, name="name")
57 /* ------------------------------------ Linkage ------------------------------------ */
59 * @ORM\OneToMany(targetEntity="ClubStock", mappedBy="club", cascade={"all"}, fetch="EXTRA_LAZY")
61 protected $stockItems;
63 * @ORM\OneToMany(targetEntity="Member", mappedBy="club", cascade={"all"}, fetch="EXTRA_LAZY")
68 /* ------------------------------------ Tracking ------------------------------------ */
71 * @ORM\Column(type="string", length=25, nullable=true, name="status");
73 protected $status = 'Active';
76 * @ORM\Column(type="datetime");
81 * @ORM\Column(type="datetime", nullable=true);
86 * @ORM\Column(type="boolean", name="use_as_default");
88 protected $useAsDefault = false;
91 * @ORM\Column(type="boolean");
93 protected $archived = false;
98 * Magic getter to expose protected properties.
100 * @param string $property
103 public function __get($property)
105 return $this->$property;
109 * Magic setter to save protected properties.
111 * @param string $property
112 * @param mixed $value
114 public function __set($property, $value)
116 $this->$property = $value;
122 public function setCreateTime()
124 if (is_null($this->company))
126 $this->company = \Utility\Registry::resolveCompanyContext($this->company);
128 $this->created = new \DateTime("now");
134 public function setUpdateTime()
136 $this->updated = new \DateTime("now");
140 * Convert the object to an array.
141 * @param array $expand
142 * @param array $intersect
143 * @param boolean $showIdentifiers
144 * @param integer $expandAll
147 public function toArray(
148 array $expand = array(), array $intersect = array(),
149 $showIdentifiers = false, $expandAll = 0
152 $intersect = array_flip($intersect);
153 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
154 $includeAll = empty($intersect);
156 ($includeAll || isset($intersect['id']))
157 && $data['id'] = $this->id;
158 ($includeAll || isset($intersect['company']))
159 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
160 && !is_null($this->company)
161 ? (!$showIdentifiers ? $this->company->toArray(
162 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
163 ) : $this->company->id)
165 ($includeAll || isset($intersect['name']))
166 && $data['name'] = $this->name;
167 ($includeAll || isset($intersect['status']))
168 && $data['status'] = $this->status;
169 ($includeAll || isset($intersect['created']))
170 && $data['created'] = !is_null($this->created)
171 ? $this->created->format($dateTimeFormat)
173 ($includeAll || isset($intersect['updated']))
174 && $data['updated'] = !is_null($this->updated)
175 ? $this->updated->format($dateTimeFormat)
177 ($includeAll || isset($intersect['useAsDefault']))
178 && $data['useAsDefault'] = $this->useAsDefault;
183 * Populate from an array.
186 public function fromArray($data = array())
189 && $this->id = $data['id'];
190 isset($data['company'])
191 && $this->company = $data['company'];
193 && $this->name = $data['name'];
194 isset($data['status'])
195 && $this->status = $data['status'];
196 isset($data['useAsDefault'])
197 && $this->useAsDefault = $data['useAsDefault'];