本文整理汇总了PHP中Result::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::error方法的具体用法?PHP Result::error怎么用?PHP Result::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: watchComposer
/**
* @desc Runs `composer update` by monitoring `composer.json`.
*/
public function watchComposer()
{
if (!$this->watcherReady()) {
return Result::error($this);
}
$this->watcherComposerMonitor();
$this->taskWatch->run();
}
示例2: function
}
});
$this->respond(['GET', 'POST'], '/match-mod/get/assets', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Assets::getRentDemandMatchingAssets($id);
$response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/match-mod/match', function ($request, $response, $service, $app) {
$rentDemandID = $request->param('rentDemandID');
$assetID = $request->param('assetID');
$id = RentProcesses::matchRentDemandAndAsset($rentDemandID, $assetID);
if ($id > 0) {
$response->json(Result::success('Matched.', ['rentProcessID' => $id]));
} else {
$response->json(Result::error('Error trying to match'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$rentDemandResult = RentDemands::deleteRentDemand($id);
RentProcesses::deleteRentDemandProcesses($id);
if ($rentDemandResult > 0) {
$response->json(Result::success('Demand Deleted.'));
} else {
$response->json(Result::error('Demand not Deleted'));
}
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
$result = RentDemands::getAllRentDemands();
$response->json(Result::success('', $result));
});
示例3: function
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('RentProcess not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body(), true);
$result = RentProcesses::updateRentProcess($id, $data);
if ($result > 0) {
$response->json(Result::success('RentProcess Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('RentProcess not Updated.'));
} else {
$response->json(Result::error('RentProcess not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = RentProcesses::deleteRentProcess($id);
if ($result > 0) {
$response->json(Result::success('RentProcess Deleted.'));
} else {
$response->json(Result::error('RentProcess not Deleted'));
}
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
$result = RentProcesses::getAllRentProcesses();
$response->json(Result::success('', $result));
});
示例4: elseif
$agents = $request->param('logAgents');
$result = Logs::updateLog($id, $logData, $agents);
if ($result > 0) {
$response->json(Result::success('Log Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Log not Updated.'));
} else {
$response->json(Result::error('Log not found'));
}
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$logData = Logs::getLog($id);
$agents = Agents::getLogAgents($id);
$notes = Notes::getLogNotes($id);
$result = array("logData" => $logData, "logAgents" => $agents, "logNotes" => $notes);
if ($logData) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Log not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Logs::deleteLog($id);
if ($result > 0) {
$response->json(Result::success('Log Deleted.'));
} else {
$response->json(Result::error('Log not Deleted'));
}
});
示例5: __defaultReturn
function __defaultReturn($success_message, $error_messages)
{
if (is_html()) {
if (!$error_messages) {
Flash::ok($success_message);
return Redirect::success();
} else {
foreach ($error_messages as $error_msg) {
Flash::error($error_msg);
}
return Redirect::failure();
}
} else {
if (!$error_messages) {
return Result::ok();
} else {
return Result::error($error_messages);
}
}
}
示例6: function
<?php
$this->respond(['GET', 'POST'], '/uploadFile', function ($request, $response, $service, $app) {
$ans = FileUploader::uploadFile();
if ($ans != -1) {
$response->json(Result::success('file uploaded.', ['path' => $ans]));
} else {
$response->json(Result::error('file upload Failed.'));
}
});
示例7: elseif
$id = $request->param('id');
$assetData = $request->param('assetData');
$contactsData = $request->param('assetContacts');
$investorsData = $request->param('assetInvestors');
$result = Assets::updateAssetInvest($id, $assetData, $contactsData, $investorsData);
if ($result > 0) {
$response->json(Result::success('Asset Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Asset not Updated.'));
} else {
$response->json(Result::error('Asset not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$assetResult = Assets::deleteAsset($id);
Logs::deleteAssetInvestLogs($id);
Contacts::deleteAssetContacts($id);
Investors::deleteAssetInvestors($id);
RentAreas::deleteAssetRentAreas($id);
RentProcesses::deleteAssetRentProcesses($id);
if ($assetResult > 0) {
$response->json(Result::success('Asset Deleted.'));
} else {
$response->json(Result::error('Asset not Deleted'));
}
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
$result = Assets::getAllAssets();
$response->json(Result::success('', $result));
});
示例8: function
$isMatching = $request->param('isMatching');
if (Logs::isLogAlreadyConnectedToInvestor($assetID, $investmentProfileID)) {
$response->json(Result::error('קיים כבר לוג בין המשקיע לנכס'));
} else {
$result = Logs::matchAssetAndInvestmentProfile($assetID, $investmentProfileID, $reasons, $isMatching);
if ($result) {
$response->json(Result::success('Matched.', $result));
} else {
$response->json(Result::error('Error trying to match'));
}
}
});
$this->respond(['GET', 'POST'], '/cancel/asset-and-investment-profile', function ($request, $response, $service, $app) {
$logID = $request->param('logID');
$result = Logs::cancelMatchAssetAndInvestmentProfile($logID);
if ($result > 0) {
$response->json(Result::success('Canceled'));
} else {
$response->json(Result::error('Error trying to cancel'));
}
});
$this->respond(['GET', 'POST'], '/get/marketing-logs/all', function ($request, $response, $service, $app) {
$assetID = $request->param('assetID', '');
$investmentProfileID = $request->param('investmentProfileID', '');
$result = Logs::getAllMarketingLogs($assetID, $investmentProfileID);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Marketing Logs not found'));
}
});
示例9: _try
/**
* Tries to execute the given function and returns a result representing the
* outcome, i.e. if the function returns normally, a successful result is
* returned containing the return value and if the function throws an exception,
* an error result is returned containing the error
*
* $f should take no arguments and return a value that will be wrapped in a
* success if the computation completes successfully
*
* The _ is required if we want to use the word try since it is keyword
*/
public static function _try(callable $f)
{
try {
return Result::success($f());
} catch (\Exception $error) {
return Result::error($error);
}
}
示例10: function
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Notes::getNote($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Note not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = Notes::updateNote($id, $data);
if ($result > 0) {
$response->json(Result::success('Note Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Note not Updated.'));
} else {
$response->json(Result::error('Note not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Notes::deleteNote($id);
if ($result > 0) {
$response->json(Result::success('Note Deleted.'));
} else {
$response->json(Result::error('Note not Deleted'));
}
});
示例11: getSubmissionPart
function getSubmissionPart($against)
{
# Validating file inputs is a rather difficult task.
# This solution is based on: http://php.net/manual/en/features.file-upload.php#114004
# It should be pretty bullet-proof, which is important because
# it is easy to create security vulnerabilities with file uploads.
return $against->files($this->name)->ifOk(function ($val) {
# See http://php.net/manual/en/features.file-upload.php
if (!is_array($val) || !isset($val['error']) || is_array($val['error'])) {
return Result::error('Invalid data.');
} else {
if ($val['error'] === UPLOAD_ERR_INI_SIZE || $val['error'] === UPLOAD_ERR_FORM_SIZE) {
return Result::error('File size exceeds server or form limit.');
} else {
if ($val['error'] === UPLOAD_ERR_NO_FILE) {
return Result::none(null);
} else {
if ($val['error'] === UPLOAD_ERR_OK) {
return Result::ok($val);
} else {
return Result::error('Error uploading file.');
}
}
}
}
})->requiredMaybe($this->required)->ifOk(function ($file) {
if ($file['size'] > $this->maxSize) {
return Result::error('File must be under ' . $this->maxSize . ' bytes in size.');
} else {
return Result::ok($file);
}
})->ifOk(function ($file) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->file($file['tmp_name']);
$ext = array_search($mime, $this->allowedExtensions, true);
if ($ext === false) {
return Result::error('Invalid file type or wrong MIME type. Allowed extensions are: ' . implode(', ', array_keys($this->allowedExtensions)) . '.');
}
if (!is_uploaded_file($file['tmp_name'])) {
return Result::error('Security error.');
}
$filename = sha1_file($file['tmp_name']) . '-' . floor(microtime(true)) . '.' . $ext;
return Result::ok(new FileInfo($file, $filename, $mime, $this->permissions));
})->name($this->name);
}
示例12: function
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = RentAreas::getRentArea($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('RentArea not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = RentAreas::updateRentArea($id, $data);
if ($result > 0) {
$response->json(Result::success('RentArea Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('RentArea not Updated.'));
} else {
$response->json(Result::error('RentArea not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = RentAreas::deleteRentArea($id);
if ($result > 0) {
$response->json(Result::success('RentArea Deleted.'));
} else {
$response->json(Result::error('RentArea not Deleted'));
}
});
示例13: function
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = Regions::updateRegion($id, $data);
if ($result > 0) {
$response->json(Result::success('Region Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Region not Updated.'));
} else {
$response->json(Result::error('Region not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Regions::deleteRegion($id);
if ($result > 0) {
$response->json(Result::success('Region Deleted.'));
} else {
$response->json(Result::error('Region not Deleted'));
}
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
$result = Regions::getAllRegions();
$response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/index/all', function ($request, $response, $service, $app) {
$result = Regions::getAllRegionsForIndex();
$response->json(Result::success('', $result));
});
示例14: json_decode
$data = json_decode($request->body(), true);
// Access only for Current Agent
if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
$response->json(Result::error('Access is denied'));
} else {
$result = Agents::updateAgent($id, $data);
if ($result > 0) {
$response->json(Result::success('Agent Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Agent not Updated.'));
} else {
$response->json(Result::error('Agent not found'));
}
}
});
$this->respond(['GET', 'POST'], '/edit/password/[:id]', function ($request, $response, $service) {
$id = $request->param('id');
$oldPassword = $request->param('oldPassword', '');
$newPassword = $request->param('newPassword', '');
// Access only for Current Agent
if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
$response->json(Result::error('Access is denied'));
} else {
$result = User::editPassword($oldPassword, $newPassword, $newPassword);
if ($result === true) {
$response->json(Result::success('edited password successfully'));
} else {
$response->json(Result::error($result));
}
}
});
示例15: function
} else {
$response->json(Result::error('Contact not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$contactResult = Contacts::deleteContact($id);
Conversations::deleteContactConversations($id);
if ($contactResult > 0) {
$response->json(Result::success('Contact Deleted.'));
} else {
$response->json(Result::error('Contact not Deleted'));
}
});
$this->respond(['GET', 'POST'], '/get/all-for-index', function ($request, $response, $service, $app) {
$result = Contacts::getAllContactsForIndex();
$response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
$result = Contacts::getAllContacts();
$response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/get-investor-contacts/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$contacts = Contacts::getInvestorCrmContacts($id);
if ($contacts) {
$response->json(Result::success('', $contacts));
} else {
$response->json(Result::error('Contact not found'));
}
});