appState->getAreaCode(); } catch (\Throwable) { // Some programmatic cancellations run before an area is initialized. } if ($areaCode === 'crontab') { return self::SCHEDULED_TASK; } $fullActionName = method_exists($this->request, 'getFullActionName') ? (string)$this->request->getFullActionName() : ''; if ($fullActionName === 'esun_customer_order_cancel') { return self::CUSTOMER; } if ($areaCode === 'adminhtml') { return self::ADMINISTRATOR; } return self::SYSTEM; } public function getComment(string $source): string { return match ($source) { self::CUSTOMER => 'The customer canceled this order from their account.', self::SCHEDULED_TASK => 'A scheduled task canceled this order automatically.', self::ADMINISTRATOR => 'An administrator canceled this order.', default => 'A system process canceled this order.', }; } }