registerTriggers(); } /** * Register all LineList triggers * * CRITICAL ORDER: * 1. PaintCycleChangeTrigger must run first (handles painting_cycle changes) * 2. WeldLogFieldsSyncTrigger syncs basic fields to weld_logs * 3. PaintSystemSyncTrigger prepares paint_systems and color_systems data * 4. PaintMatrixOperationsTrigger creates/updates base paint_matrices records * 5. PaintSystemToMatrixSyncTrigger enriches paint_matrices with system data * 6. PaintFollowUpsSyncTrigger creates/updates paint_follow_ups (uses matrices data) * 7. ConstructionPaintLogsSyncTrigger creates construction paint logs * 8. NdeMatrixSyncTrigger creates NDE data * 9. Cleanup triggers run last */ protected function registerTriggers() { // 1. Handle painting_cycle changes first (updates weld_logs, paint_matrices, paint_follow_ups cycle) $this->register(new PaintCycleChangeTrigger()); // 2. Sync basic fields to weld_logs $this->register(new WeldLogFieldsSyncTrigger()); // 3. Prepare paint system data (paint_systems and color_systems tables) $this->register(new PaintSystemSyncTrigger()); // 4. Ensure base Paint Matrix exists/updated before enrichment $this->register(new PaintMatrixOperationsTrigger()); // 5. Sync paint systems to paint matrices (BEFORE paint follow ups creation) // This ensures paint_matrices have complete paint coat data $this->register(new PaintSystemToMatrixSyncTrigger()); // 6. Create/update paint follow ups (uses paint_matrices data) $this->register(new PaintFollowUpsSyncTrigger()); // 7. Create construction paint logs $this->register(new ConstructionPaintLogsSyncTrigger()); // 8. Create NDE Matrix records $this->register(new NdeMatrixSyncTrigger()); // 9. Sync tracing_type to Test Packages $this->register(new TestPackageTracingSyncTrigger()); // 10. Sync isolation to Test Packages $this->register(new IsolationSyncTrigger()); // 11. Final cleanup operations $this->register(new PaintingCycleDeletionTrigger()); $this->register(new SpoolStatusChangerFinalTrigger()); $this->register(new CleanupOperationsTrigger()); } /** * Register a single trigger */ public function register($trigger) { $this->triggers[$trigger->getName()] = $trigger; } /** * Get all triggers in registration order * Triggers execute in the order they are registered in registerTriggers() */ public function getTriggersInOrder(): array { return array_values($this->triggers); } /** * Get a specific trigger by name */ public function getTrigger(string $name) { return $this->triggers[$name] ?? null; } /** * Get all registered trigger names */ public function getAllTriggerNames(): array { return array_keys($this->triggers); } }