security->getUser(); $username = $user instanceof User ? $user->getUsername() : 'system'; $auditLog = new AuditLog(); $auditLog ->setEmployee($employee) ->setUsername($username) ->setAction($action) ->setEntityType($entityType) ->setEntityId($entityId) ->setDescription($description) ->setChanges($changes) ->setAffectedDate($affectedDate) ; $this->entityManager->persist($auditLog); } }