2 namespace Company\Entity;
4 use Doctrine\ORM\Mapping as ORM;
11 * @ORM\HasLifecycleCallbacks
12 * @ORM\Table(name="company_group")
18 * Can archive records.
22 * Pull Synchronization Strategy for this table.
24 const PULL_SYNCH_STRATEGY = false;
26 * Push Synchronization Strategy for this table.
28 const PUSH_SYNCH_STRATEGY = false;
32 * Valid pricing types.
34 const PRICINGTYPE_INCREMENTAL = 'Incremental';
35 const PRICINGTYPE_FIXED = 'Fixed';
40 * @ORM\Column(type="integer");
41 * @ORM\GeneratedValue(strategy="AUTO")
46 * @ORM\Column(type="string", length=100)
51 * @ORM\OneToOne(targetEntity="\Utility\Entity\Image")
52 * @ORM\JoinColumn(nullable=true, name="logo_lib_photo_id")
57 * @ORM\OneToOne(targetEntity="\Utility\Entity\Image")
58 * @ORM\JoinColumn(nullable=true, name="watermark_lib_photo_id")
63 * @ORM\Column(type="smallint", name="number_of_dealers");
65 protected $numberOfDealers = 0;
68 * @ORM\Column(type="string", length=25, nullable=true, name="pricing_type")
70 protected $pricingType = 'Incremental';
73 * @ORM\Column(type="integer", nullable=true, name="fixed_pricing")
75 protected $fixedPricing = 0;
78 * @ORM\Column(type="boolean", name="price_guide");
80 protected $priceGuide = false;
83 * @ORM\Column(type="datetime");
88 * @ORM\Column(type="datetime", nullable=true);
93 * @ORM\Column(type="boolean");
95 protected $archived = false;
98 * @ORM\OneToMany(targetEntity="Config\Entity\RegionalManager", mappedBy="group", fetch="EXTRA_LAZY")
100 private $regionalManagers;
103 * @ORM\OneToMany(targetEntity="GroupDivision", mappedBy="group", fetch="EXTRA_LAZY")
108 * @ORM\OneToMany(targetEntity="Company", mappedBy="group", fetch="EXTRA_LAZY")
113 * @ORM\Column(type="string", name="landing_page");
115 protected $landingPage = '';
119 * Initialize collections.
121 public function __construct()
123 $this->regionalManagers = new \Doctrine\Common\Collections\ArrayCollection();
124 $this->divisions = new \Doctrine\Common\Collections\ArrayCollection();
125 $this->companies = new \Doctrine\Common\Collections\ArrayCollection();
129 * Add a new division to this group.
131 * @return \Location\Entity\Region
133 public function addDivision(GroupDivision $division)
135 $this->divisions[] = $division;
140 * Magic getter to expose protected properties.
141 * @param string $property
144 public function __get($property)
146 return $this->$property;
150 * Magic setter to save protected properties.
151 * @param string $property
152 * @param mixed $value
154 public function __set($property, $value)
156 $this->$property = $value;
162 public function setCreateTime()
164 $this->created = new \DateTime("now");
170 public function setUpdateTime()
172 $this->updated = new \DateTime("now");
176 * Convert the object to an array.
177 * @param array $expand
178 * @param array $intersect
181 public function toArray(array $expand = array(), array $intersect = array())
183 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
184 $includeAll = empty($intersect);
186 ($includeAll || isset($intersect['id']))
187 && $data['id'] = $this->id;
188 ($includeAll || isset($intersect['name']))
189 && $data['name'] = $this->name;
190 ($includeAll || isset($intersect['logo']))
191 && $data['logo'] = in_array('logo', $expand)
192 && !is_null($this->logo)
193 ? $this->logo->toArray($expand, $intersect)
195 ($includeAll || isset($intersect['watermark']))
196 && $data['watermark'] = in_array('watermark', $expand)
197 && !is_null($this->watermark)
198 ? $this->watermark->toArray($expand, $intersect)
200 ($includeAll || isset($intersect['numberOfDealers']))
201 && $data['numberOfDealers'] = $this->numberOfDealers;
202 ($includeAll || isset($intersect['pricingType']))
203 && $data['pricingType'] = $this->pricingType;
204 ($includeAll || isset($intersect['landingPage']))
205 && $data['landingPage'] = $this->landingPage;
206 ($includeAll || isset($intersect['fixedPricing']))
207 && $data['fixedPricing'] = $this->fixedPricing;
208 ($includeAll || isset($intersect['priceGuide']))
209 && $data['priceGuide'] = $this->priceGuide;
210 ($includeAll || isset($intersect['created']))
211 && $data['created'] = !is_null($this->created)
212 ? $this->created->format($dateTimeFormat)
214 ($includeAll || isset($intersect['updated']))
215 && $data['updated'] = !is_null($this->updated)
216 ? $this->updated->format($dateTimeFormat)
222 * Populate from an array.
225 public function fromArray($data = array())
228 && $this->id = $data['id'];
230 && $this->name = $data['name'];
232 && $this->logo = $data['logo'];
233 isset($data['watermark'])
234 && $this->watermark = $data['watermark'];
235 isset($data['numberOfDealers'])
236 && $this->numberOfDealers = $data['numberOfDealers'];
237 isset($data['pricingType'])
238 && $this->pricingType = $data['pricingType'];
239 isset($data['fixedPricing'])
240 && $this->fixedPricing = $data['fixedPricing'];
241 isset($data['priceGuide'])
242 && $this->priceGuide = $data['priceGuide'];
243 isset($data['landingPage'])
244 && $this->landingPage = $data['landingPage'];