3 namespace Config\Entity;
5 use Doctrine\ORM\Mapping as ORM;
11 * @ORM\HasLifecycleCallbacks
12 * @ORM\Table(name="regional_manager", uniqueConstraints={@ORM\UniqueConstraint(name="unique_email", columns={"email"})})
18 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = false;
28 * Push Synchronization Strategy for this table.
30 const PUSH_SYNCH_STRATEGY = false;
33 * Post update action must be called after existing entity is flushed to database.
35 const HAVE_POST_UPDATE = true;
39 * @ORM\Column(type="integer");
40 * @ORM\GeneratedValue(strategy="AUTO")
45 * @ORM\ManyToOne(targetEntity="\Company\Entity\Group")
46 * @ORM\JoinColumn(name="company_group_id")
51 * @ORM\Column(type="string", length=255, unique=true)
56 * @ORM\Column(type="string", length=100, name="first_name")
61 * @ORM\Column(type="string", length=100, name="family_name")
63 protected $familyName;
66 * @ORM\Column(type="string", length=20)
71 * @ORM\Column(type="datetime");
76 * @ORM\Column(type="datetime", nullable=true);
81 * @ORM\Column(type="boolean");
83 protected $archived = false;
86 * Initialize collections.
88 public function __construct()
93 public function getId()
99 * Magic getter to expose protected properties.
101 * @param string $property
104 public function __get($property)
106 return $this->$property;
110 * 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 $this->created = new \DateTime("now");
130 public function setUpdateTime()
132 $this->updated = new \DateTime("now");
135 public function postUpdate()
141 * Convert the object to an array.
142 * @param array $expand
143 * @param array $intersect
144 * @param boolean $showIdentifiers
145 * @param integer $expandAll
148 public function toArray(
149 array $expand = array(), array $intersect = array(), $showIdentifiers = false,
153 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
154 $includeAll = empty($intersect);
156 ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id;
157 ($includeAll || isset($intersect['group']))
158 && $data['group'] = (in_array('group', $expand) || $expandAll || $showIdentifiers)
159 && !is_null($this->group)
160 ? (!$showIdentifiers || in_array('group', $expand) ? $this->group->toArray(
161 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
162 ) : $this->group->id)
164 ($includeAll || isset($intersect['email'])) && $data['email'] = $this->email;
165 ($includeAll || isset($intersect['firstName'])) && $data['firstName'] = $this->firstName;
166 ($includeAll || isset($intersect['familyName'])) && $data['familyName'] = $this->familyName;
167 ($includeAll || isset($intersect['fullName'])) && $data['fullName'] = $this->firstName . ' ' . $this->familyName;
168 ($includeAll || isset($intersect['mobile'])) && $data['mobile'] = $this->mobile;
169 ($includeAll || isset($intersect['created'])) && $data['created'] = !is_null($this->created) ? $this->created->format($dateTimeFormat) : null;
170 ($includeAll || isset($intersect['updated'])) && $data['updated'] = !is_null($this->updated) ? $this->updated->format($dateTimeFormat) : null;
175 * Populate from an array.
178 public function fromArray($data = array())
180 isset($data['id']) && $this->id = $data['id'];
181 isset($data['group']) && $this->group = $data['group'];
182 isset($data['email']) && $this->email = $data['email'];
183 isset($data['firstName']) && $this->firstName = $data['firstName'];
184 isset($data['familyName']) && $this->familyName = $data['familyName'];
185 isset($data['mobile']) && $this->mobile = $data['mobile'];