public function wrapResult($result, $wrappingRequired) { if ($result === null) { $actionResult = new ufront_web_result_EmptyResult(true); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($actionResult)); } else { $future = null; if (($wrappingRequired & 1 << ufront_web_result_ResultWrapRequired::$WRFuture->index) !== 0) { $future = $this->wrapInFuture($result); } else { $future = $result; } $surprise = null; if (($wrappingRequired & 1 << ufront_web_result_ResultWrapRequired::$WROutcome->index) !== 0) { $surprise = $this->wrapInOutcome($future); } else { $surprise = $future; } $finalResult = null; if (($wrappingRequired & 1 << ufront_web_result_ResultWrapRequired::$WRResultOrError->index) !== 0) { $finalResult = $this->wrapResultOrError($surprise); } else { $finalResult = $surprise; } return $finalResult; } }
public function deleteTemporaryFile() { try { @unlink($this->tmpFileName); return tink_core_Outcome::Success(tink_core_Noise::$Noise); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; return tink_core_Outcome::Failure(tink_core_TypedError::withData(null, "Error during TmpFileUpload.deleteTmpFile()", $e, _hx_anonymous(array("fileName" => "TmpFileUpload.hx", "lineNumber" => 165, "className" => "ufront.web.upload.TmpFileUpload", "methodName" => "deleteTemporaryFile")))); } }
public function handleRequest($httpContext) { $doneTrigger = new tink_core_FutureTrigger(); if (ufront_remoting_RemotingHandler_0($this, $doneTrigger, $httpContext)) { $r = $httpContext->response; $remotingResponse = null; $r->setOk(); $path = null; $args = null; try { $this->initializeContext($httpContext->injector); $params = $httpContext->request->get_params(); if (!$params->exists("__x")) { throw new HException("Remoting call did not have parameter `__x` which describes which API call to make. Aborting"); } $remotingCall = null; $s = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "__x"); $remotingCall = urldecode($s); $u = new haxe_Unserializer($remotingCall); $path = $u->unserialize(); $args = $u->unserialize(); $apiCallFinished = $this->executeApiCall($path, $args, $this->context, $httpContext->actionContext); $remotingResponse = tink_core__Future_Future_Impl_::map($apiCallFinished, array(new _hx_lambda(array(&$apiCallFinished, &$args, &$doneTrigger, &$httpContext, &$params, &$path, &$r, &$remotingCall, &$remotingResponse, &$u), "ufront_remoting_RemotingHandler_1"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $error = $e; $apiNotFoundMessages = new _hx_array(array("Invalid path", "No such object", "Can't access", "No such method")); if ($path !== null && $args !== null && Std::is($e, _hx_qtype("String")) && Lambda::exists($apiNotFoundMessages, array(new _hx_lambda(array(&$apiNotFoundMessages, &$args, &$doneTrigger, &$e, &$error, &$httpContext, &$path, &$r, &$remotingResponse), "ufront_remoting_RemotingHandler_2"), 'execute'))) { $remotingResponse = tink_core__Future_Future_Impl_::sync("Unable to access " . _hx_string_or_null($path->join(".")) . " - API Not Found (" . _hx_string_or_null($error) . "). See " . Std::string($this->context->objects)); $r->setNotFound(); } else { $r->setInternalError(); $remotingResponse = tink_core__Future_Future_Impl_::sync($this->remotingError($e, $httpContext)); } } $remotingResponse(array(new _hx_lambda(array(&$args, &$doneTrigger, &$e, &$httpContext, &$path, &$r, &$remotingResponse), "ufront_remoting_RemotingHandler_3"), 'execute')); } else { $result1 = tink_core_Outcome::Success(tink_core_Noise::$Noise); if ($doneTrigger->{"list"} === null) { false; } else { $list1 = $doneTrigger->{"list"}; $doneTrigger->{"list"} = null; $doneTrigger->result = $result1; tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1); tink_core__Callback_CallbackList_Impl_::clear($list1); true; } } return $doneTrigger->future; }
public function getTemplate($path, $templatingEngine = null) { $_g = $this; if ($this->cache !== null && $this->cache->exists($path)) { $cached = $this->cache->get($path); if ($templatingEngine === null || $templatingEngine->type === $cached->a) { return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($cached->b)); } } $tplStrReady = new tink_core_FutureTrigger(); $ext = haxe_io_Path::extension($path); $finalPath = null; if ($templatingEngine !== null && $ext !== "") { $finalPath = $path; $this1 = $this->getTemplateString($finalPath); $this1(array(new _hx_lambda(array(&$_g, &$ext, &$finalPath, &$path, &$templatingEngine, &$this1, &$tplStrReady), "ufront_view_UFViewEngine_0"), 'execute')); } else { if ($templatingEngine !== null && $ext === "") { $exts = $templatingEngine->extensions->copy(); $testNextExtension = null; $testNextExtension1 = null; $testNextExtension1 = array(new _hx_lambda(array(&$_g, &$ext, &$exts, &$finalPath, &$path, &$templatingEngine, &$testNextExtension, &$testNextExtension1, &$tplStrReady), "ufront_view_UFViewEngine_1"), 'execute'); $testNextExtension = $testNextExtension1; call_user_func($testNextExtension); } else { if ($templatingEngine === null && $ext !== "") { $tplEngines = $this->engines->copy(); $testNextEngine = null; $testNextEngine1 = null; $testNextEngine1 = array(new _hx_lambda(array(&$_g, &$ext, &$finalPath, &$path, &$templatingEngine, &$testNextEngine, &$testNextEngine1, &$tplEngines, &$tplStrReady), "ufront_view_UFViewEngine_2"), 'execute'); $testNextEngine = $testNextEngine1; call_user_func($testNextEngine); } else { if ($templatingEngine === null && $ext === "") { $tplEngines1 = $this->engines->copy(); $engine1 = null; $extensions = new _hx_array(array()); $extensionsUsed = new _hx_array(array()); $ext2 = null; $testNextEngineOrExtension = null; $testNextEngineOrExtension1 = null; $testNextEngineOrExtension1 = array(new _hx_lambda(array(&$_g, &$engine1, &$ext, &$ext2, &$extensions, &$extensionsUsed, &$finalPath, &$path, &$templatingEngine, &$testNextEngineOrExtension, &$testNextEngineOrExtension1, &$tplEngines1, &$tplStrReady), "ufront_view_UFViewEngine_3"), 'execute'); $testNextEngineOrExtension = $testNextEngineOrExtension1; call_user_func($testNextEngineOrExtension); } } } } return tink_core__Future_Future_Impl_::_tryFailingMap($tplStrReady->future, array(new _hx_lambda(array(&$_g, &$ext, &$finalPath, &$path, &$templatingEngine, &$tplStrReady), "ufront_view_UFViewEngine_4"), 'execute')); }
static function catchExceptions($f, $report = null) { try { return tink_core_Outcome::Success(call_user_func($f)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; if (($e = $_ex_) instanceof tink_core_TypedError) { return tink_core_Outcome::Failure($e); } else { $e1 = $_ex_; return tink_core_Outcome::Failure($report === null ? tink_core_TypedError::withData(null, "Unexpected Error", $e1, _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 97, "className" => "tink.core.TypedError", "methodName" => "catchExceptions"))) : call_user_func_array($report, array($e1))); } } }
public function getTemplateString($viewRelativePath) { $fullPath = _hx_string_or_null($this->get_viewDirectory()) . _hx_string_or_null($viewRelativePath); try { if (file_exists($fullPath)) { return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(haxe_ds_Option::Some(sys_io_File::getContent($fullPath)))); } else { return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(haxe_ds_Option::$None)); } } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; return $e->asSurpriseError("Failed to load template " . _hx_string_or_null($viewRelativePath)); } }
function tink_core__Outcome_OutcomeMapper_Impl__1(&$f, $o) { switch ($o->index) { case 0: $d = _hx_deref($o)->params[0]; $_g = call_user_func_array($f, array($d)); switch ($_g->index) { case 0: $d1 = _hx_deref($_g)->params[0]; return tink_core_Outcome::Success($d1); break; case 1: $f1 = _hx_deref($_g)->params[0]; return tink_core_Outcome::Failure(tink_core_Either::Right($f1)); break; } break; case 1: $f2 = _hx_deref($o)->params[0]; return tink_core_Outcome::Failure(tink_core_Either::Left($f2)); break; } }
public function commit() { return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(tink_core_Noise::$Noise)); }
public function parseMultipart($onPart = null, $onData = null, $onEndPart = null) { $_g = $this; if (!$this->isMultipart()) { return ufront_core_SurpriseTools::success(); } if ($this->_parsed) { throw new HException(ufront_web_HttpError::internalServerError("parseMultipart() has been called more than once.", null, _hx_anonymous(array("fileName" => "HttpRequest.hx", "lineNumber" => 93, "className" => "sys.ufront.web.context.HttpRequest", "methodName" => "parseMultipart")))); } $this->_parsed = true; if ($onPart === null) { $onPart = array(new _hx_lambda(array(&$_g, &$onData, &$onEndPart, &$onPart), "sys_ufront_web_context_HttpRequest_0"), 'execute'); } if ($onData === null) { $onData = array(new _hx_lambda(array(&$_g, &$onData, &$onEndPart, &$onPart), "sys_ufront_web_context_HttpRequest_1"), 'execute'); } if ($onEndPart === null) { $onEndPart = array(new _hx_lambda(array(&$_g, &$onData, &$onEndPart, &$onPart), "sys_ufront_web_context_HttpRequest_2"), 'execute'); } $this->post = new haxe_ds_StringMap(); $noParts = true; $isFile = false; $partName = null; $fileName = null; $currentContent = null; $callbackFutures = new _hx_array(array()); $errors = new _hx_array(array()); $processCallbackResult = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName), "sys_ufront_web_context_HttpRequest_3"), 'execute'); $doEndOfPart = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_4"), 'execute'); $doPart = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$doEndOfPart, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_5"), 'execute'); $doData = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$doEndOfPart, &$doPart, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_6"), 'execute'); try { sys_ufront_web_context__HttpRequest_WebOverride::parseMultipart($doPart, $doData); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $stack = haxe_CallStack::toString(haxe_CallStack::exceptionStack()); $err1 = "Failed to parse multipart data: " . Std::string($e) . "\n" . _hx_string_or_null($stack); $errors->push($err1); } if ($noParts === false) { call_user_func($doEndOfPart); } if ($callbackFutures->length > 0) { return tink_core__Future_Future_Impl_::flatMap(tink_core__Future_Future_Impl_::ofMany($callbackFutures, null), array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$doData, &$doEndOfPart, &$doPart, &$e, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_7"), 'execute'), null); } else { $data5 = tink_core_Outcome::Success(tink_core_Noise::$Noise); return tink_core__Future_Future_Impl_::sync($data5); } }
function tink_core__Future_Future_Impl__13(&$f, &$map, $o) { switch ($o->index) { case 0: $a = _hx_deref($o)->params[0]; return tink_core_Outcome::Success(call_user_func_array($map, array($a))); break; case 1: $f1 = _hx_deref($o)->params[0]; return tink_core_Outcome::Failure($f1); break; } }
static function attempt($f, $report) { try { return tink_core_Outcome::Success(call_user_func($f)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; return tink_core_Outcome::Failure(call_user_func_array($report, array($e))); } }
function ufront_app_HttpApplication_9(&$_g, &$ctx, &$done, &$flag, &$modules, &$runNext, &$runNext1) { $m = $modules->shift(); if ($flag !== null && ($ctx->completion & 1 << $flag->index) !== 0) { $result = tink_core_Outcome::Success(tink_core_Noise::$Noise); if ($done->{"list"} === null) { false; } else { $list = $done->{"list"}; $done->{"list"} = null; $done->result = $result; tink_core__Callback_CallbackList_Impl_::invoke($list, $result); tink_core__Callback_CallbackList_Impl_::clear($list); true; } } else { if ($m === null) { if ($flag !== null) { $ctx->completion |= 1 << $flag->index; } $result1 = tink_core_Outcome::Success(tink_core_Noise::$Noise); if ($done->{"list"} === null) { false; } else { $list1 = $done->{"list"}; $done->{"list"} = null; $done->result = $result1; tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1); tink_core__Callback_CallbackList_Impl_::clear($list1); true; } } else { $moduleCb = isset($m->a) ? $m->a : array($m, "a"); $_g->currentModule = $m->b; $moduleResult = null; try { $moduleResult = call_user_func_array($moduleCb, array($ctx)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $ctx->messages->push(_hx_anonymous(array("msg" => "Caught error " . Std::string($e) . " while executing module " . _hx_string_or_null($_g->currentModule->className) . "." . _hx_string_or_null($_g->currentModule->methodName) . " in HttpApplication.executeModules()", "pos" => _hx_anonymous(array("fileName" => "HttpApplication.hx", "lineNumber" => 405, "className" => "ufront.app.HttpApplication", "methodName" => "executeModules")), "type" => ufront_log_MessageType::$MLog))); $moduleResult = tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::wrap($e, null, $_g->currentModule))); } $moduleResult(array(new _hx_lambda(array(&$_g, &$ctx, &$done, &$e, &$flag, &$m, &$moduleCb, &$moduleResult, &$modules, &$runNext, &$runNext1), "ufront_app_HttpApplication_22"), 'execute')); } } }
public function commitSession() { if ($this->session !== null) { return $this->session->commit(); } else { return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(tink_core_Noise::$Noise)); } }
public function _makeApiCall($method, $args, $flags, $pos = null) { if (!php_Boot::$skip_constructor) { $_g = $this; $remotingCallString = "" . _hx_string_or_null($this->className) . "." . _hx_string_or_null($method) . "(" . _hx_string_or_null($args->join(",")) . ")"; $callApi = array(new _hx_lambda(array(&$_g, &$args, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_0"), 'execute'); $returnError = array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_1"), 'execute'); if (($flags & 1 << ufront_api_ApiReturnType::$ARTVoid->index) !== 0) { try { call_user_func($callApi); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(null)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; return call_user_func_array($returnError, array($e1)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0 && ($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) { try { $surprise = call_user_func($callApi); return tink_core__Future_Future_Impl_::map($surprise, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString, &$returnError, &$surprise), "ufront_api_UFAsyncApi_2"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e2 = $_ex_; return call_user_func_array($returnError, array($e2)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0) { try { $future = call_user_func($callApi); return tink_core__Future_Future_Impl_::map($future, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$future, &$method, &$pos, &$remotingCallString, &$returnError), "ufront_api_UFAsyncApi_3"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e3 = $_ex_; return call_user_func_array($returnError, array($e3)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) { try { $outcome = call_user_func($callApi); switch ($outcome->index) { case 0: $data2 = _hx_deref($outcome)->params[0]; return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($data2)); break; case 1: $err1 = _hx_deref($outcome)->params[0]; return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::remotingError(ufront_remoting_RemotingError::RApiFailure($remotingCallString, $err1), $pos))); break; } } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e4 = $_ex_; return call_user_func_array($returnError, array($e4)); } } else { try { $result1 = call_user_func($callApi); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($result1)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e5 = $_ex_; return call_user_func_array($returnError, array($e5)); } } } } } } }
static function asGoodSurprise($data) { return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($data)); }
function ufront_core_CallbackTools_2(&$cb, &$pos, &$t, $error, $val1, $val2) { if ($error !== null) { $e = tink_core_TypedError::withData(500, "" . Std::string($error), $pos, _hx_anonymous(array("fileName" => "AsyncTools.hx", "lineNumber" => 266, "className" => "ufront.core.CallbackTools", "methodName" => "asSurprisePair"))); $result = tink_core_Outcome::Failure($e); if ($t->{"list"} === null) { false; } else { $list = $t->{"list"}; $t->{"list"} = null; $t->result = $result; tink_core__Callback_CallbackList_Impl_::invoke($list, $result); tink_core__Callback_CallbackList_Impl_::clear($list); true; } } else { $result1 = tink_core_Outcome::Success(new tink_core_MPair($val1, $val2)); if ($t->{"list"} === null) { false; } else { $list1 = $t->{"list"}; $t->{"list"} = null; $t->result = $result1; tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1); tink_core__Callback_CallbackList_Impl_::clear($list1); true; } } }
function ufront_web_upload_TmpFileUploadMiddleware_3(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onEndPart, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath, $result) { switch ($result->index) { case 0: $s = _hx_deref($result)->params[0]; return tink_core_Outcome::Success($s); break; case 1: $f = _hx_deref($result)->params[0]; return tink_core_Outcome::Failure(ufront_web_HttpError::wrap($f, null, _hx_anonymous(array("fileName" => "TmpFileUploadMiddleware.hx", "lineNumber" => 101, "className" => "ufront.web.upload.TmpFileUploadMiddleware", "methodName" => "requestIn")))); break; } }