/**
  * @Route("/ajax/log_files_names/get")
  */
 public function ajaxLogFilesNamesGetAction()
 {
     $request = new Request($_GET, $_POST);
     $username = (string) $request->request->get('username');
     $nameLogFiles = [];
     if ($username) {
         try {
             $nameLogFiles = HelperService::getLogFilesNames($username);
         } catch (\Exception $e) {
             $nameLogFiles = [];
         }
     }
     $response = new JsonResponse();
     return $response->setData(['name_log_files' => $nameLogFiles]);
 }
 /**
  * @Route("/")
  * @Template()
  */
 public function indexAction()
 {
     $user = $this->getUser();
     $isAdmin = $user->getRole()->getName() == 'ROLE_ADMIN';
     if ($isAdmin === true) {
         $listUsername = HelperService::getActiveUserNames($this->getDoctrine());
     } else {
         $listUsername = array();
     }
     try {
         $nameLogFiles = HelperService::getLogFilesNames($user->getUsername());
     } catch (\Exception $e) {
         $nameLogFiles = [];
     }
     return array('log_files_names' => $nameLogFiles, 'log_rows_on_page' => $this->container->getParameter('log_rows_on_page'), 'is_admin' => $isAdmin, 'list_username' => $listUsername);
 }
示例#3
0
 protected function cronDumpLogFiles(OutputInterface $output)
 {
     $doctrine = $this->getContainer()->get('doctrine');
     $this->setDoctrine($doctrine);
     $this->setOutput($output);
     $listUsername = HelperService::getActiveUserNames($doctrine);
     foreach ($listUsername as $username) {
         try {
             $nameLogFiles = HelperService::getLogFilesNames($username);
         } catch (\Exception $e) {
             $nameLogFiles = [];
         }
         foreach ($nameLogFiles as $filename) {
             $this->dumpLogFile($username, $filename);
         }
     }
 }
 public function testGetActiveUserNames()
 {
     $em = $this->getKernel()->getContainer()->get('doctrine')->getManager();
     $this->assertTrue(is_array(HelperService::getActiveUserNames($em)));
 }