/** * @param null $role * @return RowAction */ public function cmsAction($role = null) { $route = 'ojs_admin_page_index'; $rowAction = new RowAction('<i class="fa fa-anchor"></i>', $route); $rowAction->setAttributes(['class' => 'btn btn-info btn-xs ', 'data-toggle' => 'tooltip', 'title' => "CMS"]); $rowAction->setRouteParameters(['id', 'object']); $rowAction->setRoute($route); if ($role) { $rowAction->setRole($role); } $postExtension = $this->postExtension; $rowAction->manipulateRender(function (RowAction $action, Row $row) use($postExtension) { $entity = $row->getEntity(); $object = $postExtension->cmsobject($entity); $action->setRouteParameters(['id', 'object' => $object]); return $action; }); return $rowAction; }
/** * @param string $route * @param string $key * @param mixed $role * @param string $confirmMessage * @return RowAction */ public function deleteAction($route, $key = 'id', $role = null, $confirmMessage = 'sure') { $rowAction = new RowAction('<i class="fa fa-trash-o"></i>', $route); $rowAction->setRouteParameters($key); $translator = $this->translator; $csrfTokenManager = $this->csrfTokenManager; $rowAction->manipulateRender(function (RowAction $action, Row $row) use($translator, $csrfTokenManager, $route, $confirmMessage) { $route = str_replace('_delete', '', $route); $token = $csrfTokenManager->getToken($route . $row->getPrimaryFieldValue()); $action->setAttributes(['class' => 'btn btn-danger btn-xs delete', 'data-toggle' => 'tooltip', 'title' => $translator->trans("delete"), 'data-token' => $token, 'data-method' => 'delete', 'data-confirm' => $this->translator->trans($confirmMessage)]); return $action; }); if ($role) { $rowAction->setRole($role); } return $rowAction; }