Skip to content

Commit

Permalink
デバックモード判定を Ver. 3.1 に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
uidev1116 committed Nov 13, 2023
1 parent ae1fef1 commit 4da4b71
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Acms\Plugins\Zoho;

use Acms\Services\Facades\Process;

use ACMS_POST_Form_Submit;

class Hook
Expand Down Expand Up @@ -38,36 +36,33 @@ public function afterPostFire($thisModule)
userErrorLog('Not Found Form.');
return;
}
$config = $info['data']->getChild('mail');

$className = __NAMESPACE__ . '\\' . 'Engine';
if ($config->get('Background') === '1' && class_exists('Process')) {
$autoload = dirname(__FILE__).'/vendor/autoload.php';
$manager = Process::newProcessManager();
$manager->addTask(function () use ($info, $thisModule, $className, $autoload) {
require_once $autoload;
try {
$engine = new $className($info, $thisModule->Post);
$engine->send();
} catch (\Exception $e) {
if (DEBUG_MODE) {
throw $e;
}
userErrorLog('ACMS Warning: Zoho plugin, ' . $e->getMessage());
}
});
$manager->run();
} else {
try {
$engine = new $className($info, $thisModule->Post);
$engine->send();
} catch (\Exception $e) {
if (DEBUG_MODE) {
throw $e;
}
userErrorLog('ACMS Warning: Zoho plugin, ' . $e->getMessage());
try {
$engine = new Engine($info, $thisModule->Post);
$engine->send();
} catch (\Exception $e) {
if ($this->isDebugMode()) {
throw $e;
}
userErrorLog('ACMS Warning: Zoho plugin, ' . $e->getMessage());
}

}

/**
* デバックモードかどうか
*
* @return bool
*/
private function isDebugMode(): bool
{
if (function_exists('isDebugMode')) {
return isDebugMode();
}
if (defined('DEBUG_MODE') && DEBUG_MODE) {
return true;
}

return false;
}
}

0 comments on commit 4da4b71

Please sign in to comment.