/** * Lists all EventLogs * * @return mixed */ public function indexAction() { $logTypes = EventLogParams::adminLevelEventLogs(); $source = new Entity('OjsUserBundle:EventLog'); $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function (QueryBuilder $qb) use($tableAlias, $logTypes) { $expression = $qb->expr()->in($tableAlias . '.eventInfo', ':logTypes'); $qb->andWhere($expression)->setParameters(['logTypes' => $logTypes]); return $qb; }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", "actions"); $actionColumn->setRowActions([$gridAction->showAction('ojs_admin_event_log_show', 'id')]); $grid->addColumn($actionColumn); return $grid->getGridResponse('OjsAdminBundle:AdminEventLog:index.html.twig', ['grid' => $grid]); }
/** * Lists all EventLog according to user role. * @todo Add items to EventLogParams for every role * * @return mixed */ public function indexAction() { /** @var User $user */ $user = $this->getUser(); $logTypes = EventLogParams::editorLevelEventLogs(); $source = new Entity('OjsUserBundle:EventLog'); $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function (QueryBuilder $qb) use($tableAlias, $logTypes, $user) { $expression = $qb->expr()->in($tableAlias . '.eventInfo', ':logTypes'); $qb->andWhere($expression)->setParameter('logTypes', $logTypes); $qb->andWhere("{$tableAlias}.userId = :userId OR {$tableAlias}.affectedUserId = :userId")->setParameter('userId', $user->getId()); return $qb; }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", "actions"); $rowAction[] = $gridAction->showAction('user_eventlog_show', 'id'); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); return $grid->getGridResponse('OjsUserBundle:EventLog:index.html.twig', ['grid' => $grid]); }