log_action = $this->logAction->value; $log->log_source = $this->logSource; $log->log_params = json_encode(['refcamp' => $refcamp]); $log->log_statut = 'NOK'; $log->log_message = "La campagne n'existe pas ou n'est pas un panier"; $log->save(); } /** * Write error log when there's a wrong or missing parameter in the request. * * @param string|null $refcamp * @param string|null $refadherent * @param string|null $refsite * @param string|null $panier * @return void */ public function writeLogErrorWrongRequestParameters( $refcamp, $refadherent, $refsite, $panier ) { $log = new Log(); $log->log_action = $this->logAction->value; $log->log_source = $this->logSource; $log->log_params = json_encode([ 'refcamp' => $refcamp ?? 'NO DATA', 'refadherent' => $refadherent ?? 'NO DATA', 'refsite' => $refsite ?? 'NO DATA', 'panier' => $panier ?? 'NO DATA' ]); $log->log_statut = 'NOK'; $log->log_message = "Des paramètres de la requête sont mal renseignés ou non présents"; $log->save(); } /** * Write success log when the basket is created or updated. * * @param string $refcamp * @param string $refadherent * @param string $refsite * @param string $panier * @param array $panierCoupons * @return void */ public function writeLogSuccessBasketCreated( string $refcamp, string $refadherent, string $refsite, string $panier, array $panierCoupons ) { $log = new Log(); $log->log_action = $this->logAction->value; $log->log_source = $this->logSource; $log->log_params = json_encode([ 'refcamp' => $refcamp, 'refadherent' => $refadherent, 'refsite' => $refsite, 'panier' => $panier ]); $log->log_refsite = $refsite; $log->log_statut = 'OK'; $log->log_message = json_encode( ['Message' => 'Le panier a bien été créé/mis à jour', 'Coupons' => $panierCoupons], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); $log->save(); } }