2 namespace Company\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * Dealer Group Division.
11 * @ORM\HasLifecycleCallbacks
12 * @ORM\Table(name="company_group_division")
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\ManyToOne(targetEntity="Group", inversedBy="divisions")
47 * @ORM\JoinColumn(name="company_group_id", referencedColumnName="id")
48 * @ORM\OrderBy({"name" = "ASC"})
53 * @ORM\Column(type="string", length=100)
58 * @ORM\OneToMany(targetEntity="Company", mappedBy="groupDivision", fetch="EXTRA_LAZY")
63 * @ORM\Column(type="datetime");
68 * @ORM\Column(type="datetime", nullable=true);
73 * @ORM\Column(type="boolean");
75 protected $archived = false;
79 * Initialize collections.
81 public function __construct()
83 $this->companies = new \Doctrine\Common\Collections\ArrayCollection();
88 * Magic getter to expose protected properties.
89 * @param string $property
92 public function __get($property)
94 return $this->$property;
98 * Magic setter to save protected properties.
99 * @param string $property
100 * @param mixed $value
102 public function __set($property, $value)
104 $this->$property = $value;
110 public function setCreateTime()
112 $this->created = new \DateTime("now");
118 public function setUpdateTime()
120 $this->updated = new \DateTime("now");
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 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
132 $includeAll = empty($intersect);
134 ($includeAll || isset($intersect['id']))
135 && $data['id'] = $this->id;
136 ($includeAll || isset($intersect['group']))
137 && in_array('group', $expand)
138 && $data['group'] = $this->group->toArray($expand, $intersect);
139 ($includeAll || isset($intersect['name']))
140 && $data['name'] = $this->name;
141 ($includeAll || isset($intersect['created']))
142 && $data['created'] = !is_null($this->created)
143 ? $this->created->format($dateTimeFormat)
145 ($includeAll || isset($intersect['updated']))
146 && $data['updated'] = !is_null($this->updated)
147 ? $this->updated->format($dateTimeFormat)
153 * Populate from an array.
156 public function fromArray($data = array())
159 && $this->id = $data['id'];
160 isset($data['group'])
161 && $this->group = $data['group'];
163 && $this->name = $data['name'];