$property; } /** * Magic setter to save protected properties. * * @param string $property * @param mixed $value */ public function __set($property, $value) { $this->$property = $value; } /** * @ORM\PrePersist */ public function setCreateTime() { $this->created = new \DateTime("now"); } /** * @ORM\PreUpdate */ public function setUpdateTime() { $this->updated = new \DateTime("now"); if($this->appointmentCancelled) { $this->appointmentDateCancelled = new \DateTime("now"); } } /** * Convert the object to an array. * @param array $expand * @param array $intersect * @param boolean $showIdentifiers * @param integer $expandAll * @return array */ public function toArray( array $expand = array(), array $intersect = array(), $showIdentifiers = false, $expandAll = 0 ) { $intersect = array_flip($intersect); $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat'); $includeAll = empty($intersect); $data = array(); ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id; ($includeAll || isset($intersect['timeSlot'])) && $data['timeSlot'] = (in_array('timeSlot', $expand) || $expandAll || $showIdentifiers) && !is_null($this->timeSlot) ? (!$showIdentifiers || in_array('timeSlot', $expand) ? $this->timeSlot->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->timeSlot->id) : null; ($includeAll || isset($intersect['valuator'])) && $data['valuator'] = (in_array('valuator', $expand) || $expandAll || $showIdentifiers) && !is_null($this->valuator) ? (!$showIdentifiers || in_array('valuator', $expand) ? $this->valuator->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->valuator->id) : null; ($includeAll || isset($intersect['valuation'])) && $data['valuation'] = (in_array('valuation', $expand) || $expandAll || $showIdentifiers) && !is_null($this->valuation) ? (!$showIdentifiers || in_array('valuation', $expand) ? $this->valuation->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->valuation->id) : null; ($includeAll || isset($intersect['appointmentDate'])) && $data['appointmentDate'] = !is_null($this->appointmentDate) ? $this->appointmentDate->format($dateTimeFormat) : null; ($includeAll || isset($intersect['created'])) && $data['created'] = !is_null($this->created) ? $this->created->format($dateTimeFormat) : null; ($includeAll || isset($intersect['updated'])) && $data['updated'] = !is_null($this->updated) ? $this->updated->format($dateTimeFormat) : null; ($includeAll || isset($intersect['archived'])) && $data['archived'] = $this->archived; ($includeAll || isset($intersect['appointmentCompleted'])) && $data['appointmentCompleted'] = $this->appointmentCompleted; ($includeAll || isset($intersect['appointmentCancelled'])) && $data['appointmentCancelled'] = $this->appointmentCancelled; ($includeAll || isset($intersect['appointmentDateCancelled'])) && $data['appointmentDateCancelled'] = !is_null($this->appointmentDateCancelled) ? $this->appointmentDateCancelled->format($dateTimeFormat) : null; ($includeAll || isset($intersect['appointmentCancelledComments'])) && $data['appointmentCancelledComments'] = $this->appointmentCancelledComments; return $data; } /** * Populate from an array. * @param array $data */ public function fromArray($data = array()) { // unset($data['id']); // unset($data['timeSlot']); // unset($data['valuator']); // unset($data['valuation']); // unset($data['appointmentCompleted']); // unset($data['appointmentCancelled']); // unset($data['appointmentDateCancelled']); // unset($data['appointmentDateCancelled']); // unset($data['appointmentCancelledComments']); // \Utility\Debug::errorLog('$data',$data); isset($data['id']) && $this->id = $data['id']; isset($data['timeSlot']) && $this->timeSlot = $data['timeSlot']; isset($data['valuator']) && $this->valuator = $data['valuator']; isset($data['valuation']) && $this->valuation = $data['valuation']; isset($data['appointmentDate']) && $this->appointmentDate = (is_object($data['appointmentDate']) ? $data['appointmentDate'] : new \DateTime($data['appointmentDate'])); isset($data['appointmentCompleted']) && $this->appointmentCompleted = $data['appointmentCompleted']; isset($data['appointmentCancelled']) && $this->appointmentCancelled = $data['appointmentCancelled']; isset($data['appointmentDateCancelled']) && $this->appointmentDateCancelled = (is_object($data['appointmentDateCancelled']) ? $data['appointmentDateCancelled'] : new \DateTime($data['appointmentDateCancelled'])); isset($data['appointmentCancelledComments']) && $this->appointmentCancelledComments = $data['appointmentCancelledComments']; // if (isset($data['appointmentDate'])) // { // $data['appointmentDate'] = explode(' ', $data['appointmentDate']); // $this->appointmentDate = new \DateTime($data['appointmentDate'][0]); // } // // // \Utility\Debug::errorLog('$data[appointmentDate]',$data['appointmentDate']); // // \Utility\Debug::errorLog('$this->appointmentDate',$this->appointmentDate); // // $this->updated = new \DateTime("now"); // // $this->appointmentDateCancelled = new \DateTime("now"); } /** * Convert the object to an array for synchronization. * @return array */ public function toSynchArray() { return array( 'id' => $this->id, 'appointmentDate' => $this->appointmentDate, 'appointmentCompleted' => $this->appointmentCompleted, 'appointmentCancelled' => $this->appointmentCancelled, 'appointmentDateCancelled' => $this->appointmentDateCancelled, 'appointmentCancelledComments' => $this->appointmentCancelledComments ); } }