Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Mar 4, 2020
1 parent 3f7f18a commit 01ae808
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inkifi/core"
,"version": "0.1.9"
,"version": "0.2.0"
,"description": "A custom module for inkifi.com"
,"type": "magento2-module"
,"homepage": "https://github.com/inkifi/core"
Expand Down
13 changes: 8 additions & 5 deletions lib/endpoint.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
use Closure as F;
use Df\Framework\W\Result\Json as J;
use Df\Framework\W\Result\Json;
use Df\Framework\W\Result\Text;
/**
* 2020-03-04
* @used-by \Inkifi\Pwinty\Controller\Index\Index::execute()
Expand All @@ -10,10 +11,12 @@
* @used-by \Mangoit\MediaclipHub\Controller\Index\OrderStatusUpdateEndpoint::execute()
* @used-by \Mangoit\MediaclipHub\Controller\Index\RenewMediaclipToken::execute()
* @param F $f
* @return J
* @param string $onSuccess [optional]
* @param bool $plain [optional]
* @return Json|Text
*/
function ikf_endpoint(F $f) {/** @var mixed $r */
try {$r = $f() ?: 'OK';}
function ikf_endpoint(F $f, $onSuccess = 'OK', $plain = false) {/** @var mixed $r */
try {$r = $f() ?: $onSuccess;}
catch (\Exception $e) {
df_500(); // 2019-05-17 https://doc.mediaclip.ca/hub/store-endpoints#replying-with-errors
$r = ['code' => 500, 'message' => df_ets($e)];
Expand All @@ -22,5 +25,5 @@ function ikf_endpoint(F $f) {/** @var mixed $r */
throw $e; // 2016-03-27 It is convenient for me to the the exception on the screen.
}
}
return J::i($r);
return $plain ? Text::i($r) : Json::i($r);
}

0 comments on commit 01ae808

Please sign in to comment.