/**
  * {@inheritDoc}
  */
 public function getUserName()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUserName', array());
     return parent::getUserName();
 }
Beispiel #2
0
 /**
  * Writes an entry to the audit log
  *
  * @param array $args [bundle, object, objectId, action, details, ipAddress]
  */
 public function writeToLog(array $args)
 {
     $bundle = isset($args["bundle"]) ? $args["bundle"] : "";
     $object = isset($args["object"]) ? $args["object"] : "";
     $objectId = isset($args["objectId"]) ? $args["objectId"] : "";
     $action = isset($args["action"]) ? $args["action"] : "";
     $details = isset($args["details"]) ? $args["details"] : "";
     $ipAddress = isset($args["ipAddress"]) ? $args["ipAddress"] : "";
     $log = new AuditLog();
     $log->setBundle($bundle);
     $log->setObject($object);
     $log->setObjectId($objectId);
     $log->setAction($action);
     $log->setDetails($details);
     $log->setIpAddress($ipAddress);
     $log->setDateAdded(new \DateTime());
     $user = !defined('MAUTIC_IGNORE_AUDITLOG_USER') ? $this->factory->getUser() : null;
     $userId = 0;
     $userName = '';
     if (!$user instanceof User) {
         $userId = 0;
         $userName = $this->translator->trans('mautic.core.system');
     } elseif ($user->getId()) {
         $userId = $user->getId();
         $userName = $user->getName();
     }
     $log->setUserId($userId);
     $log->setUserName($userName);
     $this->em->getRepository("MauticCoreBundle:AuditLog")->saveEntity($log);
 }