예제 #1
0
 public function addLog($action = NULL)
 {
     $em = $this->getDoctrine()->getManager();
     $log = new Log();
     $user = $this->container->get('security.context')->getToken()->getUser();
     $log->setUsername($user);
     $date = new \DateTime();
     $log->setDate($date);
     $log->setAction($action);
     $url = $this->container->get('request')->headers->get('referer');
     $log->setUrl($url);
     $log->setAction('visited');
     if (strstr($url, 'login') !== FALSE) {
         $log->setAction('login');
     }
     $em->persist($log);
     $em->flush();
     return;
 }
예제 #2
0
파일: FrSave.php 프로젝트: aoll/Framework
 /**
  *@return bool
  */
 public function saveLog($em, Request $request, $username, $action = null)
 {
     //$em = $this->em;
     $log = new Log();
     //	$request->getSession();
     $date = new \DateTime();
     $log->setDate($date);
     //		$url = $this->container->get('request')->headers->get('referer');
     $url = $request->getUri();
     //	$user = $this->container->get('security.context')->getToken()->getUser();
     $user = $request->getHost();
     $log->setUsername($username);
     if (!$action) {
         $log->setAction('Page visité');
     } else {
         $log->setAction($action);
     }
     $log->setUrl($url);
     $em->persist($log);
     $em->flush();
     return strlen('ok') < 5;
 }