İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
// app/Http/Controllers/SaveTrigger/line_lists.php
|
||||
|
||||
use App\Services\LineListTriggers\LineListTriggerManager;
|
||||
use App\Services\LineListTriggers\LineListTriggerRegistry;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
// Memory and execution settings
|
||||
ini_set('memory_limit', '2G');
|
||||
ini_set('max_execution_time', 600);
|
||||
|
||||
$id = $request['key'];
|
||||
|
||||
// Get line list data
|
||||
$lineList = db($tableName)->where("id", $id)->first();
|
||||
if(is_null($lineList)) {
|
||||
$lineList = db($tableName)->where($id)->first();
|
||||
}
|
||||
|
||||
// Safety check - ensure we have data
|
||||
if(is_null($lineList)) {
|
||||
Log::error("LineList not found for trigger execution", [
|
||||
'line_list_id' => $id,
|
||||
'table_name' => $tableName
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Detect changes and new record status
|
||||
$isNewRecord = is_null($beforeData);
|
||||
$changedFields = detectChangedFields($lineList, $beforeData);
|
||||
|
||||
// Execute triggers via manager
|
||||
$registry = new LineListTriggerRegistry();
|
||||
$manager = new LineListTriggerManager($registry);
|
||||
|
||||
try {
|
||||
$results = $manager->executeTriggers(
|
||||
$lineList,
|
||||
$beforeData,
|
||||
$changedFields,
|
||||
$isNewRecord
|
||||
);
|
||||
|
||||
Log::info("LineList triggers execution completed", [
|
||||
'line_list_id' => $id,
|
||||
'line_no' => $lineList->line_no ?? 'NULL',
|
||||
'results_summary' => array_map(function($result) {
|
||||
if (isset($result['skipped']) && $result['skipped']) {
|
||||
return 'skipped';
|
||||
} elseif (isset($result['success']) && $result['success']) {
|
||||
return 'success';
|
||||
} elseif (isset($result['error'])) {
|
||||
return 'failed';
|
||||
}
|
||||
return 'unknown';
|
||||
}, $results)
|
||||
]);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::error("LineList triggers execution failed with critical error", [
|
||||
'line_list_id' => $id,
|
||||
'line_no' => $lineList->line_no ?? 'NULL',
|
||||
'error' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' => $th->getLine(),
|
||||
'trace' => $th->getTraceAsString()
|
||||
]);
|
||||
|
||||
throw $th;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user