public function error() { $this->autoRender = false; $url = $this->request->url; \Cake\Log\Log::error('User hit with unknown api Endpoint : ' . $url); $this->response->body(DTO\ErrorDto::prepareError(404)); }
public function index() { $this->autoRender = false; $userId = $this->request->query("userId"); $restaurantId = $this->request->query("restaurantId"); \Cake\Log\Log::debug("Download request come with userId :- " . $userId . ' restaurantId :- ' . $restaurantId); if (empty($userId) or empty($restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(101)); \Cake\Log\Log::error("userId or restaurantID is blank "); return; } $restaurantController = new RestaurantController(); if (!$restaurantController->isValidate($restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(100)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId); return; } $userController = new UserController(); if (!$userController->isUserValid($userId, $restaurantId)) { $this->response->body(DTO\ErrorDto::prepareError(102)); \Cake\Log\Log::error("request with incorrect userId :- " . $userId); return; } \Cake\Log\Log::debug('Download request is validate successfully '); $syncController = new SyncController(); $syncController->download($userId, $restaurantId); }
public function takeawayInsert(UploadDTO\TakeawayUploadDto $takeawayRequest, $restaurantId) { try { $tableObj = $this->connect(); $newEntity = $tableObj->newEntity(); $newEntity->TakeawayId = $takeawayRequest->takeawayId; $newEntity->TakeawayNo = $takeawayRequest->takeawayNo; $newEntity->Discount = $takeawayRequest->discount; $newEntity->DeliveryCharges = $takeawayRequest->deliveryCharges; $newEntity->CustId = $takeawayRequest->custId; $newEntity->RestaurantId = $restaurantId; $newEntity->UserId = $takeawayRequest->userId; $newEntity->SourceId = $takeawayRequest->sourceId; $newEntity->CreatedDate = date(VB_DATE_TIME_FORMAT); $newEntity->UpdatedDate = date(VB_DATE_TIME_FORMAT); if ($tableObj->save($newEntity)) { Log::debug('Takeaway entry stored for custId :- ' . $takeawayRequest->custId); return $takeawayRequest->takeawayNo; } Log::error('Takeaway entry stored for custId :- ' . $takeawayRequest->custId); return FALSE; } catch (Exception $ex) { return FALSE; } }
public function saveNetworkDeviceInfo(DTO\ClsNetworkDeviceInfoDto $infoDto) { if ($infoDto and !$this->isPresent($infoDto->userId)) { $entity = $this->connect()->newEntity(); $entity->UserId = $infoDto->userId; $entity->Board = $infoDto->board; $entity->Brand = $infoDto->brand; $entity->Manufacturer = $infoDto->manufacturer; $entity->Model = $infoDto->model; $entity->Product = $infoDto->product; $entity->FmVersion = $infoDto->fmVersion; $entity->IpAddress = $infoDto->ip; $entity->City = $infoDto->city; $entity->Region = $infoDto->region; $entity->Country = $infoDto->country; if ($this->connect()->save($entity)) { \Cake\Log\Log::debug("User Network Device Info save in database for userid : " . $infoDto->userId); return SUCCESS; } \Cake\Log\Log::error("User Network Device Info not save in database for userid : " . $infoDto->userId); return FAIL; } \Cake\Log\Log::error(" userid : " . $infoDto->userId . " record exist in database"); return FAIL; }
public function index() { $this->autoRender = false; $restaurantId = $this->request->query('restaurantId'); $imei = $this->request->query('imei'); $macAddress = $this->isNull($this->request->query('macId')); $info = base64_decode($this->request->query('info')); $ipAddress = $this->request->clientIp(); $restaurantIMEIController = new RestaurantImeiController(); if (!$restaurantIMEIController->isPresent($restaurantId, $imei, $macAddress)) { $this->response->body(DTO\ErrorDto::prepareError(116)); \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId); return; } $restaurantController = new RestaurantController(); \Cake\Log\Log::info('Request is in Download Controller'); if ($restaurantController->isValidate($restaurantId) and !empty($info)) { $networkDeviceDto = UploadDTO\NetworkDeviceInfoDto::Deserialize($info); $ipInfo = new Component\Ipinfo(); $ipDetails = $ipInfo->getFullIpDetails($imei, $networkDeviceDto, $ipAddress); $networkDeviceController = new NetworkDeviceController(); $addNetworkDeviceInfo = $networkDeviceController->addNetworkDeviceInfo($ipDetails, $restaurantId, $macAddress); $sqliteController = new SqliteController(); $sqliteController->getDB($restaurantId); } else { $this->response->body(DTO\ErrorDto::prepareError(100)); } }
/** * Validate a google recaptcha. * * @param string $value The captcha value. * @param array $context The form context. * @return bool */ public static function googleRecaptcha($value, $context) { $httpClient = new Client(); $googleReponse = $httpClient->post('https://www.google.com/recaptcha/api/siteverify', ['secret' => Configure::read('Google.Recaptcha.secret'), 'response' => $value, 'remoteip' => Router::getRequest()->clientIp()]); $result = json_decode($googleReponse->body(), true); if (!empty($result['error-codes'])) { Log::error('Google Recaptcha: ' . $result['error-codes'][0]); } return (bool) $result['success']; }
private function makeSyncEntry(UploadDTO\BillEntryDto $billEntryDto) { $newBillEntry = $this->getTableObj()->getNewBill($billEntryDto->billNo, $billEntryDto->restaurantId, $billEntryDto->userId); if (!is_null($newBillEntry)) { $syncController = new SyncController(); $syncResult = $syncController->billEntry($billEntryDto->userId, json_encode($newBillEntry), $this->insert, $billEntryDto->restaurantId); Log::debug(' New bill entry successfully place in sync table'); return $syncResult; } Log::error('Error occured in sync entry of new bill'); return; }
/** * Casts given value from a database type to PHP equivalent * * @param mixed $value value to be converted to PHP equivalent * @param Driver $driver object from which database preferences and configuration will be extracted * @return mixed */ public function toPHP($value, Driver $driver) { if (!is_string($value) || $value === null) { return null; } $unserialized = unserialize($value); if ($unserialized === false) { Log::error(__('Could not unserialize payload:')); Log::error($value); $unserialized = []; } return $unserialized; }
public function up() { $this->autoRender = false; // $json = null; $json = $this->request->input(); \Cake\Log\Log::debug("Upload request input json : " . $json); \Cake\Log\Log::debug("Checking is request empty or not"); if (empty($json)) { $this->response->body(DTO\ClsErrorDto::prepareError(104)); \Cake\Log\Log::error("User requested with invalid data"); return; } $arr = DTO\ClsUploadDeserializerDto::Deserialize($json); if (empty($arr->user) or empty($arr->data)) { // $this->response->body(DTO\ClsErrorDto::prepareError(117)); return; } $user = DTO\ClsUserDto::Deserialize($arr->user); if ($this->userValidation($user->userId, $user->emailId, $user->userName)) { $senderUserId = $user->userId; foreach ($arr->data as $index => $record) { \Cake\Log\Log::info('Index : ' . $index . 'Record :' . $record->tableName); switch ($record->tableName) { case $this->table['TC']: \Cake\Log\Log::info("Comment section"); $commentDto = DTO\ClsCommentAndLikeDto::Deserialize($record->tableData); $this->uploadComment($senderUserId, $commentDto); break; case $this->table['TL']: $likeDto = DTO\ClsCommentAndLikeDto::Deserialize($record->tableData); $this->uploadLike($user->userId, $likeDto); break; case $this->table['TA']: $answerDto = DTO\ClsAnswerDto::Deserialize($record->tableData); \Cake\Log\Log::debug("Accepted Answer data"); $this->uploadAnswer($user->userId, $answerDto); break; // case $this->table['TU']: // $userDto = DTO\ClsUserDto::Deserialize($record->tableData); // $this->uploadUser($user->userId,$userDto); // break; // case $this->table['TI']: // $imageDto = DTO\ClsImagesDto::Deserialize($record->tableData); // $this->image($imageDto); // break; } } } else { $this->response->body(DTO\ClsErrorDto::prepareError(100)); } }
public function Insert($userId, $update, $table, $operation) { try { $query = $this->connect()->newEntity(); $query->UserId = $userId; $query->JsonSync = $update; $query->TableName = $table; $query->Operation = $operation; $query->UpdatedDate = date("Y-m-d H:i:s"); $this->connect()->save($query); } catch (Excetion $e) { \Cake\Log\Log::error("Database exception : " . $ex); } }
/** * Authentication hook to authenticate a user against an LDAP server. * * @param \Cake\Network\Request $request The request that contains login information. * @param \Cake\Network\Response $response Unused response object. * @return mixed False on login failure. An array of User data on success. */ public function authenticate(Request $request, Response $response) { // This will probably be cn or an email field to search for Log::debug("[Yalp.authenticate] Authentication started", 'yalp'); $userField = $this->form_fields['username']; $passField = $this->form_fields['password']; $userModel = $this->config('userModel'); list($plugin, $model) = pluginSplit($userModel); // Definitely not authenticated if we haven't got the request data... if (!isset($request->data[$userModel])) { Log::error("[Yalp.authenticate] No request data, cannot authenticate", 'yalp'); return false; } // We need to know the username, or email, or some other unique ID $submittedDetails = $request->data[$userModel]; if (!isset($submittedDetails[$userField])) { //Log::write('yalp', "[Yalp.authenticate] No username supplied, cannot authenticate"); return false; } // Make sure it's a valid string... $username = $submittedDetails[$userField]; if (!is_string($username)) { Log::error("[Yalp.authenticate] Invalid username, cannot authenticate", 'yalp'); return false; } // Make sure they gave us a password too... $password = $submittedDetails[$passField]; if (!is_string($password) || empty($password)) { Log::error("[Yalp.authenticate] Invalid password, cannot authenticate", 'yalp'); return false; } // Check whether or not user exists on LDAP if (!$this->Yalp->validateUser($username, $password)) { Log::error("[Yalp.authenticate] User '{$username}' could not be found on LDAP", 'yalp'); return false; } else { Log::debug("[Yalp.authenticate] User '{$username}' was found on LDAP", 'yalp'); } // Check on DB $comparison = 'LOWER(' . $model . '.' . $userField . ')'; $conditions = array($comparison => strtolower($username)); $dbUser = TableRegistry::get($userModel)->find('all', array('conditions' => $conditions, 'recursive' => false))->first(); // If we couldn't find them in the database, warn and fail if (empty($dbUser)) { Log::warning("[Yalp.authenticate] Could not find a database entry for {$username}", 'yalp'); return false; } // ...and return the user object. return $dbUser->toArray(); }
public function occupy($tableId, $isOccupied) { if ($tableId) { $conditions = ['TableId =' => $tableId]; $updateTable = $this->connect()->query()->update(); $updateTable->set(['IsOccupied' => $isOccupied]); $updateTable->where($conditions); if ($updateTable->execute()) { Log::debug('Table Occupied status changes for giveen request'); return true; } Log::error('Table Occupied status changes for giveen request'); return false; } }
public function deleteCustomer(UploadDTO\CustomerUploadDto $customerInfo, $userInfo) { $conditions = ['CustId =' => $customerInfo->custId, 'RestaurantId =' => $userInfo->restaurantId]; try { $delete = $this->connect()->deleteAll($conditions); if ($delete) { Log::debug('Waiting Customer' . $customerInfo->custName . ' deleted from customer table'); return true; } Log::error('Error Occured in customer table during customer deletion'); return false; } catch (Exception $ex) { return false; } }
public function excutePreparedStatement($Text) { $db = new \SQLite3($this->sqliteFile); if ($Text) { try { $success = $db->exec($Text); $db->close(); return $success; } catch (Exception $ex) { throw "sqlite database error"; } } \Cake\Log\Log::error('Table insert script is not valid'); return false; }
private function updateUserInfo($userDto) { if (is_null($userDto->userId) or is_null($userDto->emailId) or is_null($userDto->userName)) { $this->response->body(DTO\ClsErrorDto::prepareError(114)); \Cake\Log\Log::error("User information is empty"); return FAIL; } if ($this->getTableObj()->update($userDto)) { $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage("User updated successfully for userid " . $userDto->userId)); $syncController = new SyncController(); $downloadUserDto = new DownloadDto\UserDto($userDto->userId, $userDto->userName, $userDto->photoUrl); $syncController->userEntry($userDto->userId, json_encode($downloadUserDto), INSERT); } else { $this->response->body(DTO\ClsErrorDto::prepareError(108)); } }
private function makeSyncEntry($billNo, $userId, $restaurantId) { $newBillDetailsEntryList = $this->getTableObj()->getNewDetails($billNo); if (!is_null($newBillDetailsEntryList)) { $syncController = new SyncController(); foreach ($newBillDetailsEntryList as $newBillDetails) { $syncResult = $syncController->billDetailsEntry($userId, json_encode($newBillDetails), INSERT_OPERATION, $restaurantId); if (!$syncResult) { return $syncResult; } } Log::debug(' New bill Details entry successfully place in sync table'); return $syncResult; } Log::error('Error occured in sync entry of new bill Details '); return; }
public function insert(UploadDTO\BillTaxTransactionDto $billTaxTransactions) { $conn = ConnectionManager::get('default'); $tableObj = $this->connect(); $newBillTax = $tableObj->newEntity(); $newBillTax->BillNo = $billTaxTransactions->billNo; $newBillTax->TaxId = $billTaxTransactions->taxId; $newBillTax->TaxAmount = $billTaxTransactions->taxAmt; $newBillTax->CreatedDate = date(VB_DATE_TIME_FORMAT); if ($tableObj->save($newBillTax)) { Log::debug('Bill Tax Transactions has been created for BillNo :-' . $billTaxTransactions->billNo); return $billTaxTransactions->billNo; } $conn->rollback(); Log::error('error ocurred in Bill Tax Transactions creating for BillNo :-' . $billTaxTransactions->billNo); return 0; }
public function update(UploadDTO\CustomerVisitUpldDto $customerVIsitData) { $conditions = ['RestaurantId =' => $customerVIsitData->restaurantId, 'Month =' => $customerVIsitData->month, 'Year =' => $customerVIsitData->year, 'Day =' => $customerVIsitData->day]; $timeSlot = $customerVIsitData->timeSlot; try { $tableObj = $this->connect(); $entity = $tableObj->get($conditions); $entity->{$timeSlot} = $entity->{$timeSlot} + 1; if ($tableObj->save($entity)) { Log::debug('customer visit updated successfully'); return TRUE; } Log::error('customer visit error in update'); return false; } catch (Exception $ex) { return false; } }
public function Insert($userId, $update, $table, $operation, $restaurantId) { try { $query = $this->connect()->newEntity(); $query->UserId = $userId; $query->JsonSync = $update; $query->TableName = $table; $query->Operation = $operation; $query->UpdatedDate = date(VB_DATE_TIME_FORMAT); $query->RestaurantId = $restaurantId; $save = $this->connect()->save($query); if ($save) { return true; } return false; } catch (Excetion $ex) { \Cake\Log\Log::error("Database exception : " . $ex); } }
public function insert(UploadDTO\BillDetailsUploadDto $billDetails) { $conn = ConnectionManager::get('default'); $tableObj = $this->connect(); $newBillDetails = $tableObj->newEntity(); $newBillDetails->OrderId = $billDetails->orderId; $newBillDetails->BillNo = $billDetails->billNo; $newBillDetails->CreatedDate = date(VB_DATE_TIME_FORMAT); $newBillDetails->UpdatedDate = date(VB_DATE_TIME_FORMAT); $newBillDetails->OrderNo = $billDetails->orderNo; $newBillDetails->OrderAmount = $billDetails->orderAmt; if ($tableObj->save($newBillDetails)) { Log::debug('bill details has been created for BillNo :-' . $billDetails->billNo); return $billDetails->billNo; } $conn->rollback(); Log::error('error ocurred in Bill details creating for BillNo :-' . $billDetails->billNo); return 0; }
public function index() { $this->autoRender = false; $userId = $this->request->query("userid"); \Cake\Log\Log::debug("Download request input querystring userId is : " . $userId); if (empty($userId)) { $this->response->body(DTO\ClsErrorDto::prepareError(101)); \Cake\Log\Log::error("userId is blank " . $userId); return; } $userDto = new DTO\ClsUserDto($userId); if ($this->isValied($userDto->userId)) { \Cake\Log\Log::debug("User validate"); $syncController = new SyncController(); $syncController->download($userDto->userId); } else { $this->response->body(DTO\ClsErrorDto::prepareError(102)); \Cake\Log\Log::error("User requested with invalid userid : " . $userId); } }
public function insert(UploadDTO\OrderDetailEntryDto $orderDetailsEntryDto) { $tableObj = $this->connect(); $newOrder = $tableObj->newEntity(); $newOrder->OrderPrice = $orderDetailsEntryDto->orderPrice; $newOrder->OrderQuantity = $orderDetailsEntryDto->orderQty; $newOrder->CreatedDate = date(VB_DATE_TIME_FORMAT); $newOrder->UpdatedDate = date(VB_DATE_TIME_FORMAT); $newOrder->OrderId = $orderDetailsEntryDto->orderId; $newOrder->MenuId = $orderDetailsEntryDto->menuId; $newOrder->SubMenuId = $orderDetailsEntryDto->subMenuId; $newOrder->MenuTitle = $orderDetailsEntryDto->menuTitle; $newOrder->Note = $orderDetailsEntryDto->note; if ($tableObj->save($newOrder)) { Log::debug('order Details has been saved for OrderDetailsId :-' . $newOrder->OrderDetailsId); return $newOrder->OrderDetailsId; } Log::error('error ocurred in order Details for OrderId :-' . $orderDetailsEntryDto->orderId); return 0; }
public static function loadListeners() { $eventManager = EventManager::instance(); $cached = Cache::read('EventHandlers', 'default'); if ($cached === false) { $eventHandlers = Configure::read('EventHandlers'); $validKeys = array('eventKey' => null, 'options' => array()); $cached = array(); if (!empty($eventHandlers) && is_array($eventHandlers)) { foreach ($eventHandlers as $eventHandler => $eventOptions) { $eventKey = null; if (is_numeric($eventHandler)) { $eventHandler = $eventOptions; $eventOptions = array(); } list($plugin, $class) = pluginSplit($eventHandler); if (!empty($eventOptions)) { extract(array_intersect_key($eventOptions, $validKeys)); } if (isset($eventOptions['options']['className'])) { list($plugin, $class) = pluginSplit($eventOptions['options']['className']); } if (class_exists('\\' . $plugin . '\\Event\\' . $class)) { $cached[] = compact('plugin', 'class', 'eventKey', 'eventOptions'); } else { Log::error(__d('croogo', 'EventHandler %s not found in plugin %s', $class, $plugin)); } } Cache::write('EventHandlers', $cached, 'default'); } } foreach ($cached as $cache) { extract($cache); if (Plugin::loaded($plugin)) { $settings = isset($eventOptions['options']) ? $eventOptions['options'] : array(); $namespace = '\\' . $plugin . '\\Event\\' . $class; $listener = new $namespace($settings); $eventManager->on($listener, $eventKey, $eventOptions); } } }
public function addPrinter(DownloadDTO\RPrinterDownloadDto $entiry, $restaurantId) { try { $obj = $this->connect(); $newEntity = $obj->newEntity(); $newEntity->IpAddress = $entiry->ipAddress; $newEntity->PrinterName = $entiry->name; $newEntity->ModelName = $entiry->model; $newEntity->Company = $entiry->company; $newEntity->MacAddress = $entiry->macAddress; $newEntity->Active = $entiry->active; $newEntity->RestaurantId = $restaurantId; if ($obj->save($newEntity)) { Log::debug('new printer insert operation is done.' . $newEntity->PrinterId); return $newEntity->PrinterId; } Log::error('Error in new printer insert operation.'); } catch (Exception $e) { throw Exception; } }
public function insertImage($imageid, $userid, $destid, $path) { try { $image = $this->connect(); $query = $image->newEntity(); $query->ImageId = $imageid; $query->ImagePath = $path; $query->CreatedDate = date('Y-m-d H:i:s'); $query->UserId = $userid; $query->DestId = $destid; $query->Visibility = 1; if ($image->save($query)) { \Cake\Log\Log::debug("image saved in database : " . $path); return SUCCESS; } Log::error("image not saved in database " . $path); return FAIL; } catch (Exception $e) { throw new \PDOException("database error"); } }
public function insert(UploadDTO\NetworkDeviceInfoDto $networkDeviceDto) { $tableObj = $this->connect(); $newEntry = $tableObj->newEntity(); $newEntry->IMEI = $networkDeviceDto->imei; $newEntry->IpAddress = $networkDeviceDto->ip; $newEntry->City = $networkDeviceDto->city; $newEntry->Region = $networkDeviceDto->region; $newEntry->Country = $networkDeviceDto->country; $newEntry->Brand = $networkDeviceDto->brand; $newEntry->Board = $networkDeviceDto->board; $newEntry->Manufacturer = $networkDeviceDto->manufacturer; $newEntry->Model = $networkDeviceDto->model; $newEntry->Product = $networkDeviceDto->product; $newEntry->FmVersion = $networkDeviceDto->fmVersion; if ($tableObj->save($newEntry)) { Log::debug("User Network Device Info save in database for userid : " . $networkDeviceDto->imei); return true; } Log::error("User Network Device Info not save in database for userid : " . $networkDeviceDto->imei); return false; }
public function index() { $this->autoRender = false; $data = $this->request->data; if (empty($data)) { $this->response->body(DTO\ClsErrorDto::prepareError(106)); \Cake\Log\Log::debug("Image data empty"); return; } if (!array_key_exists('userId', $data) or !array_key_exists('emailId', $data) or !array_key_exists('userName', $data)) { $this->response->body(DTO\ClsErrorDto::prepareError(107)); \Cake\Log\Log::debug("Image data empty"); return; } $userTable = new Table\UserTable(); if (!$userTable->userCkeck($data['userId'], $data['emailId'], $data['userName'])) { $this->response->body(DTO\ClsErrorDto::prepareError(112)); return; } if (array_key_exists('destId', $data)) { $imagesController = new ImagesController(); $result = $imagesController->uploadDestinationImage($data); if ($result) { \Cake\Log\Log::debug("Destination image uploaded successfully"); } else { \Cake\Log\Log::error("Invalid image extension"); } } else { $imagesController = new ImagesController(); $result = $imagesController->uploadProfileImage($data); if ($result) { \Cake\Log\Log::debug("profile image uploaded successfully"); } else { \Cake\Log\Log::error("Invalid image extension"); } } }
public function submit($senderUserId, DTO\ClsAnswerDto $answer) { $check = $this->getTablObj()->isAnswerNew($answer); if ($check) { $result = $this->getTablObj()->update($answer); } else { $result = $this->getTablObj()->Insert($answer->userId, $answer->destId, $answer->optionId); if ($result) { $json = json_encode(new DTO\ClsAnswerDto($answer->userId, $answer->destId, $answer->optionId, $result, date('Y-m-d H:i:s'))); $syncController = new \App\Controller\SyncController(); $syncController->answerEntry($senderUserId, $answer->userId, $json, INSERT); \Cake\Log\Log::debug("Sync Entry for Answer"); } } if ($result) { \Cake\Log\Log::debug('answer submited'); $this->response->body(DTO\ClsErrorDto::prepareSuccessMessage("Answer Saved")); $this->response->send(); } else { \Cake\Log\Log::error('answer not submited'); $this->response->body(DTO\ClsErrorDto::prepareError(120)); $this->response->send(); } }
public function index() { $this->autoRender = false; //$tempUserId = null; $tempUserId = $this->request->query("userid"); $info = base64_decode($this->request->query('info')); $ip = "113.193.128.35"; //$this->request->clientIp(); \Cake\Log\Log::debug('DownloadDb request input querystring info : ' . $info); if (empty($tempUserId) or empty($info)) { $this->response->body(DTO\ClsErrorDto::prepareError(101)); \Cake\Log\Log::error("User requested with blank user id :" . $tempUserId); return; } $networkDeviceInfoDto = DTO\ClsNetworkDeviceInfoDto::Deserialize($info); $ipInfo = new Component\Ipinfo(); $fullDetails = $ipInfo->getFullIpDetails($tempUserId, $networkDeviceInfoDto, $ip); $networkDeviceInfoTable = new Table\NetworkDeviceInfoTable(); $networkDeviceInfoTable->saveNetworkDeviceInfo($fullDetails); $userDto = new DTO\ClsUserDto($tempUserId); \Cake\Log\Log::debug('TempUserId is send to Validate' . $tempUserId . " userIP : " . $ip); if ($this->isValid($userDto->userId)) { \Cake\Log\Log::debug("User validate"); $sqliteController = new SqliteController(); $sqliteController->getDB($userDto->userId); \Cake\Log\Log::debug("Sqlite database sended to user"); } else { $userController = new UserController(); \Cake\Log\Log::debug('UserId send to save in database'); if ($userController->userSignUp($userDto->userId)) { $sqliteController = new SqliteController(); $sqliteController->getDB($userDto->userId); \Cake\Log\Log::debug("sqlite file sended to user after userid saving"); } } }
/** * test convenience methods */ public function testConvenienceMethods() { $this->_deleteLogs(); Log::config('debug', ['engine' => 'File', 'path' => LOGS, 'types' => ['notice', 'info', 'debug'], 'file' => 'debug']); Log::config('error', ['engine' => 'File', 'path' => LOGS, 'types' => ['emergency', 'alert', 'critical', 'error', 'warning'], 'file' => 'error']); $testMessage = 'emergency message'; Log::emergency($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertRegExp('/(Emergency|Critical): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'alert message'; Log::alert($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertRegExp('/(Alert|Critical): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'critical message'; Log::critical($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertContains('Critical: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'error message'; Log::error($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertContains('Error: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'warning message'; Log::warning($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertContains('Warning: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'notice message'; Log::notice($testMessage); $contents = file_get_contents(LOGS . 'debug.log'); $this->assertRegExp('/(Notice|Debug): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'error.log'); $this->_deleteLogs(); $testMessage = 'info message'; Log::info($testMessage); $contents = file_get_contents(LOGS . 'debug.log'); $this->assertRegExp('/(Info|Debug): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'error.log'); $this->_deleteLogs(); $testMessage = 'debug message'; Log::debug($testMessage); $contents = file_get_contents(LOGS . 'debug.log'); $this->assertContains('Debug: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'error.log'); $this->_deleteLogs(); }