-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c834609
commit 3f7f18a
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
use Closure as F; | ||
use Df\Framework\W\Result\Json as J; | ||
/** | ||
* 2020-03-04 | ||
* @used-by \Inkifi\Pwinty\Controller\Index\Index::execute() | ||
* @used-by \Mangoit\MediaclipHub\Controller\Index\AddToCartEndpoint::execute() | ||
* @used-by \Mangoit\MediaclipHub\Controller\Index\GetPriceEndpoint::execute() | ||
* @used-by \Mangoit\MediaclipHub\Controller\Index\OneflowResponse::execute() | ||
* @used-by \Mangoit\MediaclipHub\Controller\Index\OrderStatusUpdateEndpoint::execute() | ||
* @used-by \Mangoit\MediaclipHub\Controller\Index\RenewMediaclipToken::execute() | ||
* @param F $f | ||
* @return J | ||
*/ | ||
function ikf_endpoint(F $f) {/** @var mixed $r */ | ||
try {$r = $f() ?: 'OK';} | ||
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)]; | ||
df_log($e, $this); | ||
if (df_my_local()) { | ||
throw $e; // 2016-03-27 It is convenient for me to the the exception on the screen. | ||
} | ||
} | ||
return J::i($r); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
<?php | ||
use Magento\Framework\Component\ComponentRegistrar as R; | ||
R::register(R::MODULE, 'Inkifi_Core', __DIR__); | ||
R::register(R::MODULE, 'Inkifi_Core', __DIR__); | ||
// 2017-04-25, 2017-12-13 | ||
// Unfortunately, I have not found a way to make this code reusable among my modules. | ||
// I tried to move this code to a `/lib` function like df_lib(), but it raises a «chicken and egg» problem, | ||
// because Magento runs the `registration.php` scripts before any `/lib` functions are initalized, | ||
// whereas the `/lib` functions are initalized from the `registration.php` scripts. | ||
$base = dirname(__FILE__); /** @var string $base */ | ||
if (is_dir($libDir = "{$base}/lib")) { /** @var string $libDir */ | ||
// 2015-02-06 | ||
// array_slice removes «.» and «..». | ||
// http://php.net/manual/function.scandir.php#107215 | ||
foreach (array_slice(scandir($libDir), 2) as $c) {require_once "{$libDir}/{$c}";} | ||
} |