-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHook.php
More file actions
executable file
·56 lines (52 loc) · 1.46 KB
/
Hook.php
File metadata and controls
executable file
·56 lines (52 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Acms\Plugins\GoogleSheets;
use ACMS_POST_Form_Submit;
use Acms\Services\Facades\Logger;
use Acms\Services\Facades\Common;
class Hook
{
/**
* POSTモジュール処理前
* $thisModuleのプロパティを参照・操作するなど
*
* @param \ACMS_POST $thisModule
* @return void
*/
public function afterPostFire($thisModule): void
{
$formCode = $thisModule->Post->get('id');
if(!$formCode) {
return;
}
if (!($thisModule instanceof ACMS_POST_Form_Submit)) {
return;
}
$info = $thisModule->loadForm($formCode);
if (empty($info)) {
return;
}
if ($info['data']->getChild('mail')->get('spreadsheet_void') !== 'on') {
return;
};
if (!$thisModule->Post->isValidAll()) {
return;
}
$step = $thisModule->Post->get('error');
if (empty($step)) {
$step = $thisModule->Get->get('step');
}
$step = $thisModule->Post->get('step', $step);
if (in_array($step, ['forbidden', 'repeated'])) {
return;
}
try {
$engine = new Engine($formCode, $thisModule);
$engine->send();
} catch (\Exception $e) {
Logger::warning(
'【Google Sheets】Google Sheets plugin: ' . $e->getMessage(),
Common::exceptionArray($e)
);
}
}
}