/**
  * @Route("/ajax/log/get")
  */
 public function ajaxLogGetAction()
 {
     $request = new Request($_GET, $_POST);
     $page = (int) $request->request->get('page');
     $username = (string) $request->request->get('username');
     $logFile = (string) $request->request->get('logfile');
     $rows = (int) $request->request->get('rows');
     $date = (string) $request->request->get('date');
     $time = (string) $request->request->get('time');
     $search = (string) $request->request->get('search');
     $regular_expression = (int) $request->request->get('regular_expression');
     if ($regular_expression == 1) {
         $regular_expression = $search;
         $search = '';
     } else {
         $regular_expression = '';
     }
     if (!preg_match("/^(.*).log\$/", $logFile)) {
         $logFile = '';
     }
     $log_rows_on_page = $this->container->getParameter('log_rows_on_page');
     if (!in_array($rows, $log_rows_on_page)) {
         $rows = reset($log_rows_on_page);
     }
     $limitOffset = $page * $rows;
     $limitRows = $rows;
     $logFilesContent = [];
     if ($username) {
         if ($logFile) {
             $realPath = HelperService::getLogFilesPath($username) . '/' . $logFile;
             $logFiles[] = new \SplFileInfo($realPath);
         } else {
             $logFiles = HelperService::getLogFilesInfo($username);
         }
         foreach ($logFiles as $logFile) {
             $logReader = new LogReaderService();
             $logReader->setRealPath($logFile->getRealPath());
             $logReader->setDate($date);
             $logReader->setTime($time);
             $logReader->setQueryText($search);
             $logReader->setRegularExpression($regular_expression);
             $logReader->setLimitOffset($limitOffset);
             $logReader->setLimitRows($limitRows);
             $logFilesContent[] = ['file_path' => $logFile->getRealPath(), 'data' => $logReader->getContent()];
         }
     }
     $response = new JsonResponse();
     return $response->setData(['page' => $page, 'content' => $logFilesContent]);
 }
 public function testGetLogFilesPath()
 {
     $username = '******' . rand();
     $expectValue = '/home/' . $username . '/logs';
     $this->assertEquals($expectValue, HelperService::getLogFilesPath($username));
 }