Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Mar 4, 2020
1 parent c834609 commit 3f7f18a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inkifi/core"
,"version": "0.1.8"
,"version": "0.1.9"
,"description": "A custom module for inkifi.com"
,"type": "magento2-module"
,"homepage": "https://github.com/inkifi/core"
Expand All @@ -11,7 +11,7 @@
,"homepage": "https://mage2.pro/users/dmitry_fedyuk"
,"role": "Developer"
}]
,"require": {"mage2pro/core": ">=3.12.14"}
,"require": {"mage2pro/core": ">=6.4.0"}
,"autoload": {"files": ["registration.php"], "psr-4": {"Inkifi\\Core\\": ""}}
,"keywords": ["Magento 2"]
}
26 changes: 26 additions & 0 deletions lib/endpoint.php
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);
}
14 changes: 13 additions & 1 deletion registration.php
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}";}
}

0 comments on commit 3f7f18a

Please sign in to comment.