/** * @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); }
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))); }