protected function initRelations() { $this->setManyToOne('user_device', \models\entitymanagers\UserDeviceManager::instance()); }
public function doRegister() { $this->_enforcePOST(); $timeInt = (int) substr($this->requestId, 0, strlen($this->requestId) - 3); $diff = abs($timeInt - time()); if (!$this->userDevice) { if ($diff > self::ALLOWED_LAG) { $this->response->badRequest(); $this->response->addError(new ApiError(400, "Validation error")); } else { $device_uuid = $this->_request->getPostData('device_uuid'); $userDevice = UserDeviceManager::register($device_uuid); if (!$userDevice) { $this->response->addError(new ApiError(400, "Error creating entry")); } else { $this->userDevice = $userDevice; } } } if ($this->userDevice) { //set to body $this->result = array('device' => $this->userDevice->toArray(0)); } }